Merge branch 'argonui:main' into kohaku
This commit is contained in:
commit
e8e68de98a
@ -89,12 +89,12 @@
|
|||||||
],
|
],
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": 40.7253036,
|
"posX": 40,
|
||||||
"posY": 1.29860592,
|
"posY": 1.3,
|
||||||
"posZ": 66.7765656,
|
"posZ": 66,
|
||||||
"rotX": 1.697304e-7,
|
"rotX": 0,
|
||||||
"rotY": 270.0102,
|
"rotY": 270,
|
||||||
"rotZ": 2.00479718e-7,
|
"rotZ": 0,
|
||||||
"scaleX": 0.6,
|
"scaleX": 0.6,
|
||||||
"scaleY": 1,
|
"scaleY": 1,
|
||||||
"scaleZ": 0.6
|
"scaleZ": 0.6
|
||||||
|
@ -380,8 +380,9 @@ end
|
|||||||
|
|
||||||
-- Constructs a list of available basic weaknesses by starting with the full pool of basic
|
-- Constructs a list of available basic weaknesses by starting with the full pool of basic
|
||||||
-- weaknesses then removing any which are currently in the play or deck construction areas
|
-- weaknesses then removing any which are currently in the play or deck construction areas
|
||||||
|
---@param traits? string Trait(s) to use as filter
|
||||||
---@return table: Array of weakness IDs which are valid to choose from
|
---@return table: Array of weakness IDs which are valid to choose from
|
||||||
function buildAvailableWeaknesses()
|
function buildAvailableWeaknesses(traits)
|
||||||
local weaknessesInPlay = {}
|
local weaknessesInPlay = {}
|
||||||
local allObjects = getAllObjects()
|
local allObjects = getAllObjects()
|
||||||
for _, object in ipairs(allObjects) do
|
for _, object in ipairs(allObjects) do
|
||||||
@ -399,7 +400,32 @@ function buildAvailableWeaknesses()
|
|||||||
if (weaknessesInPlay[weaknessId] ~= nil and weaknessesInPlay[weaknessId] > 0) then
|
if (weaknessesInPlay[weaknessId] ~= nil and weaknessesInPlay[weaknessId] > 0) then
|
||||||
weaknessesInPlay[weaknessId] = weaknessesInPlay[weaknessId] - 1
|
weaknessesInPlay[weaknessId] = weaknessesInPlay[weaknessId] - 1
|
||||||
else
|
else
|
||||||
table.insert(availableWeaknesses, weaknessId)
|
if traits then
|
||||||
|
-- split the string into separate traits (separated by "|")
|
||||||
|
local allowedTraits = {}
|
||||||
|
for str in traits:gmatch("([^|]+)") do
|
||||||
|
-- remove dots
|
||||||
|
str = str:gsub("[%.]", "")
|
||||||
|
|
||||||
|
-- remove leading and trailing whitespace
|
||||||
|
str = str:match("^%s*(.-)%s*$")
|
||||||
|
|
||||||
|
-- make sure string ends with a dot
|
||||||
|
str = string.lower(str .. ".")
|
||||||
|
table.insert(allowedTraits, str)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- make sure the trait is present on the weakness
|
||||||
|
local card = cardIdIndex[weaknessId]
|
||||||
|
for _, allowedTrait in ipairs(allowedTraits) do
|
||||||
|
if string.contains(string.lower(card.metadata.traits), allowedTrait) then
|
||||||
|
table.insert(availableWeaknesses, weaknessId)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(availableWeaknesses, weaknessId)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return availableWeaknesses
|
return availableWeaknesses
|
||||||
|
@ -25,7 +25,7 @@ do
|
|||||||
return getAllCardsBag().call("getCardById", { id = id })
|
return getAllCardsBag().call("getCardById", { id = id })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Gets a random basic weakness from the bag. Once a given ID has been returned it
|
-- Gets a random basic weakness from the bag. Once a given ID has been returned it
|
||||||
-- will be removed from the list and cannot be selected again until a reload occurs
|
-- will be removed from the list and cannot be selected again until a reload occurs
|
||||||
-- or the indexes are rebuilt, which will refresh the list to include all weaknesses.
|
-- or the indexes are rebuilt, which will refresh the list to include all weaknesses.
|
||||||
---@return string: ID of the selected weakness
|
---@return string: ID of the selected weakness
|
||||||
@ -80,6 +80,14 @@ do
|
|||||||
return returnCopyOfList(getAllCardsBag().call("getCardsByCycle", { cycle = cycle, sortByMetadata = sortByMetadata }))
|
return returnCopyOfList(getAllCardsBag().call("getCardsByCycle", { cycle = cycle, sortByMetadata = sortByMetadata }))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Constructs a list of available basic weaknesses by starting with the full pool of basic
|
||||||
|
-- weaknesses then removing any which are currently in the play or deck construction areas
|
||||||
|
---@param traits? string Trait(s) to use as filter
|
||||||
|
---@return table: Array of weakness IDs which are valid to choose from
|
||||||
|
AllCardsBagApi.buildAvailableWeaknesses = function(traits)
|
||||||
|
return returnCopyOfList(getAllCardsBag().call("buildAvailableWeaknesses", traits))
|
||||||
|
end
|
||||||
|
|
||||||
AllCardsBagApi.getUniqueWeaknesses = function()
|
AllCardsBagApi.getUniqueWeaknesses = function()
|
||||||
return returnCopyOfList(getAllCardsBag().call("getUniqueWeaknesses"))
|
return returnCopyOfList(getAllCardsBag().call("getUniqueWeaknesses"))
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,8 @@ local allCardsBagApi = require("playercards/AllCardsBagApi")
|
|||||||
local arkhamDb = require("arkhamdb/ArkhamDb")
|
local arkhamDb = require("arkhamdb/ArkhamDb")
|
||||||
local spawnBag = require("playercards/SpawnBag")
|
local spawnBag = require("playercards/SpawnBag")
|
||||||
|
|
||||||
|
local lastWeaknessTrait = "Madness"
|
||||||
|
|
||||||
-- Size and position information for the three rows of class buttons
|
-- Size and position information for the three rows of class buttons
|
||||||
local CIRCLE_BUTTON_SIZE = 250
|
local CIRCLE_BUTTON_SIZE = 250
|
||||||
local CLASS_BUTTONS_X_OFFSET = 0.1325
|
local CLASS_BUTTONS_X_OFFSET = 0.1325
|
||||||
@ -224,9 +226,10 @@ function createWeaknessButtons()
|
|||||||
weaknessButtonParams.tooltip = "All Weaknesses"
|
weaknessButtonParams.tooltip = "All Weaknesses"
|
||||||
weaknessButtonParams.position = buttonPos
|
weaknessButtonParams.position = buttonPos
|
||||||
self.createButton(weaknessButtonParams)
|
self.createButton(weaknessButtonParams)
|
||||||
|
|
||||||
buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET
|
buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET
|
||||||
weaknessButtonParams.click_function = "spawnRandomWeakness"
|
weaknessButtonParams.click_function = "spawnRandomWeakness"
|
||||||
weaknessButtonParams.tooltip = "Random Basic Weakness"
|
weaknessButtonParams.tooltip = "Random Basic Weakness\nRight-click to specify a trait"
|
||||||
weaknessButtonParams.position = buttonPos
|
weaknessButtonParams.position = buttonPos
|
||||||
self.createButton(weaknessButtonParams)
|
self.createButton(weaknessButtonParams)
|
||||||
end
|
end
|
||||||
@ -361,9 +364,9 @@ function createXML(showOtherCardsButton)
|
|||||||
alignment = "MiddleLeft",
|
alignment = "MiddleLeft",
|
||||||
horizontalOverflow = "wrap",
|
horizontalOverflow = "wrap",
|
||||||
text = "• Select a group to place cards\n" ..
|
text = "• Select a group to place cards\n" ..
|
||||||
"• Copy the cards you want for your deck\n" ..
|
"• Copy the cards you want for your deck\n" ..
|
||||||
"• Select a new group to clear the placed cards and see new ones\n" ..
|
"• Select a new group to clear the placed cards and see new ones\n" ..
|
||||||
"• Clear to remove all cards"
|
"• Clear to remove all cards"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -775,13 +778,32 @@ function spawnWeaknesses()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function spawnRandomWeakness()
|
function spawnRandomWeakness(_, playerColor, isRightClick)
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
local weaknessId = allCardsBagApi.getRandomWeaknessId()
|
|
||||||
if (weaknessId == nil) then
|
if not isRightClick then
|
||||||
broadcastToAll("All basic weaknesses are in play!", { 0.9, 0.2, 0.2 })
|
local weaknessId = allCardsBagApi.getRandomWeaknessId()
|
||||||
return
|
if weaknessId == nil then
|
||||||
|
broadcastToAll("All basic weaknesses are in play!", { 0.9, 0.2, 0.2 })
|
||||||
|
else
|
||||||
|
spawnSingleWeakness(weaknessId)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Player[playerColor].showInputDialog("Specify a trait for the weakness (split multiple eligible traits with '|'):", lastWeaknessTrait,
|
||||||
|
function(text)
|
||||||
|
lastWeaknessTrait = text
|
||||||
|
local availableWeaknesses = allCardsBagApi.buildAvailableWeaknesses(text)
|
||||||
|
if #availableWeaknesses > 0 then
|
||||||
|
spawnSingleWeakness(availableWeaknesses[math.random(#availableWeaknesses)])
|
||||||
|
else
|
||||||
|
broadcastToAll("No matching weakness available!", { 0.9, 0.2, 0.2 })
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- spawn the random weakness
|
||||||
|
function spawnSingleWeakness(weaknessId)
|
||||||
spawnBag.spawn({
|
spawnBag.spawn({
|
||||||
name = "randomWeakness",
|
name = "randomWeakness",
|
||||||
cards = { weaknessId },
|
cards = { weaknessId },
|
||||||
|
@ -28,6 +28,9 @@ Spawner.spawnCards = function(cardList, pos, rot, sort, callback)
|
|||||||
if card.metadata.type == "Investigator" then
|
if card.metadata.type == "Investigator" then
|
||||||
table.insert(investigatorCards, card)
|
table.insert(investigatorCards, card)
|
||||||
elseif card.metadata.type == "Minicard" then
|
elseif card.metadata.type == "Minicard" then
|
||||||
|
-- set proper scale for minicards
|
||||||
|
card.data.Transform.scaleX = 0.6
|
||||||
|
card.data.Transform.scaleZ = 0.6
|
||||||
table.insert(miniCards, card)
|
table.insert(miniCards, card)
|
||||||
else
|
else
|
||||||
table.insert(standardCards, card)
|
table.insert(standardCards, card)
|
||||||
|
@ -1,32 +1,31 @@
|
|||||||
-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets
|
|
||||||
local mythosAreaApi = require("core/MythosAreaApi")
|
local mythosAreaApi = require("core/MythosAreaApi")
|
||||||
local playermatApi = require("playermat/PlayermatApi")
|
local playermatApi = require("playermat/PlayermatApi")
|
||||||
|
|
||||||
-- get class via metadata and create context menu accordingly
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
|
-- get class via metadata and proceed menu accordingly:
|
||||||
|
-- lvl 0: draw 1 card from the bottom
|
||||||
|
-- mystic lvl 3: draw 1 card from the bottom
|
||||||
|
local buttonLabel = "Draw bottom card"
|
||||||
|
local amount = 1
|
||||||
local notes = JSON.decode(self.getGMNotes())
|
local notes = JSON.decode(self.getGMNotes())
|
||||||
if notes then
|
if notes.id == "05188" or notes.id == "05188-t" then
|
||||||
createContextMenu(notes.id)
|
|
||||||
else
|
|
||||||
print("Missing metadata for Scroll of Secrets!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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 id == "05188" or id == "05188-t" then
|
|
||||||
-- seeker lvl 3: 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)
|
buttonLabel = buttonLabel .. "(s)"
|
||||||
elseif id == "05189" or id == "05189-t" then
|
amount = 3
|
||||||
-- mystic lvl 3: draw 1 card from the bottom
|
|
||||||
self.addContextMenuItem("Draw bottom card", function(playerColor) contextFunc(playerColor, 1) end)
|
|
||||||
end
|
end
|
||||||
|
self.addContextMenuItem(buttonLabel, function(playerColor) contextFunc(playerColor, amount) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function contextFunc(playerColor, amount)
|
function contextFunc(playerColor, amount)
|
||||||
local options = { "Encounter Deck" }
|
deckData = {}
|
||||||
|
local options = {}
|
||||||
|
|
||||||
|
-- check for encounter deck
|
||||||
|
local encounterDeck = mythosAreaApi.getEncounterDeck()
|
||||||
|
if encounterDeck then
|
||||||
|
table.insert(options, "Encounter Deck")
|
||||||
|
deckData["Encounter Deck"] = { draw = encounterDeck }
|
||||||
|
end
|
||||||
|
|
||||||
-- check for players with a deck and only display them as option
|
-- check for players with a deck and only display them as option
|
||||||
for _, color in ipairs(Player.getAvailableColors()) do
|
for _, color in ipairs(Player.getAvailableColors()) do
|
||||||
@ -34,28 +33,35 @@ function contextFunc(playerColor, amount)
|
|||||||
local deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
local deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
||||||
|
|
||||||
if deckAreaObjects.draw or deckAreaObjects.topCard then
|
if deckAreaObjects.draw or deckAreaObjects.topCard then
|
||||||
table.insert(options, color)
|
local playerName = Player[color].steam_name
|
||||||
|
local invName = playermatApi.getInvestigatorName(matColor)
|
||||||
|
|
||||||
|
-- figure out a proper display name for the drop down menu
|
||||||
|
local displayName = color .. " (color)"
|
||||||
|
if playerName then
|
||||||
|
displayName = playerName
|
||||||
|
elseif invName ~= "" then
|
||||||
|
displayName = invName .. " (inv)"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- recreate table in this script to have access
|
||||||
|
deckData[displayName] = {
|
||||||
|
draw = deckAreaObjects.draw,
|
||||||
|
topCard = deckAreaObjects.topCard
|
||||||
|
}
|
||||||
|
table.insert(options, displayName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- show the target selection dialog
|
-- 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
|
end
|
||||||
|
|
||||||
function drawCardsFromBottom(playerColor, owner, amount)
|
function drawCardsFromBottom(playerColor, owner, amount)
|
||||||
-- variable initialization
|
local deckAreaObjects = deckData[owner]
|
||||||
local deck = nil
|
local deck = deckAreaObjects.draw
|
||||||
local deckSize = 1
|
local deckSize = 1
|
||||||
local deckAreaObjects = {}
|
|
||||||
|
|
||||||
-- get the respective deck
|
|
||||||
if owner == "Encounter Deck" then
|
|
||||||
deck = mythosAreaApi.getEncounterDeck()
|
|
||||||
else
|
|
||||||
local matColor = playermatApi.getMatColor(owner)
|
|
||||||
deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
|
||||||
deck = deckAreaObjects.draw
|
|
||||||
end
|
|
||||||
|
|
||||||
-- error handling
|
-- error handling
|
||||||
if not deck then
|
if not deck then
|
||||||
|
@ -2,6 +2,7 @@ do
|
|||||||
local PlayermatApi = {}
|
local PlayermatApi = {}
|
||||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||||
local searchLib = require("util/SearchLib")
|
local searchLib = require("util/SearchLib")
|
||||||
|
local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }
|
||||||
|
|
||||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||||
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
||||||
@ -283,7 +284,6 @@ do
|
|||||||
|
|
||||||
-- Returns a list of mat colors that have an investigator placed
|
-- Returns a list of mat colors that have an investigator placed
|
||||||
PlayermatApi.getUsedMatColors = function()
|
PlayermatApi.getUsedMatColors = function()
|
||||||
local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }
|
|
||||||
local usedColors = {}
|
local usedColors = {}
|
||||||
for matColor, mat in pairs(getMatForColor("All")) do
|
for matColor, mat in pairs(getMatForColor("All")) do
|
||||||
local searchPos = mat.positionToWorld(localInvestigatorPosition)
|
local searchPos = mat.positionToWorld(localInvestigatorPosition)
|
||||||
@ -295,6 +295,19 @@ do
|
|||||||
return usedColors
|
return usedColors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns investigator name
|
||||||
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
|
PlayermatApi.getInvestigatorName = function(matColor)
|
||||||
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
|
local searchPos = mat.positionToWorld(localInvestigatorPosition)
|
||||||
|
local searchResult = searchLib.atPosition(searchPos, "isCardOrDeck")
|
||||||
|
if #searchResult == 1 then
|
||||||
|
return searchResult[1].getName()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
-- Resets the specified skill tracker to "1, 1, 1, 1"
|
-- Resets the specified skill tracker to "1, 1, 1, 1"
|
||||||
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playermat - White, Orange, Green, Red or All
|
||||||
PlayermatApi.resetSkillTracker = function(matColor)
|
PlayermatApi.resetSkillTracker = function(matColor)
|
||||||
|
Loading…
Reference in New Issue
Block a user