Improve type coercion
This commit is contained in:
parent
4ce2405288
commit
c451fa6d57
5 changed files with 24 additions and 8 deletions
|
|
@ -495,7 +495,7 @@ local venerable_visage = blind {
|
|||
|
||||
table.insert(G.playing_cards, card)
|
||||
G.deck:emplace(card)
|
||||
play_sound("card1")
|
||||
play_sound "card1"
|
||||
card:add_to_deck()
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ local finalizers = {
|
|||
G.hand:unhighlight_all()
|
||||
|
||||
local count = (blind.name == "Cerulean Bell" and 2 or 1) -
|
||||
f(G.hand.cards):map(f "ability"):count(f "forced_selection")
|
||||
f(G.hand.cards):map "ability":count "forced_selection"
|
||||
|
||||
f(copy):take(count):each(function(v)
|
||||
v.ability.forced_selection = true
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ joker {
|
|||
---@param card Card
|
||||
---@param times? integer
|
||||
proc = function(card, times)
|
||||
local hands = f(G.GAME.hands):where(f "visible"):keys():table()
|
||||
local hands = f(G.GAME.hands):where "visible":keys():table()
|
||||
pseudoshuffle(hands, pseudoseed "RolandEscapey")
|
||||
local levels = card.ability.extra.hands * (times or 1)
|
||||
level_up("all", math.floor(levels / #hands), card)
|
||||
|
|
@ -270,7 +270,7 @@ joker {
|
|||
G.hand_text_area.blind_chips:juice_up()
|
||||
G.hand_text_area.game_chips:juice_up()
|
||||
card:start_dissolve()
|
||||
play_sound("tarot1")
|
||||
play_sound "tarot1"
|
||||
end)
|
||||
end
|
||||
end,
|
||||
|
|
@ -377,7 +377,7 @@ joker {
|
|||
card.getting_sliced = not context.forcetrigger
|
||||
|
||||
q(function()
|
||||
local scored_cards = f(G.play.cards):where(f "highlighted"):table()
|
||||
local scored_cards = f(G.play.cards):where "highlighted":table()
|
||||
local copied = {}
|
||||
|
||||
if not next(scored_cards) then
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ end
|
|||
---@param step? nil
|
||||
---@return F | { [K]: V }
|
||||
---@overload fun(tbl: number, fpairs?: number, step?: number): F | { [number]: number }
|
||||
---@overload fun(tbl: string|K): fun(table: { [string|K]: V }): V
|
||||
---@overload fun(tbl: string): (fun(table: { [string]: V }): V)
|
||||
---@overload fun(tbl: false): fun(): false
|
||||
---@overload fun(tbl: true): fun(): true
|
||||
---@overload fun(tbl: nil): F
|
||||
|
|
@ -193,7 +193,10 @@ end
|
|||
---@param func F|fun(v: V, k: K): U
|
||||
---@return F|{ [K]: U }
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): F|{ [K]: U }
|
||||
function f:map(func)
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
return f.new(function()
|
||||
local k, v = self:next()
|
||||
|
||||
|
|
@ -209,9 +212,11 @@ end
|
|||
---@param fpairs? fun(t: table<K, V>): (fun(table: table<K, V>, index?: K): K, V)
|
||||
---@return F|{ [K]: U }
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): F|{ [K]: U }
|
||||
function f:flatmap(func, fpairs)
|
||||
-- local i = 0
|
||||
local vt, vk, vv, vp
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
return f.new(function()
|
||||
if vk then
|
||||
|
|
@ -256,7 +261,10 @@ end
|
|||
---@param func F|fun(v: V, k: K): boolean
|
||||
---@return F|{ [K]: V }
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): F|{ [K]: V }
|
||||
function f:where(func)
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
return f.new(function()
|
||||
local k, v
|
||||
|
||||
|
|
@ -393,7 +401,10 @@ end
|
|||
---@param func F|fun(v: V, k: K): boolean
|
||||
---@return boolean|V
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): boolean
|
||||
function f:any(func)
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
for k, v in self.next do
|
||||
if not func or func(v, k) then
|
||||
return v or true
|
||||
|
|
@ -408,7 +419,10 @@ end
|
|||
---@param func F|fun(v: V, k: K): boolean
|
||||
---@return boolean|V
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): boolean
|
||||
function f:all(func)
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
for k, v in self.next do
|
||||
if not func or not func(v, k) then
|
||||
return v and false
|
||||
|
|
@ -423,8 +437,10 @@ end
|
|||
---@param func F|fun(v: V, k: K): boolean
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
---@overload fun(self: F|{ [K]: V }, func: string): integer
|
||||
function f:count(func)
|
||||
local ret = 0
|
||||
func = type(func) == "string" and f.index(func) or func
|
||||
|
||||
for k, v in self.next do
|
||||
if not func or func(v, k) then
|
||||
|
|
@ -475,7 +491,7 @@ end
|
|||
|
||||
---@generic K, V
|
||||
---@param self F|{ [K]: V }
|
||||
---@param func? F|fun(v: V, k: K)
|
||||
---@param func? fun(v: V, k: K)
|
||||
function f:each(func)
|
||||
for k, v in self.next do
|
||||
if func then
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ SMODS.Seal {
|
|||
local tag = Tag(get_next_tag_key "Roland_glass")
|
||||
|
||||
if tag.name == "Orbital Tag" then
|
||||
local hands = f(G.GAME.hands):where(f "visible"):keys():table()
|
||||
local hands = f(G.GAME.hands):where "visible":keys():table()
|
||||
tag.ability.orbital_hand = pseudorandom_element(hands, pseudoseed "Roland_glass")
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue