Decrease BaseHitbox to fix tag-outs

Rename tryToThrowOut() to tryToMakeOut()
This commit is contained in:
Sage Vaillancourt 2025-02-04 14:27:58 -05:00
parent 9df836e0bf
commit 841b7e3fea
1 changed files with 9 additions and 7 deletions

View File

@ -281,7 +281,7 @@ local elapsedSec = 0
local crankChange = 0 local crankChange = 0
local acceleratedChange local acceleratedChange
local BaseHitbox = 13 local BaseHitbox = 10
--- Returns the base being touched by the runner at (x,y), or nil, if no base is being touched --- Returns the base being touched by the runner at (x,y), or nil, if no base is being touched
function isTouchingBase(x, y) function isTouchingBase(x, y)
for _, base in ipairs(Bases) do for _, base in ipairs(Bases) do
@ -410,9 +410,10 @@ function getBaseOfStrandedRunner()
return farRunnersBase, farDistance return farRunnersBase, farDistance
end end
--- Returns x,y of the throw target
--- Returns x,y of the out target
---@return number|nil, number|nil ---@return number|nil, number|nil
function getNextThrowTarget() function getNextOutTarget()
-- TODO: Handle missed throws, check for fielders at target, etc. -- TODO: Handle missed throws, check for fielders at target, etc.
local targets = getForcedOutTargets() local targets = getForcedOutTargets()
if #targets ~= 0 then if #targets ~= 0 then
@ -420,13 +421,14 @@ function getNextThrowTarget()
end end
local baseCloseToStrandedRunner = getBaseOfStrandedRunner() local baseCloseToStrandedRunner = getBaseOfStrandedRunner()
-- TODO: If another fielder is closer, throw it to them, instead
if baseCloseToStrandedRunner then if baseCloseToStrandedRunner then
return baseCloseToStrandedRunner.x, baseCloseToStrandedRunner.y return baseCloseToStrandedRunner.x, baseCloseToStrandedRunner.y
end end
end end
function tryToThrowOut(thrower) function tryToMakeAnOut(thrower)
local targetX, targetY = getNextThrowTarget() local targetX, targetY = getNextOutTarget()
if targetX ~= nil and targetY ~= nil then if targetX ~= nil and targetY ~= nil then
local nearestFielder = getNearestOf(fielders, targetX, targetY) local nearestFielder = getNearestOf(fielders, targetX, targetY)
nearestFielder.target = xy(targetX, targetY) nearestFielder.target = xy(targetX, targetY)
@ -476,10 +478,10 @@ function updateFielders()
then then
outRunner(i) outRunner(i)
playdate.timer.new(750, function() playdate.timer.new(750, function()
tryToThrowOut(fielder) tryToMakeAnOut(fielder)
end) end)
else else
tryToThrowOut(fielder) tryToMakeAnOut(fielder)
end end
end end
end end