Skip to content

Commit

Permalink
Made token attaching more restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
Chr1Z93 committed Jan 9, 2025
1 parent dc5433d commit 3a8c974
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/core/Global.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,18 @@ function handleTokenAttaching(params)
local player = params.player
local searchResult = searchLib.onObject(card, "isTileOrToken", 0.9)

if card.is_face_down and next(searchResult) ~= nil then
local cardPos = card.getPosition()
local eligibleTokens = {}
for _, token in ipairs(searchResult) do
if not token.locked and token.getPosition().y > (cardPos.y + 0.025) then
table.insert(eligibleTokens, token)
end
end

if #eligibleTokens == 0 then return end

-- maybe change settings (and save them to restore later)
if card.is_face_down then
cardSettings[card] = {
hideFacedown = card.hide_when_face_down,
tooltip = card.tooltip
Expand All @@ -2922,10 +2933,8 @@ function handleTokenAttaching(params)
card.tooltip = false
end

for _, token in ipairs(searchResult) do
if not token.locked then
card.addAttachment(token)
end
for _, token in ipairs(eligibleTokens) do
card.addAttachment(token)
end

Wait.condition(
Expand Down

0 comments on commit 3a8c974

Please sign in to comment.