Skip to content

Commit efbde13

Browse files
authored
Allow calc_scaling to apply to editions (#1014)
* Allow calc_scaling to apply to editions
1 parent 155ea1a commit efbde13

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lsp_def/classes/edition.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
---@field draw? fun(self: SMODS.Edition|table, card: Card|table, layer: string) Draws the edition's shader. By default, `self.shader` is drawn.
3939
---@field get_edition_cards? fun(self: SMODS.Edition|table, card_area: CardArea|table, edition: boolean): table
4040
---@field in_pool? fun(self: SMODS.Edition|table, args: table|{source: string}): boolean? Allows configuring if the edition is allowed to spawn.
41+
---@field calc_scaling? fun(self: SMODS.Edition|table, card: Card|table, other_card: Card|table, scaling_value: number, scalar_value: number, args: table): table? Called by `SMODS.scale_card`. Allows detection and modification of cards when scaling values. The return may include a `scaling_value` or `scalar_value` field to modify those values or any standard calculation return.
4142
---@overload fun(self: SMODS.Edition): SMODS.Edition
4243
SMODS.Edition = setmetatable({}, {
4344
__call = function(self)

src/utils.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,6 +2865,19 @@ function SMODS.scale_card(card, args)
28652865
SMODS.calculate_effect(ret, _card)
28662866
end
28672867
end
2868+
if card.edition then
2869+
local edition = G.P_CENTERS[card.edition.key]
2870+
if edition.calc_scaling and type(edition.calc_scaling) == 'function' then
2871+
local ret = edition:calc_scaling(_card, card, initial, scalar_value, args)
2872+
if ret then
2873+
if ret.override_value and not args.block_overrides.value then initial = ret.override_value.value; SMODS.calculate_effect(ret.override_value, _card) end
2874+
if ret.override_scalar_value and not args.block_overrides.scalar then scalar_value = ret.override_scalar_value.value; SMODS.calculate_effect(ret.override_scalar_value, _card) end
2875+
if ret.override_message and not args.block_overrides.message then scaling_message = SMODS.merge_defaults(ret.override_message, scaling_message) end
2876+
if ret.post then ret.post.source = _card; scaling_responses[#scaling_responses + 1] = ret.post end
2877+
SMODS.calculate_effect(ret, _card)
2878+
end
2879+
end
2880+
end
28682881
end
28692882
end
28702883

0 commit comments

Comments
 (0)