Merge pull request #813 from argonui/searching-on-cards
Adjusted searching on cards to a smaller area
This commit is contained in:
commit
1d99f0af12
@ -268,7 +268,8 @@ function removeOneUse(playerColor, hoveredObject)
|
||||
if hoveredObject.type == "Tile" then
|
||||
targetObject = hoveredObject
|
||||
elseif hoveredObject.type == "Card" then
|
||||
local searchResult = searchLib.onObject(hoveredObject, "isTileOrToken")
|
||||
-- we're only searching 80% of the cards area to avoid matching tokens on other cards
|
||||
local searchResult = searchLib.onObject(hoveredObject, "isTileOrToken", 0.8)
|
||||
|
||||
if #searchResult == 0 then
|
||||
broadcastToColor("No tokens found!", playerColor, "Yellow")
|
||||
|
@ -2407,6 +2407,8 @@ function TokenManager.replenishTokens(card, useInfo)
|
||||
local clickableResourceCounter = nil
|
||||
local foundTokens = 0
|
||||
|
||||
-- we're only searching 80% of the cards area to avoid matching tokens on other cards
|
||||
-- (except for clues, since these are on locations and they should never be this close)
|
||||
local maybeDeleteThese = {}
|
||||
if useInfo.token == "clue" then
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isClue")) do
|
||||
@ -2414,7 +2416,7 @@ function TokenManager.replenishTokens(card, useInfo)
|
||||
table.insert(maybeDeleteThese, obj)
|
||||
end
|
||||
elseif useInfo.token == "doom" then
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isDoom")) do
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isDoom", 0.8)) do
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
table.insert(maybeDeleteThese, obj)
|
||||
end
|
||||
@ -2425,7 +2427,7 @@ function TokenManager.replenishTokens(card, useInfo)
|
||||
searchType = useInfo.token
|
||||
end
|
||||
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isTileOrToken")) do
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isTileOrToken", 0.8)) do
|
||||
local memo = obj.getMemo()
|
||||
if searchType == memo then
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
|
@ -42,25 +42,26 @@ do
|
||||
end
|
||||
|
||||
-- searches the specified area
|
||||
SearchLib.inArea = function(pos, rot, size, filter)
|
||||
function SearchLib.inArea(pos, rot, size, filter)
|
||||
return returnSearchResult(pos, rot, size, filter)
|
||||
end
|
||||
|
||||
-- searches the area on an object
|
||||
SearchLib.onObject = function(obj, filter)
|
||||
function SearchLib.onObject(obj, filter, scale)
|
||||
scale = scale or 1
|
||||
local pos = obj.getPosition()
|
||||
local size = obj.getBounds().size:setAt("y", 1)
|
||||
local size = obj.getBounds().size:scale(scale):setAt("y", 1)
|
||||
return returnSearchResult(pos, _, size, filter)
|
||||
end
|
||||
|
||||
-- searches the specified position (a single point)
|
||||
SearchLib.atPosition = function(pos, filter)
|
||||
function SearchLib.atPosition(pos, filter)
|
||||
local size = { 0.1, 2, 0.1 }
|
||||
return returnSearchResult(pos, _, size, filter)
|
||||
end
|
||||
|
||||
-- searches below the specified position (downwards until y = 0)
|
||||
SearchLib.belowPosition = function(pos, filter)
|
||||
function SearchLib.belowPosition(pos, filter)
|
||||
local size = { 0.1, 2, 0.1 }
|
||||
local direction = { 0, -1, 0 }
|
||||
local maxDistance = pos.y
|
||||
|
Loading…
Reference in New Issue
Block a user