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 additional convenience properties for game metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Oct 12, 2020
1 parent 2a290d2 commit 4a64d39
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/lib/model/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Game extends Entry {
awayTeamEmoji: string;
awayTeamName: string;
awayTeamNickname: string;
baseRunnerCount: number;
baserunnerCount: number;
day: number;
finalized: boolean;
gameComplete: boolean;
Expand Down Expand Up @@ -93,7 +93,7 @@ export class Game extends Entry {
'awayScore',
'awayStrikes',
'awayTeamBatterCount',
'baseRunnerCount',
'baserunnerCount',
'halfInningOuts',
'halfInningScore',
'homeBases',
Expand Down Expand Up @@ -127,7 +127,7 @@ export class Game extends Entry {
'atBatBalls',
'atBatStrikes',
'awayScore',
'baseRunnerCount',
'baserunnerCount',
'halfInningOuts',
'halfInningScore',
'homeScore',
Expand Down Expand Up @@ -161,6 +161,30 @@ export class Game extends Entry {
}
}

public get bases() {
return this.homeBatting ? this.homeBases : this.awayBases;
}

public get strikes() {
return this.homeBatting ? this.homeStrikes : this.awayStrikes;
}

public get pitcherId() {
return this.homeBatting ? this.awayPitcher : this.homePitcher;
}

public get pitcherName() {
return this.homeBatting ? this.awayPitcherName : this.homePitcherName;
}

public get batterId() {
return this.homeBatting ? this.homeBatter : this.awayBatter;
}

public get batterName() {
return this.homeBatting ? this.homeBatterName : this.awayBatterName;
}

public get baseRunnerNames(): string[] {
return this.data?.baseRunnerNames || [];
}
Expand Down

0 comments on commit 4a64d39

Please sign in to comment.