integer -> number

This commit is contained in:
Sage Vaillancourt 2025-02-17 20:42:44 -05:00
parent e20ad0d3ad
commit c3a9122580
3 changed files with 9 additions and 10 deletions

View File

@ -38,7 +38,7 @@ function Baserunning.new(announcer, onThirdOut)
return o return o
end end
---@param runner integer | Runner ---@param runner number | Runner
---@param message string | nil ---@param message string | nil
---@return boolean wasThirdOut ---@return boolean wasThirdOut
function Baserunning:outRunner(runner, message) function Baserunning:outRunner(runner, message)
@ -152,7 +152,7 @@ function Baserunning:pushNewBatter()
end end
---@param self table ---@param self table
---@param runnerIndex integer ---@param runnerIndex number
function Baserunning:runnerScored(runnerIndex) function Baserunning:runnerScored(runnerIndex)
-- TODO: outRunners/scoredRunners split -- TODO: outRunners/scoredRunners split
self.outRunners[#self.outRunners + 1] = self.runners[runnerIndex] self.outRunners[#self.outRunners + 1] = self.runners[runnerIndex]
@ -161,7 +161,7 @@ end
--- Returns true only if the given runner moved during this update. --- Returns true only if the given runner moved during this update.
---@param runner Runner | nil ---@param runner Runner | nil
---@param runnerIndex integer | nil May only be nil if runner == batter ---@param runnerIndex number | nil May only be nil if runner == batter
---@param appliedSpeed number ---@param appliedSpeed number
---@param deltaSeconds number ---@param deltaSeconds number
---@return boolean runnerMoved, boolean runnerScored ---@return boolean runnerMoved, boolean runnerScored

View File

@ -266,13 +266,12 @@ end
function Game:nextHalfInning() function Game:nextHalfInning()
pitchTracker:reset() pitchTracker:reset()
local homeScore, awayScore = utils.totalScores(self.state.stats) local homeScore, awayScore = utils.totalScores(self.state.stats)
-- TODO end the game if away team just batted and home team is winning local isFinalInning = self.state.inning >= self.settings.finalInning
local gameOver = self.state.battingTeam == "home" local gameOver = isFinalInning and self.state.battingTeam == "home" and awayScore ~= homeScore
and self.state.inning == self.settings.finalInning gameOver = gameOver or self.state.battingTeam == "away" and isFinalInning and homeScore > awayScore
and awayScore ~= homeScore
if gameOver then if gameOver then
self.announcer:say("AND THAT'S THE BALL GAME!") self.announcer:say("THAT'S THE BALL GAME!")
playdate.timer.new(3000, function() playdate.timer.new(3000, function()
transitionTo(BoxScore.new(self.state.stats)) transitionTo(BoxScore.new(self.state.stats))
end) end)

View File

@ -11,7 +11,7 @@ function buildBaserunning()
return baserunning, thirdOutCallbackData return baserunning, thirdOutCallbackData
end end
---@alias BaseIndexOrXyPair (integer | XyPair) ---@alias BaseIndexOrXyPair (number | XyPair)
--- NOTE: in addition to the given runners, there is implicitly a batter running from first. --- NOTE: in addition to the given runners, there is implicitly a batter running from first.
---@param runnerLocations BaseIndexOrXyPair[] ---@param runnerLocations BaseIndexOrXyPair[]
@ -44,7 +44,7 @@ end
---@param expected boolean ---@param expected boolean
---@param fielderWithBallAt XyPair ---@param fielderWithBallAt XyPair
---@param when integer[][] ---@param when number[][]
function assertRunnerOutCondition(expected, when, fielderWithBallAt) function assertRunnerOutCondition(expected, when, fielderWithBallAt)
local msg = expected and "out" or "safe" local msg = expected and "out" or "safe"
for _, runnersOn in ipairs(when) do for _, runnersOn in ipairs(when) do