some bugfixes

This commit is contained in:
Chr1Z93 2024-09-30 12:46:53 +02:00
parent 076ce45b9f
commit dccf5daacc
4 changed files with 53 additions and 34 deletions

View File

@ -2472,25 +2472,17 @@ end
-- generates the data to spawn an infinite bag of a specific type of resources
function TokenManager.getDataForInfiniteBag(tokenType)
TokenManager.initTokenTemplates()
local tokenTemplate = tokenTemplates["resource"]
local subTypeData
local subTypeStateId
for stateId, objData in pairs(tokenTemplate["States"]) do
if tokenType == objData["Memo"] then
subTypeStateId = stateId
subTypeData = objData
break
end
end
local template = deepCopy(tokenTemplates["resource"])
local subTypeStateId = stateTable[tokenType]
local subTypeData = template["States"][subTypeStateId]
-- add states to data
subTypeData["States"] = tokenTemplate["States"]
subTypeData["States"] = template["States"]
-- add "1" state and remove the current state
subTypeData["States"]["1"] = tokenTemplate
subTypeData["States"]["1"]["States"] = nil
subTypeData["States"][tostring(subTypeStateId)] = nil
subTypeData["States"][1] = template
subTypeData["States"][1]["States"] = nil
subTypeData["States"][subTypeStateId] = nil
return subTypeData
--local spawnData = {}
@ -2565,3 +2557,17 @@ function getColoredName(playerColor)
-- add bb-code
return "[" .. Color.fromString(playerColor):toHex() .. "]" .. displayName .. "[-]"
end
-- creates a deep copy of a table
function deepCopy(data)
if type(data) ~= "table" then return data end
local copiedList = {}
for key, value in pairs(data) do
if type(value) == "table" then
copiedList[key] = deepCopy(value)
else
copiedList[key] = value
end
end
return copiedList
end

View File

@ -89,19 +89,14 @@ do
function TokenManagerApi.maybeReplenishCard(card, uses)
Global.call("callTable", {
{ "TokenManager", "maybeReplenishCard" },
{
card = card,
uses = uses
}
{ card = card, uses = uses }
})
end
function TokenManagerApi.getDataForInfiniteBag(tokenType)
Global.call("callTable", {
return Global.call("callTable", {
{ "TokenManager", "getDataForInfiniteBag" },
{
tokenType = tokenType
}
tokenType
})
end

View File

@ -272,9 +272,15 @@ function round(num, numDecimalPlaces)
end
-- updates the internal "messageColor" which is used for print/broadcast statements if no player is seated
---@param clickedByColor string Colorstring of player who clicked a button
---@param clickedByColor? string Colorstring of player who clicked a button
function updateMessageColor(clickedByColor)
messageColor = Player[playerColor].seated and playerColor or clickedByColor
if Player[playerColor].seated then
messageColor = playerColor
elseif clickedByColor and Player[clickedByColor].seated then
messageColor = clickedByColor
else
messageColor = Player.getPlayers()[1].color
end
end
---------------------------------------------------------
@ -1340,6 +1346,8 @@ end
-- does something for specific investigators when they are loaded
function newInvestigatorCallback(newId)
updateMessageColor()
-- remove existing object that was placed for a specific investigator
local obj = guidReferenceApi.getObjectByOwnerAndType(playerColor, "InvestigatorSpecifics")
if obj ~= nil then
@ -1350,13 +1358,17 @@ function newInvestigatorCallback(newId)
if newId == "01005-p" or newId == "01005-pf" then
-- parallel Wendy Adams
printToColor(
"There's a Game Key for parallel Wendy to add sealing options to any card:" ..
"Wendy Adams: There's a Game Key to add sealing options to any card:" ..
" Top menu bar > Options > Game Keys", messageColor)
elseif newId == "06003" then
-- Tony Morgan
local spawnedObj = spawnObjectData({ data = getDataForInfiniteBag("bounty") })
local spawnedObj = spawnObjectData({
data = getDataForInfiniteBag("bounty"),
position = zones.getZonePosition(playerColor, "SetAside7"),
rotation = self.getRotation()
})
guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID())
printToColor("We've spawned an infinite bag of bounty tokens for convenience near your playermat.", messageColor)
printToColor("Tony Morgan: Spawned an infinite bag of bounty tokens near your playermat.", messageColor)
elseif newId == "08004" then
-- Norman Withers
printToColor(
@ -1364,9 +1376,13 @@ function newInvestigatorCallback(newId)
"and then the mod should keep it flipped throughout the game.", messageColor)
elseif newId == "09015" then
-- Darrell Simmons
local spawnedObj = spawnObjectData({ data = getDataForInfiniteBag("evidence") })
local spawnedObj = spawnObjectData({
data = getDataForInfiniteBag("evidence"),
position = zones.getZonePosition(playerColor, "SetAside7"),
rotation = self.getRotation()
})
guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID())
printToColor("We've spawned an infinite bag of evidence tokens for convenience near your playermat.", messageColor)
printToColor("Darrell Simons: Spawned an infinite bag of evidence tokens near your playermat.", messageColor)
elseif newId == "89001" then
-- Subject 5U-21
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos", "OptionPanelSource")
@ -1382,13 +1398,15 @@ function newInvestigatorCallback(newId)
break
end
end
printToColor("We've spawned a helper to track the classes of devoured cards near your playermat. " ..
"Note that this and 'Ravenous' will work with the Attachment Helper from the option panel.", messageColor)
printToColor("Subject 5U-21: Spawned a helper to track the classes of devoured cards near your playermat. " ..
"Note that this and 'Ravenous' will work with the Attachment Helper from the option panel.", messageColor)
end
end
function getDataForInfiniteBag(tokenType)
local tokenData = tokenManagerApi.getDataForInfiniteBag(tokenType)
log(tokenData)
return tokenData
end
-- returns the mini ID for the currently placed investigator

View File

@ -80,7 +80,7 @@ do
zoneData["White"]["SetAside5"] = { 2.78, 0, 0.042 }
zoneData["White"]["SetAside6"] = { 2.78, 0, 0.605 }
zoneData["White"]["UnderSetAside6"] = { 2.93, 0, 0.805 }
zoneData["White"]["SetAside7"] = { 3.21, 0, 0.705 }
zoneData["White"]["SetAside7"] = { 2.85, 0, 1.650 }
zoneData["Orange"] = {}
zoneData["Orange"]["Investigator"] = commonZones["Investigator"]
@ -113,7 +113,7 @@ do
zoneData["Orange"]["SetAside5"] = { -2.78, 0, 0.042 }
zoneData["Orange"]["SetAside6"] = { -2.78, 0, 0.605 }
zoneData["Orange"]["UnderSetAside6"] = { -2.93, 0, 0.805 }
zoneData["Orange"]["SetAside7"] = { -3.21, 0, 0.705 }
zoneData["Orange"]["SetAside7"] = { -2.85, 0, 1.650 }
-- Green positions are the same as White and Red the same as Orange
zoneData["Red"] = zoneData["Orange"]