Add Frozen rank and suit support

This commit is contained in:
Emik 2026-07-08 19:27:15 +02:00
parent 860381ebff
commit e6e76ec0ba
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
3 changed files with 61 additions and 3 deletions

View file

@ -3,7 +3,7 @@
"id": "Roland",
"name": "Roland",
"prefix": "Roland",
"version": "2.9.42",
"version": "2.9.43",
"badge_colour": "8BE9FD",
"display_name": "Roland",
"main_file": "src/main.lua",

View file

@ -54,9 +54,22 @@ local function freeze(card)
end
(card.ability or {}).Roland_crimson = not not (card.ability or {}).Roland_crimson
local config = card.config or {}
card.Roland_frozen_base = card.Roland_frozen_base or copy(card.base)
card.Roland_frozen_card = card.Roland_frozen_card or copy(config.card)
card.Roland_frozen_ability = card.Roland_frozen_ability or copy(card.ability)
card.base = card.Roland_frozen_base and copy(card.Roland_frozen_base) or card.base
config.card = card.Roland_frozen_card and copy(card.Roland_frozen_card) or config.card
card.ability = card.Roland_frozen_ability and copy(card.Roland_frozen_ability) or card.ability
card.Roland_frozen = card.Roland_frozen or {probability = SMODS.get_probability_vars(card, 1, 1)}
if type(card.set_sprites) == "function" and
f(card.Roland_frozen_card):diff(config.card) then
card:set_sprites(card.config.center, card.config.card)
end
local ability, ret = card.ability, card.Roland_frozen_ability
ability.extra = ability.extra == nil and {} or ability.extra
@ -196,10 +209,14 @@ SMODS.Edition {
local _ = not context.fix_probability and not context.mod_probability and freeze(card)
end,
on_remove = function(card)
card.Roland_frozen, card.Roland_frozen_ability, card.Roland_frozen_current_round = nil, nil, nil
card.Roland_frozen,
card.Roland_frozen_base,
card.Roland_frozen_card,
card.Roland_frozen_ability,
card.Roland_frozen_current_round = nil, nil, nil, nil, nil
end,
get_weight = function(self)
return G.GAME.edition_rate * self.weight
return self.weight * G.GAME.edition_rate
end,
}
@ -231,6 +248,32 @@ function Card:click(...)
return ret
end
local orig_save = Card.save
function Card:save(...)
if false then
---@type Card|{Roland_frozen: table, Roland_frozen_ability: table, Roland_frozen_base: table, Roland_frozen_card: table, Roland_frozen_current_round: table}
self = self
end
local ret = orig_save(self, ...)
ret.Roland_frozen,
ret.Roland_frozen_base,
ret.Roland_frozen_card,
ret.Roland_frozen_ability,
ret.Roland_frozen_current_round =
self.Roland_frozen,
self.Roland_frozen_base,
self.Roland_frozen_card,
self.Roland_frozen_ability,
self.Roland_frozen_current_round
ret.base = self.Roland_frozen_base or ret.base
ret.ability = self.Roland_frozen_ability or ret.ability
return ret
end
local orig_calculate_joker = Card.calculate_joker
---@param self Card|{Roland_frozen_ability?: table}

View file

@ -289,6 +289,7 @@ function f.new(fnext)
concat = f.concat,
const = f.const,
count = f.count,
diff = f.diff,
each = f.each,
eq = f.eq,
fals = f.fals,
@ -718,6 +719,20 @@ function f:count(func)
return ret
end
---@generic K, V
---@param self F|{ [K]: V }
---@param other { [K]: V }
---@return K?
---@overload fun(self: F|{ [K]: V }, func: string): integer
---@nodiscard
function f:diff(other)
for k, v in self.next do
if other[k] ~= v then
return k
end
end
end
---@generic K, V, T
---@param self F|{ [K]: V }
---@param _ `T`