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()
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