Merge branch 'argonui:main' into kohaku
This commit is contained in:
commit
9eae42212a
@ -7,5 +7,12 @@
|
||||
"level": 0,
|
||||
"traits": "Item. Illicit.",
|
||||
"intellectIcons": 1,
|
||||
"uses": [
|
||||
{
|
||||
"count": 0,
|
||||
"type": "Suspicion",
|
||||
"token": "resource"
|
||||
}
|
||||
],
|
||||
"cycle": "The Feast of Hemlock Vale"
|
||||
}
|
||||
|
@ -8,5 +8,12 @@
|
||||
"traits": "Item. Illicit.",
|
||||
"intellectIcons": 1,
|
||||
"agilityIcons": 1,
|
||||
"uses": [
|
||||
{
|
||||
"count": 0,
|
||||
"type": "Suspicion",
|
||||
"token": "resource"
|
||||
}
|
||||
],
|
||||
"cycle": "The Feast of Hemlock Vale"
|
||||
}
|
||||
|
@ -211,8 +211,11 @@ do
|
||||
if tokenType == "clue" then
|
||||
offsets = internal.buildClueOffsets(card, tokenCount)
|
||||
else
|
||||
-- only up to 12 offset tables defined
|
||||
if tokenCount > 12 then return end
|
||||
-- only up to 12 offset tables defined (TODO: stack more than 12 tokens and generate offsets dynamically)
|
||||
if tokenCount > 12 then
|
||||
printToAll("Spawning maximum of 12 tokens.")
|
||||
tokenCount = 12
|
||||
end
|
||||
for i = 1, tokenCount do
|
||||
offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])
|
||||
-- Fix the y-position for the spawn, since positionToWorld considers rotation which can
|
||||
@ -302,8 +305,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some
|
||||
-- callers.
|
||||
-- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some callers
|
||||
---@param card tts__Object Card object to reset the tokens for
|
||||
TokenManager.resetTokensSpawned = function(card)
|
||||
tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())
|
||||
@ -483,11 +485,6 @@ do
|
||||
---@param uses table The already decoded metadata.uses (to avoid decoding again)
|
||||
---@param mat tts__Object The playermat the card is placed on (for rotation and casting)
|
||||
internal.replenishTokens = function(card, uses, mat)
|
||||
local cardPos = card.getPosition()
|
||||
|
||||
-- don't continue for cards on the deck (Norman) or in the discard pile
|
||||
if mat.positionToLocal(cardPos).x < -1 then return end
|
||||
|
||||
-- get current amount of resource tokens on the card
|
||||
local clickableResourceCounter = nil
|
||||
local foundTokens = 0
|
||||
@ -511,7 +508,7 @@ do
|
||||
-- if there are already more uses than the replenish amount, keep them
|
||||
if foundTokens > uses[1].count then
|
||||
newCount = foundTokens
|
||||
-- only replenish up until the replenish amount
|
||||
-- only replenish up until the replenish amount
|
||||
elseif newCount > uses[1].count then
|
||||
newCount = uses[1].count
|
||||
end
|
||||
|
@ -343,8 +343,8 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
forcedLearning = true
|
||||
end
|
||||
|
||||
-- maybe replenish uses on certain cards
|
||||
if cardMetadata.uses ~= nil then
|
||||
-- maybe replenish uses on certain cards (don't continue for cards on the deck (Norman) or in the discard pile)
|
||||
if cardMetadata.uses ~= nil and self.positionToLocal(obj.getPosition()).x < -1 then
|
||||
tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)
|
||||
end
|
||||
elseif obj.type == "Deck" and forcedLearning == false then
|
||||
|
@ -60,6 +60,7 @@ do
|
||||
|
||||
-- searches below the specified position (downwards until y = 0)
|
||||
SearchLib.belowPosition = function(pos, filter)
|
||||
size = { 0.1, 2, 0.1 }
|
||||
direction = { 0, -1, 0 }
|
||||
maxDistance = pos.y
|
||||
return returnSearchResult(pos, _, size, filter, direction, maxDistance)
|
||||
|
@ -1,3 +1,4 @@
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local playermatApi = require("playermat/PlayermatApi")
|
||||
local searchLib = require("util/SearchLib")
|
||||
local tokenManager = require("core/token/TokenManager")
|
||||
@ -12,17 +13,6 @@ TOKEN_INDEX[7] = "doom"
|
||||
TOKEN_INDEX[8] = "clue"
|
||||
TOKEN_INDEX[9] = "resource"
|
||||
|
||||
local stateTable = {
|
||||
["resource"] = 1,
|
||||
["ammo"] = 2,
|
||||
["bounty"] = 3,
|
||||
["charge"] = 4,
|
||||
["evidence"] = 5,
|
||||
["secret"] = 6,
|
||||
["supply"] = 7,
|
||||
["offering"] = 8
|
||||
}
|
||||
|
||||
---@param index number Index of the pressed key
|
||||
---@param playerColor string Color of the triggering player
|
||||
function onScriptingButtonDown(index, playerColor)
|
||||
@ -31,29 +21,36 @@ function onScriptingButtonDown(index, playerColor)
|
||||
|
||||
local rotation = { x = 0, y = Player[playerColor].getPointerRotation(), z = 0 }
|
||||
local position = Player[playerColor].getPointerPosition() + Vector(0, 0.2, 0)
|
||||
local subType = ""
|
||||
local callback = nil
|
||||
|
||||
-- check for subtype of resource based on card below
|
||||
if tokenType == "resource" then
|
||||
for _, obj in ipairs(searchLib.belowPosition(position, "isCard")) do
|
||||
if not obj.is_face_down then
|
||||
local metadata = JSON.decode(obj.getGMNotes()) or {}
|
||||
local uses = metadata.uses or {}
|
||||
for _, useInfo in ipairs(uses) do
|
||||
if useInfo.token == "resource" then
|
||||
subType = useInfo.type
|
||||
break
|
||||
end
|
||||
end
|
||||
local card
|
||||
local hoverObj = Player[playerColor].getHoverObject()
|
||||
if hoverObj and hoverObj.type == "Card" then
|
||||
card = hoverObj
|
||||
elseif hoverObj then
|
||||
-- use the first card below the hovered object if it's not a card1
|
||||
for _, obj in ipairs(searchLib.belowPosition(position, "isCard")) do
|
||||
card = obj
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
||||
local stateID = stateTable[string.lower(subType)]
|
||||
if stateID ~= nil and stateID ~= 1 then
|
||||
callback = function(spawned) spawned.setState(stateID) end
|
||||
-- get the metadata from the card and maybe replenish a use
|
||||
if card and not card.is_face_down then
|
||||
local metadata = JSON.decode(card.getGMNotes()) or {}
|
||||
local uses = metadata.uses or {}
|
||||
for _, useInfo in ipairs(uses) do
|
||||
if useInfo.token == "resource" then
|
||||
-- artifically create replenish data to re-use that existing functionality
|
||||
uses[1].count = 999
|
||||
uses[1].replenish = 1
|
||||
local matColor = playermatApi.getMatColorByPosition(position)
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
||||
tokenManager.maybeReplenishCard(card, uses, mat)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
-- check hovered object for "resourceCounter" tokens and increase them instead
|
||||
elseif tokenType == "resourceCounter" then
|
||||
|
Loading…
Reference in New Issue
Block a user