resolved review comments

This commit is contained in:
Chr1Z93 2023-11-18 10:03:37 +01:00
parent 9a2141cb82
commit f0ead2f415

View File

@ -6,38 +6,40 @@ local playmatApi = require("playermat/PlaymatApi")
function onLoad() function onLoad()
local notes = JSON.decode(self.getGMNotes()) local notes = JSON.decode(self.getGMNotes())
if notes then if notes then
createContextMenu(notes.class) createContextMenu(notes.id)
else else
print("Missing metadata for Scroll of Secrets!") print("Missing metadata for Scroll of Secrets!")
end end
end end
function createContextMenu(class) function createContextMenu(id)
local colorList = Player.getAvailableColors() if id == "05116" or id == "05116-t" then
-- lvl 0: draw 1 card from the bottom
if class == "Seeker|Mystic" then
-- draw 1 card from the bottom
self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end) self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end)
elseif class == "Seeker" then elseif id == "05188" or id == "05188-t" then
-- draw 3 cards from the bottom -- seeker lvl 3: draw 3 cards from the bottom
self.addContextMenuItem("Draw bottom card(s)", function(playerColor) contextFunc(playerColor, 3) end) self.addContextMenuItem("Draw bottom card(s)", function(playerColor) contextFunc(playerColor, 3) end)
elseif class == "Mystic" then elseif id == "05189" or id == "05189-t" then
-- draw 1 card from the bottom -- mystic lvl 3: draw 1 card from the bottom
self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end) self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end)
end end
end end
function contextFunc(playerColor, amount) function contextFunc(playerColor, amount)
-- TODO: only show colors that have a deck local options = { "Encounter Deck" }
local options = Player.getAvailableColors()
table.insert(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 -- show the target selection dialog
Player[playerColor].showOptionsDialog("Select target deck", options, _, Player[playerColor].showOptionsDialog("Select target deck", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)
function(owner)
drawCardsFromBottom(playerColor, owner, amount)
end
)
end end
function drawCardsFromBottom(playerColor, owner, amount) function drawCardsFromBottom(playerColor, owner, amount)
@ -89,4 +91,5 @@ function drawCardsFromBottom(playerColor, owner, amount)
end end
end end
end end
printToColor("Handle the drawn cards according to the ability text on 'Scroll of Secrets'.", playerColor)
end end