Skip to content

Commit

Permalink
Updated Chef's Selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Chr1Z93 committed Dec 4, 2024
1 parent 03ba6cd commit 1ab71a1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 35 deletions.
52 changes: 33 additions & 19 deletions src/core/Global.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -2184,24 +2184,37 @@ end

-- Spawns a set of tokens on the given card.
function TokenManager.spawnTokenGroup(params)
local card = params.card
local tokenType = params.tokenType
local card = params.card
local tokenType = params.tokenType
local tokenCount = params.tokenCount
local shiftDown = params.shiftDown
local subType = params.subType
local temporary = params.temporary
local replenish = params.replenish
local shiftDown = params.shiftDown
local subType = params.subType
local temporary = params.temporary

if tokenType == "damage" or tokenType == "horror" then
TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)
elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "enabled" then
TokenManager.spawnResourceCounterToken(card, tokenCount)
elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "custom" and tokenCount == 0 then
elseif shouldSpawnResourceCounter(tokenType, tokenCount, replenish) then
TokenManager.spawnResourceCounterToken(card, tokenCount)
else
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType, temporary)
end
end

function shouldSpawnResourceCounter(tokenType, tokenCount, replenish)
if tokenType == "resource" then
if optionPanel["useResourceCounters"] == "enabled" then
return true
elseif optionPanel["useResourceCounters"] == "custom" then
-- spawn a resource counter for cards with "0 uses" or small amount of replenshing tokens
if tokenCount == 0 or (replenish and tokenCount < 3) then
return true
end
end
end
return false
end

-- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.
---@param card tts__Object Card to spawn tokens on
---@param tokenType string Type of token to spawn (template needs to be in source bag)
Expand Down Expand Up @@ -2434,11 +2447,12 @@ function TokenManager.spawnTokensFromUses(card, extraUses)
end
-- Shift each spawned group after the first down so they don't pile on each other
TokenManager.spawnTokenGroup({
card = card,
tokenType = useInfo.token,
card = card,
tokenType = useInfo.token,
tokenCount = tokenCount,
shiftDown = (i - 1) * 0.8,
subType = useInfo.type
replenish = useInfo.replenish,
shiftDown = (i - 1) * 0.8,
subType = useInfo.type
})
end

Expand Down Expand Up @@ -2466,8 +2480,8 @@ end
-- the right data for this card.
function TokenManager.spawnPlayerCardTokensFromDataHelper(card, playerData)
TokenManager.spawnTokenGroup({
card = card,
tokenType = playerData.tokenType,
card = card,
tokenType = playerData.tokenType,
tokenCount = playerData.tokenCount
})
tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())
Expand All @@ -2481,8 +2495,8 @@ function TokenManager.spawnLocationTokensFromDataHelper(card, locationData)
local clueCount = TokenManager.getClueCountFromData(card, locationData)
if clueCount > 0 then
TokenManager.spawnTokenGroup({
card = card,
tokenType = "clue",
card = card,
tokenType = "clue",
tokenCount = clueCount
})
tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())
Expand Down Expand Up @@ -2627,10 +2641,10 @@ function TokenManager.replenishTokens(card, useInfo)

-- spawn new token group
TokenManager.spawnTokenGroup({
card = card,
tokenType = useInfo.token,
card = card,
tokenType = useInfo.token,
tokenCount = newCount,
subType = useInfo.type
subType = useInfo.type
})
end
end
Expand Down
29 changes: 13 additions & 16 deletions src/tokens/TokenManagerApi.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ do
Global.call("callTable", {
{ "TokenManager", "spawnToken" },
{
position = position,
rotation = rotation,
tokenType = tokenType,
callbackName = callbackName,
position = position,
rotation = rotation,
tokenType = tokenType,
callbackName = callbackName,
callbackParams = callbackParams,
scriptstate = scriptstate
scriptstate = scriptstate
}
})
end
Expand All @@ -77,12 +77,12 @@ do
Global.call("callTable", {
{ "TokenManager", "spawnTokenGroup" },
{
card = card,
tokenType = tokenType,
card = card,
tokenType = tokenType,
tokenCount = tokenCount,
shiftDown = shiftDown,
subType = subType,
temporary = temporary
shiftDown = shiftDown,
subType = subType,
temporary = temporary
}
})
end
Expand All @@ -103,8 +103,8 @@ do
{ "TokenManager", "getDataForInfiniteBag" },
{
tokenType = tokenType,
position = position,
rotation = rotation
position = position,
rotation = rotation
}
})
end
Expand All @@ -115,10 +115,7 @@ do
function TokenManagerApi.addUseToCard(card, useType)
local result = Global.call("callTable", {
{ "TokenManager", "addUseToCard" },
{
card = card,
useType = useType
}
{ card = card, useType = useType }
})
return result
end
Expand Down

0 comments on commit 1ab71a1

Please sign in to comment.