updated hand helper and search assistant

This commit is contained in:
Chr1Z93 2023-03-16 13:50:06 +01:00
parent c52df403bc
commit 4c9b50b683
2 changed files with 20 additions and 20 deletions

View File

@ -1,4 +1,6 @@
local playmatAPI = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
-- forward declaration of variables that are used across functions
local matColor, handColor, loopId, hovering local matColor, handColor, loopId, hovering
function onLoad() function onLoad()
@ -62,8 +64,8 @@ end
-- updates the matcolor and handcolor variable -- updates the matcolor and handcolor variable
function updateColors() function updateColors()
matColor = playmatAPI.getMatColorByPosition(self.getPosition()) matColor = playmatApi.getMatColorByPosition(self.getPosition())
handColor = playmatAPI.getHandColor(matColor) handColor = playmatApi.getPlayerColor(matColor)
self.setName(handColor .. " Hand Helper") self.setName(handColor .. " Hand Helper")
end end
@ -78,7 +80,7 @@ function updateValue(toggle)
if Player[handColor].getHandCount() == 0 then return end if Player[handColor].getHandCount() == 0 then return end
-- get state of "Dream-Enhancing Serum" from playermat and update button label -- get state of "Dream-Enhancing Serum" from playermat and update button label
local des = playmatAPI.isDES(matColor) local des = playmatApi.isDES(matColor)
if toggle then des = not des end if toggle then des = not des end
self.editButton({ index = 1, label = "DES: " .. (des and "✓" or "✗") }) self.editButton({ index = 1, label = "DES: " .. (des and "✓" or "✗") })
@ -110,5 +112,5 @@ end
-- discards a random non-hidden card from hand -- discards a random non-hidden card from hand
function discardRandom() function discardRandom()
playmatAPI.doDiscardOne(matColor) playmatApi.doDiscardOne(matColor)
end end

View File

@ -1,10 +1,7 @@
local playmatAPI = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
-- forward declaration of variables that are used across functions -- forward declaration of variables that are used across functions
local matColor local matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition
local setAsidePosition
local setAsideRotation
local drawDeckPosition
local quickParameters = {} local quickParameters = {}
quickParameters.function_owner = self quickParameters.function_owner = self
@ -102,10 +99,11 @@ end
-- start the search (change UI, set handCards aside, draw cards) -- start the search (change UI, set handCards aside, draw cards)
function startSearch(messageColor, number) function startSearch(messageColor, number)
matColor = playmatAPI.getMatColorByPosition(self.getPosition()) matColor = playmatApi.getMatColorByPosition(self.getPosition())
handColor = playmatApi.getPlayerColor(matColor)
-- get draw deck -- get draw deck
local drawDeck = playmatAPI.getDrawDeck(matColor) local drawDeck = playmatApi.getDrawDeck(matColor)
if drawDeck == nil then if drawDeck == nil then
printToColor(matColor .. " draw deck could not be found!", messageColor, "Red") printToColor(matColor .. " draw deck could not be found!", messageColor, "Red")
return return
@ -121,8 +119,8 @@ function startSearch(messageColor, number)
end end
-- get position and rotation for set aside cards -- get position and rotation for set aside cards
local handData = Player[matColor].getHandTransform() local handData = Player[handColor].getHandTransform()
local handCards = Player[matColor].getHandObjects() local handCards = Player[handColor].getHandObjects()
setAsidePosition = handData.position + offset * handData.right setAsidePosition = handData.position + offset * handData.right
setAsideRotation = { handData.rotation.x, handData.rotation.y + 180, 180 } setAsideRotation = { handData.rotation.x, handData.rotation.y + 180, 180 }
@ -136,18 +134,18 @@ function startSearch(messageColor, number)
local object = v.hit_object local object = v.hit_object
if object.tag == "Card" and not object.is_face_down then if object.tag == "Card" and not object.is_face_down then
object.flip() object.flip()
Wait.time(function() drawDeck = playmatAPI.getDrawDeck(matColor) end, 1) Wait.time(function() drawDeck = playmatApi.getDrawDeck(matColor) end, 1)
break break
end end
end end
Wait.time(function() drawDeck.deal(number, matColor) end, 1) Wait.time(function() drawDeck.deal(number, handColor) end, 1)
searchView() searchView()
end end
-- place handCards back into deck and optionally shuffle -- place handCards back into deck and optionally shuffle
function endSearch(_, _, isRightClick) function endSearch(_, _, isRightClick)
local handCards = Player[matColor].getHandObjects() local handCards = Player[handColor].getHandObjects()
for i = #handCards, 1, -1 do for i = #handCards, 1, -1 do
handCards[i].setPosition(drawDeckPosition + Vector(0, 6 - i * 0.3, 0)) handCards[i].setPosition(drawDeckPosition + Vector(0, 6 - i * 0.3, 0))
@ -156,7 +154,7 @@ function endSearch(_, _, isRightClick)
if not isRightClick then if not isRightClick then
Wait.time(function() Wait.time(function()
local deck = playmatAPI.getDrawDeck(matColor) local deck = playmatApi.getDrawDeck(matColor)
if deck ~= nil then if deck ~= nil then
deck.shuffle() deck.shuffle()
end end
@ -168,11 +166,11 @@ function endSearch(_, _, isRightClick)
local obj = v.hit_object local obj = v.hit_object
if obj.tag == "Deck" then if obj.tag == "Deck" then
Wait.time(function() Wait.time(function()
obj.deal(#obj.getObjects(), matColor) obj.deal(#obj.getObjects(), handColor)
end, 1) end, 1)
break break
elseif obj.tag == "Card" then elseif obj.tag == "Card" then
obj.setPosition(Player[matColor].getHandTransform().position) obj.setPosition(Player[handColor].getHandTransform().position)
obj.flip() obj.flip()
break break
end end