Avoid all uses of update functions

This commit is contained in:
Emik 2026-08-04 16:30:31 +02:00
parent 656be9aa38
commit 2a6371a928
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
6 changed files with 75 additions and 82 deletions

View file

@ -16,9 +16,7 @@ match_indent = true
target = "globals.lua" target = "globals.lua"
pattern = "EDITION = {1,1,1,1}," pattern = "EDITION = {1,1,1,1},"
position = "before" position = "before"
payload = '''jane_RGB = {0,0,0,1}, payload = "jane_RGB = {1,1,1,1},"
jane_RGB_HUE = 0,
almighty = {0,0,1,1},'''
match_indent = true match_indent = true
[[patches]] [[patches]]

View file

@ -18,5 +18,5 @@
"conflicts": [ "conflicts": [
"Jen" "Jen"
], ],
"version": "1.11.22" "version": "1.11.23"
} }

View file

@ -217,12 +217,15 @@ SMODS.Edition({
loc_vars = function(self, _, _) loc_vars = function(self, _, _)
return {vars = {self.config.e_chips, self.config.e_mult}} return {vars = {self.config.e_chips, self.config.e_mult}}
end, end,
draw = function()
G.P_CENTERS.j_jane_saint:draw()
end,
calculate = function(self, card, context) calculate = function(self, card, context)
return ( if not context.post_joker and (not context.main_scoring or context.cardarea ~= G.play) then
context.post_joker or return
context.main_scoring and end
context.cardarea == G.play
) and { return {
extra = { extra = {
card = card, card = card,
colour = G.C.jane_RGB, colour = G.C.jane_RGB,
@ -233,6 +236,6 @@ SMODS.Edition({
e_mult = self.config.e_mult, e_mult = self.config.e_mult,
}, },
}, },
} or nil }
end, end,
}) })

View file

@ -281,7 +281,7 @@ SMODS.Joker {
function Jane.update_honey() function Jane.update_honey()
if not G.GAME then if not G.GAME then
return return true
end end
local honey = SMODS.find_card("j_jane_honey") local honey = SMODS.find_card("j_jane_honey")
@ -393,8 +393,11 @@ SMODS.Joker {
}, },
} }
end, end,
update = function(_, card, _) draw = function(_, card)
if card.added_to_deck and card.children.center and card.children.floating_sprite then if not Jane.update_honey() and
card.added_to_deck and
card.children.center and
card.children.floating_sprite then
local extra = card.ability.extra or {} local extra = card.ability.extra or {}
local y = (tonumber(extra.level) or 1) > 1 and 1 or 0 local y = (tonumber(extra.level) or 1) > 1 and 1 or 0
card.children.center:set_sprite_pos({x = 0, y = y}) card.children.center:set_sprite_pos({x = 0, y = y})
@ -528,7 +531,7 @@ SMODS.Joker {
}, },
} }
end, end,
update = function(_, card, _) draw = function(_, card)
if card.added_to_deck and card.children.center and card.children.floating_sprite then if card.added_to_deck and card.children.center and card.children.floating_sprite then
local extra = card.ability.extra or {} local extra = card.ability.extra or {}
local y = extra.is_corrupted and 1 or 0 local y = extra.is_corrupted and 1 or 0
@ -658,6 +661,9 @@ SMODS.Joker {
remove_from_deck = function(_, card, _) remove_from_deck = function(_, card, _)
grand_dad(card) grand_dad(card)
end, end,
draw = function()
G.P_CENTERS.j_jane_saint:draw()
end,
calculate = function(_, card, context) calculate = function(_, card, context)
if context.cardarea ~= G.play or if context.cardarea ~= G.play or
not context.individual or not context.individual or

View file

@ -155,6 +155,33 @@ function Jane.hidden(card)
(type(card) == "table" and (card.name == "Black Hole" or card.name == "The Soul") or card.hidden) (type(card) == "table" and (card.name == "Black Hole" or card.name == "The Soul") or card.hidden)
end end
function Jane.hsv(h, s, v)
if s <= 0 then
return v, v, v
end
h = h * 6
local c = v * s
local x = (1 - math.abs((h % 2) - 1)) * c
local m, r, g, b = (v - c), 0, 0, 0
if h < 1 then
r, g, b = c, x, 0
elseif h < 2 then
r, g, b = x, c, 0
elseif h < 3 then
r, g, b = 0, c, x
elseif h < 4 then
r, g, b = 0, x, c
elseif h < 5 then
r, g, b = x, 0, c
else
r, g, b = c, 0, x
end
return r + m, g + m, b + m
end
function Jane.is_end_of_ante(context, card) function Jane.is_end_of_ante(context, card)
return not context.individual and not return not context.individual and not
context.repetition and not context.repetition and not
@ -271,74 +298,16 @@ function Game:main_menu(change_context)
orig_menu(self, change_context) orig_menu(self, change_context)
end end
local orig_update = Game.update local orig_start_run = Game.start_run
function Game:update(dt) function Game:start_run(...)
local function delete_hardbans() orig_start_run(self, ...)
if not Jane.config.disable_bans then
for _, v in pairs(Jane.config.bans) do
local e = SMODS.Center:get_obj(v)
if e then if self.GAME.banned_keys then
e:delete()
end
end
end
end
local function hsv(h, s, v)
if s <= 0 then
return v, v, v
end
h = h * 6
local c = v * s
local x = (1 - math.abs((h % 2) - 1)) * c
local m, r, g, b = (v - c), 0, 0, 0
if h < 1 then
r, g, b = c, x, 0
elseif h < 2 then
r, g, b = x, c, 0
elseif h < 3 then
r, g, b = 0, c, x
elseif h < 4 then
r, g, b = 0, x, c
elseif h < 5 then
r, g, b = x, 0, c
else
r, g, b = c, 0, x
end
return r + m, g + m, b + m
end
orig_update(self, dt)
local ante = G.GAME.round_resets.ante
local blind = get_blind_amount((ante >= 1 and ante <= 8) and math.floor(ante) or ante)
G.P_BLINDS["bl_jane_wee"].mult = 22 / blind
G.P_BLINDS["bl_jane_descending"].mult = math.ceil(8 * math.sqrt(blind)) / blind
Jane.update_honey()
if not Jane.bans_done then
Jane.bans_done = true
delete_hardbans()
end
if (G.GAME or {}).banned_keys then
for _, v in pairs(Jane.config.bans) do for _, v in pairs(Jane.config.bans) do
G.GAME.banned_keys[v] = true self.GAME.banned_keys[v] = true
end end
end end
if G.ARGS.LOC_COLOURS then
local r, g, b = hsv(self.C.jane_RGB_HUE / 360, .5, 1)
self.C.jane_RGB[1] = r
self.C.jane_RGB[3] = g
self.C.jane_RGB[2] = b
self.C.jane_RGB_HUE = (self.C.jane_RGB_HUE + 0.5) % 360
G.ARGS.LOC_COLOURS.jane_RGB = self.C.jane_RGB
end
end end
local orig_draw_card = draw_card local orig_draw_card = draw_card
@ -350,6 +319,20 @@ function draw_card(a, b, c, d, e, f, ...)
end end
end end
local orig_reset_blinds = reset_blinds
---@diagnostic disable-next-line: lowercase-global
function reset_blinds(...)
orig_reset_blinds(...)
local ante = G.GAME.round_resets.ante
local blind = get_blind_amount((ante >= 1 and ante <= 8) and math.floor(ante) or ante)
G.P_BLINDS["bl_jane_wee"].mult = 22 / blind
G.P_BLINDS["bl_jane_descending"].mult = math.ceil(8 * math.sqrt(blind)) / blind
end
loc_colour()
G.ARGS.LOC_COLOURS.jane_RGB = G.C.jane_RGB
SMODS.Atlas { SMODS.Atlas {
px = 34, px = 34,
py = 34, py = 34,

View file

@ -181,7 +181,7 @@ SMODS.Joker {
}, },
} }
end, end,
update = function(_, card, _) draw = function(_, card)
if card.added_to_deck and card.children.center and card.children.floating_sprite then if card.added_to_deck and card.children.center and card.children.floating_sprite then
for k, v in ipairs(hunter) do for k, v in ipairs(hunter) do
if card.ability.extra.rounds_left <= v then if card.ability.extra.rounds_left <= v then
@ -626,10 +626,13 @@ SMODS.Joker {
}, },
} }
end, end,
update = function(_, card, _) draw = function(_, card)
local rgb = G.C.jane_RGB
rgb[1], rgb[2], rgb[3] = Jane.hsv(1 - (G.TIMERS.REAL / 3 % 1), math.sin(G.TIMERS.REAL) / 10 + 0.6, 1)
if card.edition and card.edition.Roland_frozen then if card.edition and card.edition.Roland_frozen then
card:set_edition("e_base") card:set_edition("e_base")
elseif card.children.floating_sprite then elseif card.config.center.key == "j_jane_saint" and card.children.floating_sprite then
card.children.floating_sprite:set_sprite_pos({x = card.ability.extra.is_attuned and 2 or 1, y = 0}) card.children.floating_sprite:set_sprite_pos({x = card.ability.extra.is_attuned and 2 or 1, y = 0})
end end
end, end,
@ -671,7 +674,7 @@ SMODS.Joker {
end, 1) end, 1)
Jane.q(function() Jane.q(function()
extra.karma = extra.karma + extra.jokers extra.karma = Jane.cry and extra.karma + extra.jokers or extra.jokers
G.jokers:change_size(extra.jokers) G.jokers:change_size(extra.jokers)
end, 1) end, 1)
end end
@ -726,7 +729,7 @@ SMODS.Joker {
return return
end end
G.jokers:change_size((extra.is_attuned and quota or extra.karma) * extra.jokers) G.jokers:change_size((extra.is_attuned and quota or (Jane.cry and extra.karma or 0)) * extra.jokers)
ascend() ascend()
end, end,
add_to_deck = function(_, card) add_to_deck = function(_, card)