Skip to content

Commit

Permalink
Merge pull request #5 from homanp/feat/update-types
Browse files Browse the repository at this point in the history
feat: update types
  • Loading branch information
homanp authored Nov 15, 2024
2 parents c7dc29e + 77b36ee commit c46d500
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-hand-tracker",
"version": "1.0.1",
"version": "1.0.3",
"description": "A package for creating and managing poker hand histories",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ export class OpenHandHistory {
this.ohh.pots.push(pot);
}

toJSON(): string {
return JSON.stringify(this.ohh, null, 2);
toJSON(): OHHData {
return this.ohh;
}

saveToFile(filename: string): void {
writeFileSync(filename, this.toJSON());
const stringRepresentation = JSON.stringify(this.toJSON(), null, 2);
writeFileSync(filename, stringRepresentation);
}
}

Expand Down
20 changes: 14 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
export interface Player {
name: string;
id: number;
startingStack: number;
starting_stack: number;
seat: number;
cards?: string[];
}

export interface Action {
actionNumber: number;
playerId: number;
action: string;
action_number: number;
player_id: number;
action:
| "Dealt Card"
| "Post SB"
| "Post BB"
| "Fold"
| "Check"
| "Bet"
| "Raise"
| "Call";
amount?: number;
isAllIn?: boolean;
is_allin?: boolean;
}

export interface Round {
Expand All @@ -25,7 +33,7 @@ export interface Pot {
rake?: number;
number: number;
amount: number;
playerWins: { playerId: number; winAmount: number }[];
player_wins: { player_id: number; win_amount: number }[];
}

export interface OHHData {
Expand Down

0 comments on commit c46d500

Please sign in to comment.