diff --git a/src/main.lua b/src/main.lua index e63349e..499dd17 100644 --- a/src/main.lua +++ b/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