Add support for pools and tags
This commit is contained in:
parent
7c64a5d8fa
commit
91660bfeea
2 changed files with 32 additions and 9 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"id": "Roland",
|
"id": "Roland",
|
||||||
"name": "Roland",
|
"name": "Roland",
|
||||||
"prefix": "Roland",
|
"prefix": "Roland",
|
||||||
"version": "2.9.27",
|
"version": "2.9.28",
|
||||||
"badge_colour": "8BE9FD",
|
"badge_colour": "8BE9FD",
|
||||||
"display_name": "Roland",
|
"display_name": "Roland",
|
||||||
"main_file": "src/main.lua",
|
"main_file": "src/main.lua",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,21 @@
|
||||||
local f = assert(SMODS.load_file "src/lib/funky.lua")() or require "lib.funky"
|
local f = assert(SMODS.load_file "src/lib/funky.lua")() or require "lib.funky"
|
||||||
|
|
||||||
local function add_card(v)
|
---@param v string
|
||||||
return SMODS.add_card {no_edition = true, key = v}
|
---@return Card|Tag
|
||||||
|
local function add(v)
|
||||||
|
if not G.P_TAGS[v] then
|
||||||
|
return SMODS.add_card {no_edition = true, key = v}
|
||||||
|
end
|
||||||
|
|
||||||
|
local tag = Tag(v)
|
||||||
|
|
||||||
|
if tag.name == "Orbital Tag" then
|
||||||
|
local hands = f(G.GAME.hands):where "visible":keys():table()
|
||||||
|
tag.ability.orbital_hand = pseudorandom_element(hands, pseudoseed "Roland_c_orbital_tag")
|
||||||
|
end
|
||||||
|
|
||||||
|
add_tag(tag)
|
||||||
|
return tag
|
||||||
end
|
end
|
||||||
|
|
||||||
local function simplify(x)
|
local function simplify(x)
|
||||||
|
|
@ -18,12 +32,17 @@ local function find(it)
|
||||||
return it
|
return it
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local match = simplify(it)
|
||||||
|
local pool = f(G.P_CENTER_POOLS):any(f.chain(f.arg(2), simplify, f.eq(match)))
|
||||||
|
|
||||||
|
if type(pool) == "table" and next(pool) then
|
||||||
|
return pseudorandom_element(pool, pseudoseed "Roland_c").key
|
||||||
|
end
|
||||||
|
|
||||||
if Cryptid and Cryptid.aliases and Cryptid.aliases[it] then
|
if Cryptid and Cryptid.aliases and Cryptid.aliases[it] then
|
||||||
return Cryptid.aliases[it]
|
return Cryptid.aliases[it]
|
||||||
end
|
end
|
||||||
|
|
||||||
local match = simplify(it)
|
|
||||||
|
|
||||||
return f(G.localization.descriptions)
|
return f(G.localization.descriptions)
|
||||||
:flatmap(flatten)
|
:flatmap(flatten)
|
||||||
:where(type, "table")
|
:where(type, "table")
|
||||||
|
|
@ -93,7 +112,7 @@ end
|
||||||
|
|
||||||
--- Creates one or more cards.
|
--- Creates one or more cards.
|
||||||
---@param ... any
|
---@param ... any
|
||||||
---@return Card|Card[]
|
---@return Card|Tag|(Card|Tag[])
|
||||||
local function c(...)
|
local function c(...)
|
||||||
local cards = f {...}
|
local cards = f {...}
|
||||||
:flatmap(flatten)
|
:flatmap(flatten)
|
||||||
|
|
@ -101,7 +120,7 @@ local function c(...)
|
||||||
:map(string.lower)
|
:map(string.lower)
|
||||||
:map(find)
|
:map(find)
|
||||||
:where(f.id)
|
:where(f.id)
|
||||||
:map(add_card)
|
:map(add)
|
||||||
:values()
|
:values()
|
||||||
:table()
|
:table()
|
||||||
|
|
||||||
|
|
@ -115,7 +134,11 @@ return {f, q, u, setmetatable({}, {
|
||||||
__index = function(_, k)
|
__index = function(_, k)
|
||||||
return c(k)
|
return c(k)
|
||||||
end,
|
end,
|
||||||
__newindex = function()
|
__newindex = function(_, k, v)
|
||||||
sendErrorMessage("`c` should not be assigned to.", "Roland")
|
local n = tonumber(v)
|
||||||
|
|
||||||
|
for _ = 1, type(n) == "number" and n or 1 do
|
||||||
|
c(k)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue