From f0ead2f41569e5366defe48a648f9718f5030d29 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 18 Nov 2023 10:03:37 +0100 Subject: [PATCH] resolved review comments --- src/playercards/cards/ScrollofSecrets.ttslua | 39 +++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/playercards/cards/ScrollofSecrets.ttslua b/src/playercards/cards/ScrollofSecrets.ttslua index 48c8cb3a..964912bd 100644 --- a/src/playercards/cards/ScrollofSecrets.ttslua +++ b/src/playercards/cards/ScrollofSecrets.ttslua @@ -6,38 +6,40 @@ local playmatApi = require("playermat/PlaymatApi") function onLoad() local notes = JSON.decode(self.getGMNotes()) if notes then - createContextMenu(notes.class) + createContextMenu(notes.id) else print("Missing metadata for Scroll of Secrets!") end end -function createContextMenu(class) - local colorList = Player.getAvailableColors() - - if class == "Seeker|Mystic" then - -- draw 1 card from the bottom +function createContextMenu(id) + if id == "05116" or id == "05116-t" then + -- lvl 0: draw 1 card from the bottom self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end) - elseif class == "Seeker" then - -- draw 3 cards from the bottom + elseif id == "05188" or id == "05188-t" then + -- seeker lvl 3: draw 3 cards from the bottom self.addContextMenuItem("Draw bottom card(s)", function(playerColor) contextFunc(playerColor, 3) end) - elseif class == "Mystic" then - -- draw 1 card from the bottom + elseif id == "05189" or id == "05189-t" then + -- mystic lvl 3: draw 1 card from the bottom self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end) end end function contextFunc(playerColor, amount) - -- TODO: only show colors that have a deck - local options = Player.getAvailableColors() - table.insert(options, "Encounter Deck") + local options = { "Encounter Deck" } + + -- check for players with a deck and only display them as option + for _, color in ipairs(Player.getAvailableColors()) do + local matColor = playmatApi.getMatColor(color) + local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor) + + if deckAreaObjects.draw or deckAreaObjects.topCard then + table.insert(options, color) + end + end -- show the target selection dialog - Player[playerColor].showOptionsDialog("Select target deck", options, _, - function(owner) - drawCardsFromBottom(playerColor, owner, amount) - end - ) + Player[playerColor].showOptionsDialog("Select target deck", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end) end function drawCardsFromBottom(playerColor, owner, amount) @@ -89,4 +91,5 @@ function drawCardsFromBottom(playerColor, owner, amount) end end end + printToColor("Handle the drawn cards according to the ability text on 'Scroll of Secrets'.", playerColor) end