Skip to content

Commit

Permalink
Fix play-by-play
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Apr 15, 2024
1 parent ed13037 commit ade2a3b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
3 changes: 0 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ allow undoing a trade
shootouts
- hockey
- need football/baseball scoringSummary style - build up from events?
- flavor?
- separate attempt from result
- fix play-by-play text
- scoring summary
- isScoringPlay -> formatScoringSummaryEvent
- confirm for all sports
Expand Down
4 changes: 3 additions & 1 deletion src/ui/util/processLiveGameEvents.hockey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ const getText = (
);
} else if (event.type === "shootoutStart") {
text = `The game will now be decided by a shootout with ${event.rounds} rounds!`;
} else if (event.type === "shootoutTeam") {
text = `${event.names[0]} takes the puck`;
} else if (event.type === "shootoutShot") {
text = `Kick ${event.att}: ${event.made ? `Shot by ${event.names[0]} - saved by ${event.names[1]}` : `Shot by ${event.names[0]}`}`;
text = event.made ? "" : `Saved by ${event.names[0]}`;
} else if (event.type === "shootoutTie") {
text = `The shootout is tied! Teams will alternate penalty shots until there is a winner`;
}
Expand Down
9 changes: 7 additions & 2 deletions src/worker/core/GameSim.hockey/PlayByPlayLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ type PlayByPlayEventInputScore =
type: "shootoutShot";
clock: number;
t: TeamNum;
names: [string, string];
names: [string];
made: boolean;
att: number;
goalType: "pn";
shotType: string;
};
Expand Down Expand Up @@ -106,6 +105,12 @@ type PlayByPlayEventInput =
rounds: number;
clock: number;
}
| {
type: "shootoutTeam";
t: TeamNum;
names: [string];
clock: number;
}
| {
type: "shootoutTie";
clock: number;
Expand Down
17 changes: 12 additions & 5 deletions src/worker/core/GameSim.hockey/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,23 @@ class GameSim extends GameSimBase {
}

doShootoutShot(t: TeamNum, p: PlayerGameSim, goalie: PlayerGameSim) {
// 20% to 80%
const skaterProb = 0.2 + 0.6 * p.compositeRating.scoring;
const goalieProb = 0.8 - 0.6 * goalie.compositeRating.goalkeeping;
// 50% to 100%
const skaterProb = 0.5 + 0.5 * p.compositeRating.scoring;
const goalieProb = 1 - 0.5 * goalie.compositeRating.goalkeeping;

const probMake = skaterProb * goalieProb;

const made = Math.random() < probMake;

this.recordStat(t, undefined, "sAtt");

this.playByPlay.logEvent({
type: "shootoutTeam",
clock: this.clock,
t,
names: [p.name],
});

if (made) {
this.recordStat(t, undefined, "sPts");
}
Expand All @@ -492,8 +500,7 @@ class GameSim extends GameSimBase {
type: "shootoutShot",
clock: this.clock,
t,
names: [p.name, goalie.name],
att: this.team[t].stat.sAtt,
names: [goalie.name],
made,
goalType: "pn",
shotType: "penalty",
Expand Down

0 comments on commit ade2a3b

Please sign in to comment.