Compare commits

..

2 commits

Author SHA1 Message Date
386db180b5
Preserve original table 2026-07-08 19:36:50 +02:00
9ed747a33e
Add Frozen rank and suit support 2026-07-08 19:27:15 +02:00
3 changed files with 59 additions and 3 deletions

View file

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

View file

@ -54,9 +54,22 @@ local function freeze(card)
end end
(card.ability or {}).Roland_crimson = not not (card.ability or {}).Roland_crimson (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.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.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)} 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 local ability, ret = card.ability, card.Roland_frozen_ability
ability.extra = ability.extra == nil and {} or ability.extra 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) local _ = not context.fix_probability and not context.mod_probability and freeze(card)
end, end,
on_remove = function(card) 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, end,
get_weight = function(self) get_weight = function(self)
return G.GAME.edition_rate * self.weight return self.weight * G.GAME.edition_rate
end, end,
} }
@ -231,6 +248,30 @@ function Card:click(...)
return ret return ret
end 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
return ret
end
local orig_calculate_joker = Card.calculate_joker local orig_calculate_joker = Card.calculate_joker
---@param self Card|{Roland_frozen_ability?: table} ---@param self Card|{Roland_frozen_ability?: table}

View file

@ -289,6 +289,7 @@ function f.new(fnext)
concat = f.concat, concat = f.concat,
const = f.const, const = f.const,
count = f.count, count = f.count,
diff = f.diff,
each = f.each, each = f.each,
eq = f.eq, eq = f.eq,
fals = f.fals, fals = f.fals,
@ -718,6 +719,20 @@ function f:count(func)
return ret return ret
end 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 ---@generic K, V, T
---@param self F|{ [K]: V } ---@param self F|{ [K]: V }
---@param _ `T` ---@param _ `T`