added helper

This commit is contained in:
dscarpac 2024-07-06 13:16:13 -05:00
parent 123f6b7e42
commit 6a9c274f48
3 changed files with 69 additions and 22 deletions

View File

@ -58,5 +58,5 @@
"scaleZ": 1
},
"Value": 0,
"XmlUI": ""
"XmlUI": "\u003cInclude src=\"playercards/FamilyInheritance.xml\"/\u003e"
}

View File

@ -1,26 +1,23 @@
require("playercards/CardsWithHelper")
local playermatApi = require("playermat/PlayermatApi")
local searchLib = require("util/SearchLib")
local tokenManager = require("core/token/TokenManager")
local isHelperEnabled = false
local clickableResourceCounter = nil
local foundTokens = 0
function updateSave()
self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled })
end
function onLoad()
self.addContextMenuItem("Add 4 resources",
function(playerColor)
Player[playerColor].clearSelectedObjects()
add4(playerColor)
end)
self.addContextMenuItem("Take all resources",
function(playerColor)
Player[playerColor].clearSelectedObjects()
takeAll(playerColor)
end)
self.addContextMenuItem("Discard all resources",
function(playerColor)
Player[playerColor].clearSelectedObjects()
loseAll(playerColor)
end)
self.addTag("CardWithHelper")
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
isHelperEnabled = loadedData.isHelperEnabled
end
checkOptionPanel()
end
function searchSelf()
@ -40,7 +37,7 @@ function searchSelf()
end
end
function add4(playerColor)
function add4()
searchSelf()
local newCount = foundTokens + 4
@ -51,7 +48,7 @@ function add4(playerColor)
end
end
function takeAll(playerColor)
function takeAll(player)
searchSelf()
local matColor = playermatApi.getMatColorByPosition(self.getPosition())
playermatApi.updateCounter(matColor, "ResourceCounter", _, foundTokens)
@ -59,14 +56,27 @@ function takeAll(playerColor)
if clickableResourceCounter then
clickableResourceCounter.call("updateVal", 0)
end
printToColor("Moved " .. foundTokens .. " resource(s) to " .. matColor .. "'s resource pool.", playerColor)
printToColor("Moved " .. foundTokens .. " resource(s) to " .. matColor .. "'s resource pool.", player.color)
end
function loseAll(playerColor)
function loseAll(player)
searchSelf()
log(player.color)
if clickableResourceCounter then
clickableResourceCounter.call("updateVal", 0)
end
printToColor("Discarded " .. foundTokens .. " resource(s).", playerColor)
printToColor("Discarded " .. foundTokens .. " resource(s).", player.color)
end
-- hide buttons and stop monitoring
function shutOff()
self.UI.hide("Helper")
Wait.stopAll()
updateSave()
end
-- show buttons
function initialize()
self.UI.show("Helper")
updateSave()
end

View File

@ -0,0 +1,37 @@
<Defaults>
<Button padding="30 30 30 30"
font="font_teutonic-arkham"
textColor = "white"
fontSize="235"
shadow="#405041B3"
shadowDistance="-15 15"/>
<TableLayout position="130 0 -22"
rotation="0 0 270"
height="460"
width="2600"
scale="0.1 0.1 1"
cellSpacing="80"
cellBackgroundColor="rgba(1,1,1,0)"/>
</Defaults>
<TableLayout id="Helper"
active="false">
<Row>
<Cell>
<Button onClick="loseAll"
color = "#6D202C"
fontSize = "195"
text="Discard all"/>
</Cell>
<Cell>
<Button onClick="takeAll"
color = "#173B0B"
text="Move all"/>
</Cell>
<Cell>
<Button onClick="add4"
color = "#77674D"
text="Place 4"/>
</Cell>
</Row>
</TableLayout>