Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
feat(model): add new fields to game
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Mar 1, 2021
1 parent 11da44f commit 6976733
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/lib/model/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,76 @@ export class Game extends Entry {
awayBalls: number;
awayBases: number;
awayBatter: string;
awayBatterMod: string;
awayBatterName: string;
awayOdds: number;
awayOuts: number;
awayPitcher: ID;
awayPitcherMod: string;
awayPitcherName: string;
awayScore: number;
awayStrikes: number;
awayTeam: ID;
awayTeamBatterCount: number;
awayTeamColor: string;
/* awayTeamEmoji: string; */
awayTeamName: string;
awayTeamNickname: string;
awayTeamSecondaryColor: string;
/* baseRunnerMods: string[]; */
/* baseRunnerNames: string[]; */
/* baseRunners: ID[]; */
baserunnerCount: number;
/* basesOccupied: number[]; */
bottomInningScore: number;
day: number;
finalized: boolean;
gameComplete: boolean;
gameStart: boolean;
gameStartPhase: number;
halfInningOuts: number;
halfInningScore: number;
homeBalls: number;
homeBases: number;
homeBatter: ID;
homeBatterMod: string;
homeBatterName: string;
homeOdds: number;
homeOuts: number;
homePitcher: ID;
homePitcherMod: string;
homePitcherName: string;
homeScore: number;
homeStrikes: number;
homeTeam: ID;
homeTeamBatterCount: number;
homeTeamColor: string;
/* homeTeamEmoji: string; */
homeTeamName: string;
homeTeamNickname: string;
homeTeamSecondaryColor: string;
inning: number;
isPostseason: boolean;
isTitleMatch: boolean;
lastUpdate: string;
newInningPhase: number;
/* outcomes: string[]; */
phase: number;
playCount: number;
repeatCount: number;
rules: ID;
scoreLedger: string;
scoreUpdate: string;
season: number;
seriesIndex: number;
seriesLength: number;
shame: boolean;
stadiumId: ID;
statsheet: ID;
terminology: ID;
topInningScore: number;
topOfInning: boolean;
tournament: number;
weather: number;

hash: string;
Expand All @@ -71,17 +91,21 @@ export class Game extends Entry {
this.defineStrings([
'id',
'awayBatter',
'awayBatterMod',
'awayBatterName',
'awayPitcher',
'awayPitcherMod',
'awayPitcherName',
'awayTeam',
'awayTeamColor',
'awayTeamName',
'awayTeamNickname',
'awayTeamSecondaryColor',
'homeBatter',
'homeBatterMod',
'homeBatterName',
'homePitcher',
'homePitcherMod',
'homePitcherName',
'homeTeam',
'homeTeamColor',
Expand All @@ -90,6 +114,9 @@ export class Game extends Entry {
'homeTeamSecondaryColor',
'lastUpdate',
'rules',
'scoreLedger',
'scoreUpdate',
'stadiumId',
'statsheet',
'terminology',
]);
Expand All @@ -104,6 +131,8 @@ export class Game extends Entry {
'awayStrikes',
'awayTeamBatterCount',
'baserunnerCount',
'bottomInningScore',
'gameStartPhase',
'halfInningOuts',
'halfInningScore',
'homeBalls',
Expand All @@ -113,11 +142,14 @@ export class Game extends Entry {
'homeScore',
'homeStrikes',
'homeTeamBatterCount',
'newInningPhase',
'phase',
'playCount',
'repeatCount',
'seriesIndex',
'seriesLength',
'topInningScore',
'tournament',
'weather',
]);
this.defineIncrementedNumbers([
Expand All @@ -130,6 +162,7 @@ export class Game extends Entry {
'gameComplete',
'gameStart',
'isPostseason',
'isTitleMatch',
'shame',
'topOfInning',
]);
Expand All @@ -156,6 +189,7 @@ export class Game extends Entry {
'inning',
'gameComplete',
'gameStart',
'scoreUpdate',
'topOfInning',
];
}
Expand Down Expand Up @@ -218,6 +252,9 @@ export class Game extends Entry {
return this.homeBatting ? this.homeBatterName : this.awayBatterName;
}

public get baseRunnerMods(): string[] {
return this.data?.baseRunnerMods || [];
}
public get baseRunnerNames(): string[] {
return this.data?.baseRunnerNames || [];
}
Expand Down Expand Up @@ -315,4 +352,17 @@ export class Game extends Entry {
&& this.atBatStrikes === strikes - 1
&& this.baserunnerCount === bases - 1;
}

public get updateText(): string {
let ret = '';

if (this.lastUpdate) {
ret += this.lastUpdate.trim();
}
if (this.scoreUpdate) {
ret += this.scoreUpdate.trim();
}

return ret;
}
}

0 comments on commit 6976733

Please sign in to comment.