added helper
This commit is contained in:
parent
123f6b7e42
commit
6a9c274f48
@ -58,5 +58,5 @@
|
|||||||
"scaleZ": 1
|
"scaleZ": 1
|
||||||
},
|
},
|
||||||
"Value": 0,
|
"Value": 0,
|
||||||
"XmlUI": ""
|
"XmlUI": "\u003cInclude src=\"playercards/FamilyInheritance.xml\"/\u003e"
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,23 @@
|
|||||||
|
require("playercards/CardsWithHelper")
|
||||||
local playermatApi = require("playermat/PlayermatApi")
|
local playermatApi = require("playermat/PlayermatApi")
|
||||||
local searchLib = require("util/SearchLib")
|
local searchLib = require("util/SearchLib")
|
||||||
local tokenManager = require("core/token/TokenManager")
|
local tokenManager = require("core/token/TokenManager")
|
||||||
|
|
||||||
|
local isHelperEnabled = false
|
||||||
local clickableResourceCounter = nil
|
local clickableResourceCounter = nil
|
||||||
local foundTokens = 0
|
local foundTokens = 0
|
||||||
|
|
||||||
|
function updateSave()
|
||||||
|
self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled })
|
||||||
|
end
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
self.addContextMenuItem("Add 4 resources",
|
self.addTag("CardWithHelper")
|
||||||
function(playerColor)
|
if savedData and savedData ~= "" then
|
||||||
Player[playerColor].clearSelectedObjects()
|
local loadedData = JSON.decode(savedData)
|
||||||
add4(playerColor)
|
isHelperEnabled = loadedData.isHelperEnabled
|
||||||
end)
|
end
|
||||||
self.addContextMenuItem("Take all resources",
|
checkOptionPanel()
|
||||||
function(playerColor)
|
|
||||||
Player[playerColor].clearSelectedObjects()
|
|
||||||
takeAll(playerColor)
|
|
||||||
end)
|
|
||||||
self.addContextMenuItem("Discard all resources",
|
|
||||||
function(playerColor)
|
|
||||||
Player[playerColor].clearSelectedObjects()
|
|
||||||
loseAll(playerColor)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function searchSelf()
|
function searchSelf()
|
||||||
@ -40,7 +37,7 @@ function searchSelf()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function add4(playerColor)
|
function add4()
|
||||||
searchSelf()
|
searchSelf()
|
||||||
|
|
||||||
local newCount = foundTokens + 4
|
local newCount = foundTokens + 4
|
||||||
@ -51,7 +48,7 @@ function add4(playerColor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function takeAll(playerColor)
|
function takeAll(player)
|
||||||
searchSelf()
|
searchSelf()
|
||||||
local matColor = playermatApi.getMatColorByPosition(self.getPosition())
|
local matColor = playermatApi.getMatColorByPosition(self.getPosition())
|
||||||
playermatApi.updateCounter(matColor, "ResourceCounter", _, foundTokens)
|
playermatApi.updateCounter(matColor, "ResourceCounter", _, foundTokens)
|
||||||
@ -59,14 +56,27 @@ function takeAll(playerColor)
|
|||||||
if clickableResourceCounter then
|
if clickableResourceCounter then
|
||||||
clickableResourceCounter.call("updateVal", 0)
|
clickableResourceCounter.call("updateVal", 0)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function loseAll(playerColor)
|
function loseAll(player)
|
||||||
searchSelf()
|
searchSelf()
|
||||||
|
log(player.color)
|
||||||
if clickableResourceCounter then
|
if clickableResourceCounter then
|
||||||
clickableResourceCounter.call("updateVal", 0)
|
clickableResourceCounter.call("updateVal", 0)
|
||||||
end
|
end
|
||||||
printToColor("Discarded " .. foundTokens .. " resource(s).", playerColor)
|
printToColor("Discarded " .. foundTokens .. " resource(s).", player.color)
|
||||||
end
|
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
|
37
xml/playercards/FamilyInheritance.xml
Normal file
37
xml/playercards/FamilyInheritance.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user