Merge pull request #220 from argonui/handhelper
Hand Helper: code updates
This commit is contained in:
commit
b435eb0fcc
@ -22,7 +22,7 @@
|
|||||||
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1704036721123215146/E44A3B99EACF310E49E94977151A03C9A3DC7F17/",
|
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1704036721123215146/E44A3B99EACF310E49E94977151A03C9A3DC7F17/",
|
||||||
"WidthScale": 0
|
"WidthScale": 0
|
||||||
},
|
},
|
||||||
"Description": "- Displays the hand size (total or by title for \"Dream Enhancing Serum\"), hover over it to briefly toggle counting method\n\n- Adds a context menu to \"Short Supply\" for the 1st turn\n\n- Allows you to randomly discard a card from your hand\n\nSee context menu for additional information.",
|
"Description": "Displays the hand size (total or by title for \"Dream Enhancing Serum\"), hover over it to briefly toggle counting method.\n\nAllows you to randomly discard a card from your hand.",
|
||||||
"DragSelectable": true,
|
"DragSelectable": true,
|
||||||
"GMNotes": "",
|
"GMNotes": "",
|
||||||
"GUID": "450688",
|
"GUID": "450688",
|
||||||
@ -34,7 +34,7 @@
|
|||||||
"LayoutGroupSortIndex": 0,
|
"LayoutGroupSortIndex": 0,
|
||||||
"Locked": false,
|
"Locked": false,
|
||||||
"LuaScript": "require(\"accessories/HandHelper\")",
|
"LuaScript": "require(\"accessories/HandHelper\")",
|
||||||
"LuaScriptState": "[\"Green\",false]",
|
"LuaScriptState": "",
|
||||||
"MeasureMovement": false,
|
"MeasureMovement": false,
|
||||||
"Name": "Custom_Tile",
|
"Name": "Custom_Tile",
|
||||||
"Nickname": "Hand Helper",
|
"Nickname": "Hand Helper",
|
||||||
|
@ -1,194 +1,114 @@
|
|||||||
local playmatAPI = require("playermat/PlaymatApi")
|
local playmatAPI = require("playermat/PlaymatApi")
|
||||||
|
local matColor, handColor, loopId, hovering
|
||||||
|
|
||||||
local buttonParamaters = {}
|
function onLoad()
|
||||||
buttonParamaters.function_owner = self
|
local buttonParamaters = {}
|
||||||
|
buttonParamaters.function_owner = self
|
||||||
|
|
||||||
-- saving "playerColor" and "des"
|
-- index 0: button as hand size label
|
||||||
function onSave() return JSON.encode({ playerColor, des}) end
|
buttonParamaters.hover_color = "White"
|
||||||
|
buttonParamaters.click_function = "none"
|
||||||
|
buttonParamaters.position = { 0, 0.11, -0.4 }
|
||||||
|
buttonParamaters.height = 0
|
||||||
|
buttonParamaters.width = 0
|
||||||
|
buttonParamaters.font_size = 500
|
||||||
|
buttonParamaters.font_color = "White"
|
||||||
|
self.createButton(buttonParamaters)
|
||||||
|
|
||||||
function onLoad(saved_data)
|
-- index 1: button to toggle "des"
|
||||||
-- loading saved data
|
buttonParamaters.label = "DES: ✗"
|
||||||
local loaded_data = JSON.decode(saved_data)
|
buttonParamaters.click_function = "none"
|
||||||
playerColor = loaded_data[1] or Player.getAvailableColors()[1]
|
buttonParamaters.position = { 0, 0.11, 0.25 }
|
||||||
des = loaded_data[2] or false
|
buttonParamaters.height = 0
|
||||||
|
buttonParamaters.width = 0
|
||||||
|
buttonParamaters.font_size = 120
|
||||||
|
self.createButton(buttonParamaters)
|
||||||
|
|
||||||
-- index 0: button as hand size label
|
-- index 2: button to discard a card
|
||||||
buttonParamaters.hover_color = "White"
|
buttonParamaters.label = "discard random card"
|
||||||
buttonParamaters.click_function = "none"
|
buttonParamaters.click_function = "discardRandom"
|
||||||
buttonParamaters.position = { 0, 0.11, -0.4 }
|
buttonParamaters.position = { 0, 0.11, 0.7 }
|
||||||
buttonParamaters.height = 0
|
buttonParamaters.height = 175
|
||||||
buttonParamaters.width = 0
|
buttonParamaters.width = 900
|
||||||
buttonParamaters.font_size = 500
|
buttonParamaters.font_size = 90
|
||||||
buttonParamaters.font_color = "White"
|
buttonParamaters.font_color = "Black"
|
||||||
self.createButton(buttonParamaters)
|
self.createButton(buttonParamaters)
|
||||||
|
|
||||||
-- index 1: button to toggle "des"
|
updateColors()
|
||||||
buttonParamaters.label = "DES: " .. (des and "✓" or "✗")
|
|
||||||
buttonParamaters.click_function = "toggleDES"
|
|
||||||
buttonParamaters.position = { 0.475, 0.11, 0.25 }
|
|
||||||
buttonParamaters.height = 175
|
|
||||||
buttonParamaters.width = 440
|
|
||||||
buttonParamaters.font_size = 90
|
|
||||||
buttonParamaters.font_color = "Black"
|
|
||||||
self.createButton(buttonParamaters)
|
|
||||||
|
|
||||||
-- index 2: button to discard a card
|
-- start loop to update card count
|
||||||
buttonParamaters.label = "discard random card"
|
loopId = Wait.time(updateValue, 1, -1)
|
||||||
buttonParamaters.click_function = "discardRandom"
|
|
||||||
buttonParamaters.position = { 0, 0.11, 0.7 }
|
|
||||||
buttonParamaters.width = 900
|
|
||||||
self.createButton(buttonParamaters)
|
|
||||||
|
|
||||||
-- index 3: button to select color
|
|
||||||
buttonParamaters.label = playerColor
|
|
||||||
buttonParamaters.color = playerColor
|
|
||||||
buttonParamaters.hover_color = playerColor
|
|
||||||
buttonParamaters.click_function = "changeColor"
|
|
||||||
buttonParamaters.tooltip = "change color"
|
|
||||||
buttonParamaters.position = { -0.475, 0.11, 0.25 }
|
|
||||||
buttonParamaters.width = 440
|
|
||||||
self.createButton(buttonParamaters)
|
|
||||||
|
|
||||||
-- start loop to update card count
|
|
||||||
loopId = Wait.time(||updateValue(), 1, -1)
|
|
||||||
|
|
||||||
-- context menu to quickly bind color
|
|
||||||
self.addContextMenuItem("Bind to my color", function(color)
|
|
||||||
changeColor(_, _, _, color)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- context menu to display additional information
|
|
||||||
self.addContextMenuItem("More Information", function()
|
|
||||||
printToAll("------------------------------", "White")
|
|
||||||
printToAll("Hand Helper by Chr1Z", "Orange")
|
|
||||||
printToAll("original by Tikatoy", "White")
|
|
||||||
printToAll("Note: 'Hidden' cards can't be randomly discarded.", "Yellow")
|
|
||||||
printToAll("Set them aside beforehand!", "Yellow")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- initialize the pseudo random number generator
|
|
||||||
math.randomseed(os.time())
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- updates colors when object is dropped somewhere
|
||||||
|
function onDrop() updateColors() end
|
||||||
|
|
||||||
|
-- toggles counting method briefly
|
||||||
function onObjectHover(hover_color, obj)
|
function onObjectHover(hover_color, obj)
|
||||||
-- only continue if correct player hovers over "self"
|
-- only continue if correct player hovers over "self"
|
||||||
if obj ~= self or hover_color ~= playerColor then return end
|
if obj ~= self or hover_color ~= handColor or hovering then return end
|
||||||
|
|
||||||
-- stop loop, toggle "des" and displayed value briefly, then start new loop
|
-- toggle this flag so this doesn't get executed multiple times during the delay
|
||||||
Wait.stop(loopId)
|
hovering = true
|
||||||
des = not des
|
|
||||||
updateValue()
|
-- stop loop, toggle "des" and displayed value briefly, then start new loop after 2s
|
||||||
des = not des
|
Wait.stop(loopId)
|
||||||
loopId = Wait.time(||updateValue(), 1, -1)
|
updateValue(true)
|
||||||
|
Wait.time(function()
|
||||||
|
loopId = Wait.time(updateValue, 1, -1)
|
||||||
|
hovering = false
|
||||||
|
end, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- toggle "des" and update button label
|
-- updates the matcolor and handcolor variable
|
||||||
function toggleDES()
|
function updateColors()
|
||||||
des = not des
|
matColor = playmatAPI.getMatColorByPosition(self.getPosition())
|
||||||
self.editButton({index = 1, label = "DES: " .. (des and "✓" or "✗")})
|
handColor = playmatAPI.getHandColor(matColor)
|
||||||
updateValue()
|
self.setName(handColor .. " Hand Helper")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- count cards in hand (by name for DES)
|
-- count cards in hand (by name for DES)
|
||||||
function updateValue()
|
function updateValue(toggle)
|
||||||
if not playerExists(playerColor) then return end
|
-- update colors if handColor doesn't own a handzone
|
||||||
|
if Player[handColor].getHandCount() == 0 then
|
||||||
|
updateColors()
|
||||||
|
end
|
||||||
|
|
||||||
local hand = Player[playerColor].getHandObjects()
|
-- if there is still no handzone, then end here
|
||||||
local size = 0
|
if Player[handColor].getHandCount() == 0 then return end
|
||||||
|
|
||||||
if des then
|
-- get state of "Dream-Enhancing Serum" from playermat and update button label
|
||||||
local cardHash = {}
|
local des = playmatAPI.isDES(matColor)
|
||||||
for _, obj in pairs(hand) do
|
if toggle then des = not des end
|
||||||
if obj.tag == "Card" then
|
self.editButton({ index = 1, label = "DES: " .. (des and "✓" or "✗") })
|
||||||
local name = obj.getName()
|
|
||||||
local title = string.match(name, '(.+)(%s%(%d+%))') or name
|
-- count cards in hand
|
||||||
cardHash[title] = obj
|
local hand = Player[handColor].getHandObjects()
|
||||||
end
|
local size = 0
|
||||||
end
|
|
||||||
for _, obj in pairs(cardHash) do
|
if des then
|
||||||
size = size + 1
|
local cardHash = {}
|
||||||
end
|
for _, obj in pairs(hand) do
|
||||||
else
|
if obj.tag == "Card" then
|
||||||
for _, obj in pairs(hand) do
|
local name = obj.getName()
|
||||||
if obj.tag == "Card" then size = size + 1 end
|
local title = string.match(name, '(.+)(%s%(%d+%))') or name
|
||||||
end
|
cardHash[title] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- change button label and color
|
for _, title in pairs(cardHash) do
|
||||||
self.editButton({index = 0, font_color = des and "Green" or "White", label = size})
|
size = size + 1
|
||||||
end
|
|
||||||
|
|
||||||
-- allows change of color via external call
|
|
||||||
function externalColorChange(newColor)
|
|
||||||
changeColor(_, _, _, newColor)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get index of current color and move up one step (or down for right-click)
|
|
||||||
function changeColor(_, _, isRightClick, color)
|
|
||||||
if color then
|
|
||||||
playerColor = color
|
|
||||||
else
|
|
||||||
local COLORS = Player.getAvailableColors()
|
|
||||||
local pos = indexOf(COLORS, playerColor)
|
|
||||||
|
|
||||||
if isRightClick then
|
|
||||||
if pos == nil or pos == 1 then pos = #COLORS
|
|
||||||
else pos = pos - 1 end
|
|
||||||
else
|
|
||||||
if pos == nil or pos == #COLORS then pos = 1
|
|
||||||
else pos = pos + 1 end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- update playerColor
|
|
||||||
playerColor = COLORS[pos]
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
for _, obj in pairs(hand) do
|
||||||
|
if obj.tag == "Card" then size = size + 1 end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- update "change color" button (note: remove and create instantly updates hover_color)
|
-- update button label and color
|
||||||
buttonParamaters.label = playerColor
|
self.editButton({ index = 0, font_color = des and "Green" or "White", label = size })
|
||||||
buttonParamaters.color = playerColor
|
|
||||||
buttonParamaters.hover_color = playerColor
|
|
||||||
self.removeButton(3)
|
|
||||||
self.createButton(buttonParamaters)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
-- discards a random non-hidden card from hand
|
||||||
-- discards a random card from hand
|
|
||||||
---------------------------------------------------------
|
|
||||||
|
|
||||||
function discardRandom()
|
function discardRandom()
|
||||||
if not playerExists(playerColor) then return end
|
playmatAPI.doDiscardOne(matColor)
|
||||||
|
|
||||||
-- error handling: hand is empty
|
|
||||||
local hand = Player[playerColor].getHandObjects()
|
|
||||||
if #hand == 0 then
|
|
||||||
broadcastToAll("Cannot discard from empty hand!", "Red")
|
|
||||||
else
|
|
||||||
local searchPos = Player[playerColor].getHandTransform().position
|
|
||||||
|
|
||||||
local discardPos = playmatAPI.getDiscardPosition(playmatAPI.getMatColorByPosition(searchPos))
|
|
||||||
if discardPos == nil then
|
|
||||||
broadcastToAll("Couldn't retrieve discard position from playermat!", "Red")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local num = math.random(1, #hand)
|
|
||||||
hand[num].setPosition(discardPos)
|
|
||||||
broadcastToAll(playerColor .. " randomly discarded card " .. num .. "/" .. #hand .. ".", "White")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---------------------------------------------------------
|
|
||||||
-- helper functions
|
|
||||||
---------------------------------------------------------
|
|
||||||
|
|
||||||
-- helper to search array
|
|
||||||
function indexOf(array, value)
|
|
||||||
for i, v in ipairs(array) do
|
|
||||||
if v == value then return i end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- helper to check if player exists
|
|
||||||
function playerExists(color)
|
|
||||||
local COLORS = Player.getAvailableColors()
|
|
||||||
return indexOf(COLORS, color) and true or false
|
|
||||||
end
|
end
|
||||||
|
@ -856,10 +856,10 @@ function applyOptionPanelChange(id, state)
|
|||||||
|
|
||||||
-- option: Show hand helper for each player
|
-- option: Show hand helper for each player
|
||||||
elseif id == "showHandHelper" then
|
elseif id == "showHandHelper" then
|
||||||
optionPanel[id][1] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, 7.32}, {0, 270, 0}, "White")
|
optionPanel[id][1] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, 7.32}, {0, 270, 0})
|
||||||
optionPanel[id][2] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, -24.88}, {0, 270, 0}, "Orange")
|
optionPanel[id][2] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, -24.88}, {0, 270, 0})
|
||||||
optionPanel[id][3] = spawnOrRemoveHelper(state, "Hand Helper", {-39.13, 1.6, 22.45}, {0, 000, 0}, "Green")
|
optionPanel[id][3] = spawnOrRemoveHelper(state, "Hand Helper", {-39.13, 1.6, 22.45}, {0, 000, 0})
|
||||||
optionPanel[id][4] = spawnOrRemoveHelper(state, "Hand Helper", {-21.57, 1.6, -22.45}, {0, 180, 0}, "Red")
|
optionPanel[id][4] = spawnOrRemoveHelper(state, "Hand Helper", {-21.57, 1.6, -22.45}, {0, 180, 0})
|
||||||
|
|
||||||
-- option: Show search assistant for each player
|
-- option: Show search assistant for each player
|
||||||
elseif id == "showSearchAssistant" then
|
elseif id == "showSearchAssistant" then
|
||||||
@ -899,12 +899,11 @@ end
|
|||||||
---@param name String Name of the helper object
|
---@param name String Name of the helper object
|
||||||
---@param position Vector Position of the object (where it will spawn)
|
---@param position Vector Position of the object (where it will spawn)
|
||||||
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
|
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
|
||||||
---@param color String This is only needed for correctly setting the color of the "Hand Helper"
|
|
||||||
---@return. GUID of the spawnedObj (or nil if object was removed)
|
---@return. GUID of the spawnedObj (or nil if object was removed)
|
||||||
function spawnOrRemoveHelper(state, name, position, rotation, color)
|
function spawnOrRemoveHelper(state, name, position, rotation)
|
||||||
if state then
|
if state then
|
||||||
Player.getPlayers()[1].pingTable(position)
|
Player.getPlayers()[1].pingTable(position)
|
||||||
return spawnHelperObject(name, position, rotation, color).getGUID()
|
return spawnHelperObject(name, position, rotation).getGUID()
|
||||||
else
|
else
|
||||||
return removeHelperObject(name)
|
return removeHelperObject(name)
|
||||||
end
|
end
|
||||||
@ -913,7 +912,7 @@ end
|
|||||||
-- copies the specified tool (by name) from the barrel
|
-- copies the specified tool (by name) from the barrel
|
||||||
---@param name String Name of the object that should be copied
|
---@param name String Name of the object that should be copied
|
||||||
---@param position Table Desired position of the object
|
---@param position Table Desired position of the object
|
||||||
function spawnHelperObject(name, position, rotation, color)
|
function spawnHelperObject(name, position, rotation)
|
||||||
local barrel = getObjectFromGUID(BARREL_GUID)
|
local barrel = getObjectFromGUID(BARREL_GUID)
|
||||||
|
|
||||||
-- error handling for missing barrel
|
-- error handling for missing barrel
|
||||||
@ -925,9 +924,7 @@ function spawnHelperObject(name, position, rotation, color)
|
|||||||
local spawnTable = {
|
local spawnTable = {
|
||||||
position = position,
|
position = position,
|
||||||
callback_function = function(object)
|
callback_function = function(object)
|
||||||
if name == "Hand Helper" then
|
if name == "Token Arranger" then
|
||||||
Wait.time(function() object.call("externalColorChange", color) end, 0.1)
|
|
||||||
elseif name == "Token Arranger" then
|
|
||||||
Wait.time(function() object.call("layout") end, 0.1)
|
Wait.time(function() object.call("layout") end, 0.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ local tokenChecker = require("core/token/TokenChecker")
|
|||||||
local DEBUG = false
|
local DEBUG = false
|
||||||
|
|
||||||
-- we use this to turn off collision handling until onLoad() is complete
|
-- we use this to turn off collision handling until onLoad() is complete
|
||||||
local COLLISION_ENABLED = false
|
local collisionEnabled = false
|
||||||
|
|
||||||
-- position offsets relative to mat [x, y, z]
|
-- position offsets relative to mat [x, y, z]
|
||||||
local DRAWN_ENCOUNTER_CARD_OFFSET = {1.365, 0.5, -0.635}
|
local DRAWN_ENCOUNTER_CARD_OFFSET = {1.365, 0.5, -0.635}
|
||||||
@ -62,6 +62,9 @@ local RESOURCE_COUNTER
|
|||||||
activeInvestigatorId = "00000"
|
activeInvestigatorId = "00000"
|
||||||
local isDrawButtonVisible = false
|
local isDrawButtonVisible = false
|
||||||
|
|
||||||
|
-- global variable to report "Dream-Enhancing Serum" status
|
||||||
|
isDES = false
|
||||||
|
|
||||||
function onSave()
|
function onSave()
|
||||||
return JSON.encode({
|
return JSON.encode({
|
||||||
zoneID = zoneID,
|
zoneID = zoneID,
|
||||||
@ -122,7 +125,9 @@ function onLoad(save_state)
|
|||||||
showDrawButton(isDrawButtonVisible)
|
showDrawButton(isDrawButtonVisible)
|
||||||
|
|
||||||
if getObjectFromGUID(zoneID) == nil then spawnDeckZone() end
|
if getObjectFromGUID(zoneID) == nil then spawnDeckZone() end
|
||||||
COLLISION_ENABLED = true
|
collisionEnabled = true
|
||||||
|
|
||||||
|
math.randomseed(os.time())
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -409,6 +414,51 @@ function shuffleDiscardIntoDeck()
|
|||||||
discardPile = nil
|
discardPile = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- discard a random non-hidden card from hand
|
||||||
|
function doDiscardOne()
|
||||||
|
local handColor = getHandColor()
|
||||||
|
local hand = Player[handColor].getHandObjects()
|
||||||
|
if #hand == 0 then
|
||||||
|
broadcastToAll("Cannot discard from empty hand!", "Red")
|
||||||
|
else
|
||||||
|
local choices = {}
|
||||||
|
for i = 1, #hand do
|
||||||
|
local notes = JSON.decode(hand[i].getGMNotes())
|
||||||
|
if notes ~= nil then
|
||||||
|
if notes.hidden ~= true then
|
||||||
|
table.insert(choices, i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(choices, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #choices == 0 then
|
||||||
|
broadcastToAll("Hidden cards can't be randomly discarded.", "Orange")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- get a random non-hidden card (from the "choices" table)
|
||||||
|
local num = math.random(1, #choices)
|
||||||
|
hand[choices[num]].setPosition(returnGlobalDiscardPosition())
|
||||||
|
broadcastToAll(handColor .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- gets the hand color of the closest seated player (by roughly cutting the table into quarters)
|
||||||
|
function getHandColor()
|
||||||
|
for _, handColor in ipairs(Player.getAvailableColors()) do
|
||||||
|
local handPosition = Player[handColor].getHandTransform().position
|
||||||
|
|
||||||
|
if (PLAYER_COLOR == "White" and handPosition.x < -42 and handPosition.z > 0)
|
||||||
|
or (PLAYER_COLOR == "Orange" and handPosition.x < -42 and handPosition.z < 0)
|
||||||
|
or (PLAYER_COLOR == "Green" and handPosition.x > -42 and handPosition.z > 0)
|
||||||
|
or (PLAYER_COLOR == "Red" and handPosition.x > -42 and handPosition.z < 0) then
|
||||||
|
return handColor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- playmat token spawning
|
-- playmat token spawning
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -493,9 +543,14 @@ function spawnTokensFor(object)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onCollisionEnter(collision_info)
|
function onCollisionEnter(collision_info)
|
||||||
if not COLLISION_ENABLED then return end
|
|
||||||
local object = collision_info.collision_object
|
local object = collision_info.collision_object
|
||||||
|
|
||||||
|
-- detect if "Dream-Enhancing Serum" is placed
|
||||||
|
if object.getName() == "Dream-Enhancing Serum" then isDES = true end
|
||||||
|
|
||||||
|
-- only continue if loading is completed
|
||||||
|
if not collisionEnabled then return end
|
||||||
|
|
||||||
-- only continue for cards
|
-- only continue for cards
|
||||||
if object.name ~= "Card" and object.name ~= "CardCustom" then return end
|
if object.name ~= "Card" and object.name ~= "CardCustom" then return end
|
||||||
|
|
||||||
@ -509,6 +564,11 @@ function onCollisionEnter(collision_info)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- detect if "Dream-Enhancing Serum" is removed
|
||||||
|
function onCollisionExit(collision_info)
|
||||||
|
if collision_info.collision_object.getName() == "Dream-Enhancing Serum" then isDES = false end
|
||||||
|
end
|
||||||
|
|
||||||
function shouldSpawnTokens(card)
|
function shouldSpawnTokens(card)
|
||||||
if card.is_face_down then
|
if card.is_face_down then
|
||||||
return false
|
return false
|
||||||
|
@ -41,6 +41,20 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns the color of the player's hand that is seated next to the playermat
|
||||||
|
---@param matColor String Color of the playermat
|
||||||
|
PlaymatApi.getHandColor = function(matColor)
|
||||||
|
local mat = getObjectFromGUID(MAT_IDS[matColor])
|
||||||
|
return mat.call("getHandColor")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns if there is the card"Dream-Enhancing Serum" on the requested playermat
|
||||||
|
---@param matColor String Color of the playermat
|
||||||
|
PlaymatApi.isDES = function(matColor)
|
||||||
|
local mat = getObjectFromGUID(MAT_IDS[matColor])
|
||||||
|
return mat.getVar("isDES")
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns the draw deck of the requested playmat
|
-- Returns the draw deck of the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playermat
|
||||||
PlaymatApi.getDrawDeck = function(matColor)
|
PlaymatApi.getDrawDeck = function(matColor)
|
||||||
@ -116,6 +130,13 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Discard a non-hidden card from the corresponding player's hand
|
||||||
|
PlaymatApi.doDiscardOne = function(matColor)
|
||||||
|
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
||||||
|
mat.call("doDiscardOne")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
||||||
-- accepts "All" as a special value which will return all four mats.
|
-- accepts "All" as a special value which will return all four mats.
|
||||||
|
Loading…
Reference in New Issue
Block a user