From 3f9770a61a407bff2bd04e293f213ca2edb5fe34 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 4 Aug 2024 00:11:44 +0200 Subject: [PATCH] added new function for hand visibility --- src/core/GameKeyHandler.ttslua | 6 +++--- src/core/Global.ttslua | 1 + src/core/GlobalApi.ttslua | 13 +++++++++++++ src/playermat/Playermat.ttslua | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 77d5516f..b83e64ad 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -106,7 +106,7 @@ function takeCardIntoThreatArea(playerColor, hoveredObject) -- contruct feedback message local cardName = hoveredObject.getName() if cardName == "" then cardName = "a card" end - local playerName = Global.call("getColoredName", playerColor) + local playerName = GlobalApi.getColoredName(playerColor) broadcastToAll("Moved " .. cardName .. " to " .. playerName .. "'s threat area.", "White") -- get new rotation (rounded) @@ -379,7 +379,7 @@ function removeOneUse(playerColor, hoveredObject) end -- construct feedback message - local playerName = Global.call("getColoredName", playerColor) + local playerName = GlobalApi.getColoredName(playerColor) local cardInfo = "" if cardName and cardName ~= "" then cardInfo = " from " .. cardName @@ -530,7 +530,7 @@ function takeClueFromLocation(playerColor, hoveredObject) end -- construct feedback message - local playerName = Global.call("getColoredName", playerColor) + local playerName = GlobalApi.getColoredName(playerColor) local cardInfo = "" if cardName and cardName ~= "" then cardInfo = " from " .. cardName diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 7c6cea35..3ae1dce4 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2503,6 +2503,7 @@ function isTableEmpty(tbl) end -- returns the colored steam name or color +---@param playerColor string Color of the player function getColoredName(playerColor) local displayName = playerColor if Player[playerColor].steam_name then diff --git a/src/core/GlobalApi.ttslua b/src/core/GlobalApi.ttslua index d19235d0..22dbee5d 100644 --- a/src/core/GlobalApi.ttslua +++ b/src/core/GlobalApi.ttslua @@ -40,6 +40,19 @@ do Global.call("updateGlobalXml", newXml) end + -- returns the colored steam name or color + ---@param playerColor string Color of the player + function GlobalApi.getColoredName(playerColor) + return Global.call("getColoredName", playerColor) + end + + -- toggles the hand visibility of a hand for a specific player + ---@param playerColor string Color of the player that needs the visibility toggled + ---@param handColor string Color of the hand to toggle the visibility for + function GlobalApi.handVisibilityToggle(playerColor, handColor) + Global.call("handVisibilityToggle", { playerColor = playerColor, handColor = handColor}) + end + -- loads saved options ---@param options table Set a new state for the option table function GlobalApi.loadOptionPanelSettings(options) diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 4685b52f..d2244c63 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -624,7 +624,7 @@ function doDiscardOne() local cardId = choices[num] .. "/" .. #hand deckLib.placeOrMergeIntoDeck(card, returnGlobalDiscardPosition(), self.getRotation()) - local playerName = Global.call("getColoredName", playerColor) + local playerName = GlobalApi.getColoredName(playerColor) broadcastToAll(playerName .. " randomly discarded " .. cardName " (" .. cardId .. ").", "White") end end @@ -979,7 +979,7 @@ function onClick_visibilitySelect(player) return end - Global.call("handVisibilityToggle", { playerColor = player.color, handColor = playerColor }) + GlobalApi.handVisibilityToggle(player.color, playerColor) end -- changes the UI state and the internal variable for the togglebuttons