Merge pull request #750 from dscarpac/family-xml

Changed Family Inheritance Helper to XML
This commit is contained in:
dscarpac 2024-07-06 17:27:08 -05:00 committed by GitHub
commit d12efd2500
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 23 deletions

View File

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

View File

@ -88,7 +88,6 @@ function createButtons()
local upgradeSheet = findUpgradeSheet()
if upgradeSheet then
for i = 1, 4 do
log(4)
if upgradeSheet.call("isUpgradeActive", i) then
table.insert(hypothesisList, customizableList[i])
end

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,25 @@ 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()
if clickableResourceCounter then
clickableResourceCounter.call("updateVal", 0)
end
printToColor("Discarded " .. foundTokens .. " resource(s).", playerColor)
printToColor("Discarded " .. foundTokens .. " resource(s).", player.color)
end
-- hide buttons
function shutOff()
self.UI.hide("Helper")
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>