Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion lovely/sticker.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ payload = '''
for k, v in ipairs(SMODS.Sticker.obj_buffer) do
local sticker = SMODS.Stickers[v]
if sticker.should_apply and type(sticker.should_apply) == 'function' and sticker:should_apply(card, center, area) then
sticker:apply(card, true)
SMODS.sticker_from_game = true
card:add_sticker(sticker.key)
SMODS.sticker_from_game = nil
end
end'''

Expand Down Expand Up @@ -109,3 +111,30 @@ pattern = '''table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100
position = 'at'
match_indent = true
payload = '''table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*((a.pinned and not a.ignore_pinned) and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*((b.pinned and not b.ignore_pinned) and b.sort_id or 0) end)'''

# Change challenge apply processes to use SMODS.sticker_from_game
[[patches]]
[patches.pattern]
target = 'functions/UI_definitions.lua'
pattern = "if v.eternal then card:set_eternal(true) end"
position = 'at'
payload = '''
if v.eternal then
SMODS.sticker_from_game = true
card:set_eternal(true)
SMODS.sticker_from_game = nil
end
'''

[[patches]]
[patches.pattern]
target = 'functions/UI_definitions.lua'
pattern = "if v.pinned then card.pinned = true end"
position = 'at'
payload = '''
if v.pinned then
SMODS.sticker_from_game = true
card:add_sticker('pinned')
SMODS.sticker_from_game = nil
end
'''
26 changes: 25 additions & 1 deletion src/overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2406,4 +2406,28 @@ function Card:set_ability(center, initial, delay_sprites)
if not initial and G.STATE ~= G.STATES.SMODS_BOOSTER_OPENED and G.STATE ~= G.STATES.SHOP and not G.SETTINGS.paused or G.TAROT_INTERRUPT then
SMODS.calculate_context({setting_ability = true, old = old_center.key, new = self.config.center_key, other_card = self, unchanged = old_center.key == self.config.center.key})
end
end
end

function Card:set_eternal(_eternal)
if not self.ability.eternal and _eternal then
self:add_sticker('eternal')
elseif self.ability.eternal and not _eternal then
self:remove_sticker('eternal')
end
end

function Card:set_perishable(_perishable)
if not self.ability.perishable and _perishable then
self:add_sticker('perishable')
elseif self.ability.perishable and not _perishable then
self:remove_sticker('perishable')
end
end

function Card:set_rental(_rental)
if not self.ability.rental and _rental then
self:add_sticker('rental')
elseif self.ability.rental and not _rental then
self:remove_sticker('rental')
end
end
2 changes: 2 additions & 0 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,15 @@ function Card:add_sticker(sticker, bypass_check)
if bypass_check or (sticker and sticker.should_apply and type(sticker.should_apply) == 'function' and sticker:should_apply(self, self.config.center, self.area, true)) then
sticker:apply(self, true)
SMODS.enh_cache:write(self, nil)
SMODS.calculate_context({apply_sticker = true, other_card = self, sticker = sticker, applied_by_game = SMODS.sticker_from_game or false})
end
end

function Card:remove_sticker(sticker)
if self.ability[sticker] then
SMODS.Stickers[sticker]:apply(self, false)
SMODS.enh_cache:write(self, nil)
SMODS.calculate_context({remove_sticker = true, other_card = self, sticker = sticker})
end
end

Expand Down