Check for a game over after each score.
In case the home team just came from behind in the bottom of the final inning.
This commit is contained in:
parent
aa72d2a19f
commit
687bf74979
16
src/main.lua
16
src/main.lua
|
@ -241,8 +241,7 @@ function Game:pitcherIsReady()
|
|||
)
|
||||
end
|
||||
|
||||
function Game:nextHalfInning()
|
||||
pitchTracker:reset()
|
||||
function Game:checkForGameOver()
|
||||
local homeScore, awayScore = utils.totalScores(self.state.stats)
|
||||
local isFinalInning = self.state.inning >= self.settings.finalInning
|
||||
local gameOver = isFinalInning and self.state.battingTeam == "home" and awayScore ~= homeScore
|
||||
|
@ -254,6 +253,15 @@ function Game:nextHalfInning()
|
|||
playdate.timer.new(3000, function()
|
||||
transitionTo(BoxScore.new(self.state.stats))
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Game:nextHalfInning()
|
||||
pitchTracker:reset()
|
||||
if self:checkForGameOver() then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -291,11 +299,9 @@ end
|
|||
|
||||
---@param scoredRunCount number
|
||||
function Game:score(scoredRunCount)
|
||||
-- TODO: end the game when it's the bottom of the ninth the home team is now in the lead.
|
||||
-- outRunners/scoredRunners split
|
||||
self:battingTeamCurrentInning().score = self:battingTeamCurrentInning().score + scoredRunCount
|
||||
|
||||
self.announcer:say("SCORE!")
|
||||
self:checkForGameOver()
|
||||
end
|
||||
|
||||
---@param throwFlyMs number
|
||||
|
|
Loading…
Reference in New Issue