Merge pull request #644 from argonui/tekelili
Updated tekelili cards and clean up helper for tekelili helper
This commit is contained in:
commit
fadfd1a567
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/Tekeli-li\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -122,6 +122,7 @@ function cleanUp(_, color)
|
||||
discardHands()
|
||||
chaosBagApi.returnChaosTokens()
|
||||
chaosBagApi.releaseAllSealedTokens(color)
|
||||
maybeIgnoreTekeliliCards()
|
||||
|
||||
printToAll("Tidying main play area...", "White")
|
||||
startLuaCoroutine(self, "tidyPlayareaCoroutine")
|
||||
@ -238,6 +239,18 @@ function discardHands()
|
||||
end
|
||||
end
|
||||
|
||||
-- maybe ignore cards / decks on the tekelili helper
|
||||
function maybeIgnoreTekeliliCards()
|
||||
local tekeliliHelper = getTekeliliHelper()
|
||||
|
||||
if tekeliliHelper then
|
||||
local searchResult = searchLib.onObject(tekeliliHelper, "isCardOrDeck")
|
||||
for _, obj in ipairs(searchResult) do
|
||||
obj.addTag(IGNORE_TAG)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- clean up for play area
|
||||
function tidyPlayareaCoroutine()
|
||||
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
||||
@ -269,6 +282,8 @@ end
|
||||
|
||||
-- clean up for the four playermats and the mythos area
|
||||
function tidyPlayerMatCoroutine()
|
||||
local tekeliliHelper = getTekeliliHelper()
|
||||
|
||||
for i = 1, 5 do
|
||||
-- only continue for playermat (1-4) if option enabled
|
||||
if options["tidyPlayermats"] or i == 5 then
|
||||
@ -282,6 +297,11 @@ function tidyPlayerMatCoroutine()
|
||||
goto continue
|
||||
end
|
||||
|
||||
-- maybe store tekelili cards
|
||||
if tekeliliHelper and i ~= 5 then
|
||||
tekeliliHelper.call("storeTekelili", COLORS[i])
|
||||
end
|
||||
|
||||
local objList
|
||||
if i < 5 then
|
||||
objList = playmatApi.searchAroundPlaymat(COLORS[i])
|
||||
@ -320,10 +340,23 @@ function tidyPlayerMatCoroutine()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- maybe respawn tekelili cards
|
||||
if tekeliliHelper and i ~= 5 then
|
||||
tekeliliHelper.call("spawnStoredTekelili", COLORS[i])
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
-- maybe remove ignore tag from cards / decks on the tekelili helper
|
||||
if tekeliliHelper then
|
||||
local searchResult = searchLib.onObject(tekeliliHelper, "isCardOrDeck")
|
||||
for _, obj in ipairs(searchResult) do
|
||||
obj.removeTag(IGNORE_TAG)
|
||||
end
|
||||
end
|
||||
|
||||
-- reset "activeInvestigatorId"
|
||||
local playerMats = guidReferenceApi.getObjectsByType("Playermat")
|
||||
for _, mat in pairs(playerMats) do
|
||||
@ -340,3 +373,12 @@ function tidyPlayerMatCoroutine()
|
||||
printToAll("Clean up completed!", "Green")
|
||||
return 1
|
||||
end
|
||||
|
||||
-- used to detect the "Tekeli-li Helper" for Edge of the Earth
|
||||
function getTekeliliHelper()
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
if obj.getName() == "Tekeli-li Helper" then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
35
src/playercards/cards/Tekeli-li.ttslua
Normal file
35
src/playercards/cards/Tekeli-li.ttslua
Normal file
@ -0,0 +1,35 @@
|
||||
local deckLib = require("util/DeckLib")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
function onLoad()
|
||||
self.addContextMenuItem("Return this card", returnSelf)
|
||||
self.addContextMenuItem("Place below my deck", placeBelowDeck)
|
||||
end
|
||||
|
||||
-- uses the tekeli-li helper to place this card at the bottom of the deck
|
||||
function returnSelf()
|
||||
local helper = getTekeliliHelper()
|
||||
if helper == nil then
|
||||
printToAll("Couldn't find Tekeli-li Helper!")
|
||||
else
|
||||
helper.call("returnObject", self)
|
||||
end
|
||||
end
|
||||
|
||||
-- places this card below the deck of the player that triggered it
|
||||
function placeBelowDeck(playerColor)
|
||||
local matColor = playmatApi.getMatColor(playerColor)
|
||||
local deckPos = playmatApi.getDrawPosition(matColor)
|
||||
local deckRot = playmatApi.returnRotation(matColor)
|
||||
deckRot = deckRot:setAt("z", 180)
|
||||
deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)
|
||||
end
|
||||
|
||||
-- used to detect the "Tekeli-li Helper" for Edge of the Earth
|
||||
function getTekeliliHelper()
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
if obj.getName() == "Tekeli-li Helper" then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
@ -800,6 +800,10 @@ function returnGlobalDiscardPosition()
|
||||
return self.positionToWorld(DISCARD_PILE_POSITION)
|
||||
end
|
||||
|
||||
function returnGlobalDrawPosition()
|
||||
return self.positionToWorld(DRAW_DECK_POSITION)
|
||||
end
|
||||
|
||||
-- Sets this playermat's draw 1 button to visible
|
||||
---@param visible boolean Whether the draw 1 button should be visible
|
||||
function showDrawButton(visible)
|
||||
|
@ -79,6 +79,14 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns the position of the draw pile of the requested playmat
|
||||
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||
PlaymatApi.getDrawPosition = function(matColor)
|
||||
for _, mat in pairs(getMatForColor(matColor)) do
|
||||
return mat.call("returnGlobalDrawPosition")
|
||||
end
|
||||
end
|
||||
|
||||
-- Transforms a local position into a global position
|
||||
---@param localPos table Local position to be transformed
|
||||
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||
|
@ -5,21 +5,25 @@ do
|
||||
-- places a card/deck at a position or merges into an existing deck
|
||||
---@param obj tts__Object Object to move
|
||||
---@param pos table New position for the object
|
||||
---@param rot table New rotation for the object (optional)
|
||||
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)
|
||||
---@param rot? table New rotation for the object
|
||||
---@param below? boolean Should the object be placed below an existing deck?
|
||||
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)
|
||||
if obj == nil or pos == nil then return end
|
||||
|
||||
-- search the new position for existing card/deck
|
||||
local searchResult = searchLib.atPosition(pos, "isCardOrDeck")
|
||||
|
||||
-- get new position
|
||||
local newPos
|
||||
local offset = 0.5
|
||||
local newPos = Vector(pos) + Vector(0, offset, 0)
|
||||
|
||||
if #searchResult == 1 then
|
||||
local bounds = searchResult[1].getBounds()
|
||||
newPos = Vector(pos):setAt("y", bounds.center.y + bounds.size.y / 2 + offset)
|
||||
else
|
||||
newPos = Vector(pos) + Vector(0, offset, 0)
|
||||
if below then
|
||||
newPos = Vector(pos):setAt("y", bounds.center.y - bounds.size.y / 2)
|
||||
else
|
||||
newPos = Vector(pos):setAt("y", bounds.center.y + bounds.size.y / 2 + offset)
|
||||
end
|
||||
end
|
||||
|
||||
-- allow moving the objects smoothly out of the hand
|
||||
|
Loading…
Reference in New Issue
Block a user