Merge pull request #809 from argonui/game-keys
Remove closest uses first
This commit is contained in:
commit
5febee03c5
@ -47,8 +47,6 @@ do
|
|||||||
--- investigatorCode String. ID of the investigator in this deck
|
--- investigatorCode String. ID of the investigator in this deck
|
||||||
--- customizations table The decoded table of customization upgrades in this deck
|
--- customizations table The decoded table of customization upgrades in this deck
|
||||||
--- playerColor String. Color this deck is being loaded for
|
--- playerColor String. Color this deck is being loaded for
|
||||||
---@return boolean
|
|
||||||
---@return string
|
|
||||||
ArkhamDb.getDecklist = function(
|
ArkhamDb.getDecklist = function(
|
||||||
playerColor,
|
playerColor,
|
||||||
deckId,
|
deckId,
|
||||||
|
@ -275,14 +275,18 @@ function removeOneUse(playerColor, hoveredObject)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- index the found tokens by memo (only the first of each type)
|
-- index the found tokens by memo (store the token closest to the card for each memo)
|
||||||
|
local cardPos = hoveredObject.getPosition()
|
||||||
local indexByMemo = {}
|
local indexByMemo = {}
|
||||||
|
local distanceByMemo = {}
|
||||||
for _, obj in ipairs(searchResult) do
|
for _, obj in ipairs(searchResult) do
|
||||||
if not obj.locked then
|
if not obj.locked then
|
||||||
if obj.memo and indexByMemo[obj.memo] == nil then
|
local objPos = obj.getPosition()
|
||||||
indexByMemo[obj.memo] = obj
|
local distance = Vector.between(cardPos, objPos):magnitude()
|
||||||
elseif indexByMemo["NO_MEMO"] == nil then
|
local memo = obj.memo or "NO_MEMO"
|
||||||
indexByMemo["NO_MEMO"] = obj
|
if distanceByMemo[memo] == nil or distanceByMemo[memo] > distance then
|
||||||
|
indexByMemo[memo] = obj
|
||||||
|
distanceByMemo[memo] = distance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ do
|
|||||||
---@param owner? tts__Object Object that owns the XML (or nil if Global)
|
---@param owner? tts__Object Object that owns the XML (or nil if Global)
|
||||||
---@return boolean visible Returns the new state of the visibility
|
---@return boolean visible Returns the new state of the visibility
|
||||||
function GlobalApi.changeWindowVisibility(playerColor, windowId, overrideState, owner)
|
function GlobalApi.changeWindowVisibility(playerColor, windowId, overrideState, owner)
|
||||||
Global.call("changeWindowVisibilityForColorWrapper", {
|
return Global.call("changeWindowVisibilityForColorWrapper", {
|
||||||
color = playerColor,
|
color = playerColor,
|
||||||
windowId = windowId,
|
windowId = windowId,
|
||||||
overrideState = overrideState,
|
overrideState = overrideState,
|
||||||
|
@ -14,7 +14,7 @@ do
|
|||||||
---@param card tts__Object Card to check for data
|
---@param card tts__Object Card to check for data
|
||||||
---@return boolean: True if this card has data in the helper, false otherwise
|
---@return boolean: True if this card has data in the helper, false otherwise
|
||||||
function TokenManagerApi.hasLocationData(card)
|
function TokenManagerApi.hasLocationData(card)
|
||||||
Global.call("callTable", {
|
return Global.call("callTable", {
|
||||||
{ "TokenManager", "hasLocationData" },
|
{ "TokenManager", "hasLocationData" },
|
||||||
card
|
card
|
||||||
})
|
})
|
||||||
|
@ -51,7 +51,7 @@ As a nice reminder the XML button takes on the Frost color and icon with the tex
|
|||||||
> require...
|
> require...
|
||||||
----------------------------------------------------------]]
|
----------------------------------------------------------]]
|
||||||
|
|
||||||
local chaosBagApi = require("chaosBag/ChaosBagApi")
|
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||||
|
|
||||||
-- intentionally global
|
-- intentionally global
|
||||||
hasXML = true
|
hasXML = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user