From f190d3ccea483843afa9c20d6ce85b2dc1c56ec3 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 2 May 2023 22:56:39 +0200 Subject: [PATCH 1/3] fixed multiseal and save/load --- src/chaosbag/BlessCurseManager.ttslua | 2 +- src/playercards/CardsThatSealTokens.ttslua | 43 ++++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/chaosbag/BlessCurseManager.ttslua b/src/chaosbag/BlessCurseManager.ttslua index 7fd52d4c..faf3258a 100644 --- a/src/chaosbag/BlessCurseManager.ttslua +++ b/src/chaosbag/BlessCurseManager.ttslua @@ -85,7 +85,7 @@ function initializeState() -- find tokens in the play area for _, obj in ipairs(getObjects()) do local pos = obj.getPosition() - if pos.x > -50 and pos.x < 50 and pos.z > 8 and pos.z < 50 then + if pos.x > -65 and pos.x < 10 and pos.z > -35 and pos.z < 35 then if obj.getName() == "Bless" then table.insert(tokensTaken.Bless, obj.getGUID()) numInPlay.Bless = numInPlay.Bless + 1 diff --git a/src/playercards/CardsThatSealTokens.ttslua b/src/playercards/CardsThatSealTokens.ttslua index aab8aebb..3c4e9145 100644 --- a/src/playercards/CardsThatSealTokens.ttslua +++ b/src/playercards/CardsThatSealTokens.ttslua @@ -14,7 +14,7 @@ SHOW_SINGLE_RELEASE --@type: boolean SHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once) - enables an entry in the context menu - - this enty allows releasing of multiple tokens at once + - this entry allows releasing of multiple tokens at once - example usage: "Nephthys" (to release 3 bless tokens at once) SHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once) @@ -44,25 +44,23 @@ Example 1: Crystalline Elder Sign This card can only seal the "+1" or "Elder Sign" token, it does not need specific options for multi-sealing or releasing. Thus it should be implemented like this: - -> VALID_TOKENS = { -> ["+1"] = true, -> ["Elder Sign"] = true -> } -> require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling + > VALID_TOKENS = { + > ["+1"] = true, + > ["Elder Sign"] = true + > } + > require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling ---------------------------------------------------------- Example 2: Holy Spear This card features the following abilities (just listing the relevant parts): - releasing a single bless token - sealing two bless tokens Thus it should be implemented like this: - -> VALID_TOKENS = { -> ["Bless"] = true -> } -> SHOW_SINGLE_RELEASE = true -> SHOW_MULTI_SEAL = 2 -> require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling + > VALID_TOKENS = { + > ["Bless"] = true + > } + > SHOW_SINGLE_RELEASE = true + > SHOW_MULTI_SEAL = 2 + > require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling ----------------------------------------------------------]] local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") @@ -169,24 +167,29 @@ function sealToken(name, playerColor) end -- release the last sealed token -function releaseOneToken(playerColor) +function releaseOneToken(playerColor, doPrint) if not Global.call("canTouchChaosTokens") then return end if #sealedTokens == 0 then - printToColor("No sealed token(s) found", playerColor) + if doPrint or doPrint == nil then + printToColor("No sealed token(s) found", playerColor) + end else - printToColor("Releasing token", playerColor) + if doPrint or doPrint == nil then + printToColor("Releasing token", playerColor) + end putTokenAway(table.remove(sealedTokens)) end end -- release multiple tokens at once function releaseMultipleTokens(playerColor) - if SHOW_MULTI_RELEASE >= #sealedTokens then + if SHOW_MULTI_RELEASE <= #sealedTokens then for i = 1, SHOW_MULTI_RELEASE do - releaseOneToken(playerColor) + releaseOneToken(playerColor, false) end + printToColor("Releasing tokens", playerColor) else - printToColor("Not enough " .. name .. " tokens sealed.", playerColor) + printToColor("Not enough tokens sealed.", playerColor) end end From 3aa3ebd0cbda6b49143fd238ba871fbb611846c9 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 7 May 2023 16:22:10 +0200 Subject: [PATCH 2/3] improved code --- src/playercards/CardsThatSealTokens.ttslua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/playercards/CardsThatSealTokens.ttslua b/src/playercards/CardsThatSealTokens.ttslua index 3c4e9145..876cfff7 100644 --- a/src/playercards/CardsThatSealTokens.ttslua +++ b/src/playercards/CardsThatSealTokens.ttslua @@ -48,7 +48,7 @@ Thus it should be implemented like this: > ["+1"] = true, > ["Elder Sign"] = true > } - > require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling + > require... ---------------------------------------------------------- Example 2: Holy Spear This card features the following abilities (just listing the relevant parts): @@ -60,7 +60,8 @@ Thus it should be implemented like this: > } > SHOW_SINGLE_RELEASE = true > SHOW_MULTI_SEAL = 2 - > require ("playercards/CardsThatSealTokens") -- includes a space after "require" to not executing bundling + > require... +----------------------------------------------------------]] ----------------------------------------------------------]] local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") @@ -167,16 +168,12 @@ function sealToken(name, playerColor) end -- release the last sealed token -function releaseOneToken(playerColor, doPrint) +function releaseOneToken(playerColor) if not Global.call("canTouchChaosTokens") then return end if #sealedTokens == 0 then - if doPrint or doPrint == nil then - printToColor("No sealed token(s) found", playerColor) - end + printToColor("No sealed token(s) found", playerColor) else - if doPrint or doPrint == nil then - printToColor("Releasing token", playerColor) - end + printToColor("Releasing token", playerColor) putTokenAway(table.remove(sealedTokens)) end end @@ -185,9 +182,9 @@ end function releaseMultipleTokens(playerColor) if SHOW_MULTI_RELEASE <= #sealedTokens then for i = 1, SHOW_MULTI_RELEASE do - releaseOneToken(playerColor, false) + putTokenAway(table.remove(sealedTokens)) end - printToColor("Releasing tokens", playerColor) + printToColor("Releasing " .. SHOW_MULTI_RELEASE .. " tokens", playerColor) else printToColor("Not enough tokens sealed.", playerColor) end From 7576824b20d2004bfcaa8d919959b09a2be4fb82 Mon Sep 17 00:00:00 2001 From: Chr1Z <97286811+Chr1Z93@users.noreply.github.com> Date: Wed, 10 May 2023 09:43:55 +0200 Subject: [PATCH 3/3] removed additional line --- src/playercards/CardsThatSealTokens.ttslua | 1 - 1 file changed, 1 deletion(-) diff --git a/src/playercards/CardsThatSealTokens.ttslua b/src/playercards/CardsThatSealTokens.ttslua index 876cfff7..0037530e 100644 --- a/src/playercards/CardsThatSealTokens.ttslua +++ b/src/playercards/CardsThatSealTokens.ttslua @@ -62,7 +62,6 @@ Thus it should be implemented like this: > SHOW_MULTI_SEAL = 2 > require... ----------------------------------------------------------]] -----------------------------------------------------------]] local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local tokenArrangerApi = require("accessories/TokenArrangerApi")