Avoid all uses of update functions
This commit is contained in:
parent
656be9aa38
commit
1e4920143b
6 changed files with 75 additions and 82 deletions
|
|
@ -16,9 +16,7 @@ match_indent = true
|
|||
target = "globals.lua"
|
||||
pattern = "EDITION = {1,1,1,1},"
|
||||
position = "before"
|
||||
payload = '''jane_RGB = {0,0,0,1},
|
||||
jane_RGB_HUE = 0,
|
||||
almighty = {0,0,1,1},'''
|
||||
payload = "jane_RGB = {1,1,1,1},"
|
||||
match_indent = true
|
||||
|
||||
[[patches]]
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@
|
|||
"conflicts": [
|
||||
"Jen"
|
||||
],
|
||||
"version": "1.11.22"
|
||||
"version": "1.11.23"
|
||||
}
|
||||
|
|
@ -217,12 +217,15 @@ SMODS.Edition({
|
|||
loc_vars = function(self, _, _)
|
||||
return {vars = {self.config.e_chips, self.config.e_mult}}
|
||||
end,
|
||||
draw = function()
|
||||
G.P_CENTERS.j_jane_saint:draw()
|
||||
end,
|
||||
calculate = function(self, card, context)
|
||||
return (
|
||||
context.post_joker or
|
||||
context.main_scoring and
|
||||
context.cardarea == G.play
|
||||
) and {
|
||||
if not context.post_joker and (not context.main_scoring or context.cardarea ~= G.play) then
|
||||
return
|
||||
end
|
||||
|
||||
return {
|
||||
extra = {
|
||||
card = card,
|
||||
colour = G.C.jane_RGB,
|
||||
|
|
@ -233,6 +236,6 @@ SMODS.Edition({
|
|||
e_mult = self.config.e_mult,
|
||||
},
|
||||
},
|
||||
} or nil
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ SMODS.Joker {
|
|||
|
||||
function Jane.update_honey()
|
||||
if not G.GAME then
|
||||
return
|
||||
return true
|
||||
end
|
||||
|
||||
local honey = SMODS.find_card("j_jane_honey")
|
||||
|
|
@ -393,8 +393,11 @@ SMODS.Joker {
|
|||
},
|
||||
}
|
||||
end,
|
||||
update = function(_, card, _)
|
||||
if card.added_to_deck and card.children.center and card.children.floating_sprite then
|
||||
draw = function(_, card)
|
||||
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 y = (tonumber(extra.level) or 1) > 1 and 1 or 0
|
||||
card.children.center:set_sprite_pos({x = 0, y = y})
|
||||
|
|
@ -528,7 +531,7 @@ SMODS.Joker {
|
|||
},
|
||||
}
|
||||
end,
|
||||
update = function(_, card, _)
|
||||
draw = function(_, card)
|
||||
if card.added_to_deck and card.children.center and card.children.floating_sprite then
|
||||
local extra = card.ability.extra or {}
|
||||
local y = extra.is_corrupted and 1 or 0
|
||||
|
|
@ -658,6 +661,9 @@ SMODS.Joker {
|
|||
remove_from_deck = function(_, card, _)
|
||||
grand_dad(card)
|
||||
end,
|
||||
draw = function()
|
||||
G.P_CENTERS.j_jane_saint:draw()
|
||||
end,
|
||||
calculate = function(_, card, context)
|
||||
if context.cardarea ~= G.play or
|
||||
not context.individual or
|
||||
|
|
|
|||
111
src/main.lua
111
src/main.lua
|
|
@ -155,6 +155,33 @@ function Jane.hidden(card)
|
|||
(type(card) == "table" and (card.name == "Black Hole" or card.name == "The Soul") or card.hidden)
|
||||
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)
|
||||
return not context.individual and not
|
||||
context.repetition and not
|
||||
|
|
@ -271,74 +298,16 @@ function Game:main_menu(change_context)
|
|||
orig_menu(self, change_context)
|
||||
end
|
||||
|
||||
local orig_update = Game.update
|
||||
local orig_start_run = Game.start_run
|
||||
|
||||
function Game:update(dt)
|
||||
local function delete_hardbans()
|
||||
if not Jane.config.disable_bans then
|
||||
function Game:start_run(...)
|
||||
orig_start_run(self, ...)
|
||||
|
||||
if self.GAME.banned_keys then
|
||||
for _, v in pairs(Jane.config.bans) do
|
||||
local e = SMODS.Center:get_obj(v)
|
||||
|
||||
if e then
|
||||
e:delete()
|
||||
self.GAME.banned_keys[v] = true
|
||||
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
|
||||
G.GAME.banned_keys[v] = true
|
||||
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
|
||||
|
||||
local orig_draw_card = draw_card
|
||||
|
|
@ -350,6 +319,20 @@ function draw_card(a, b, c, d, e, f, ...)
|
|||
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 {
|
||||
px = 34,
|
||||
py = 34,
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ SMODS.Joker {
|
|||
},
|
||||
}
|
||||
end,
|
||||
update = function(_, card, _)
|
||||
draw = function(_, card)
|
||||
if card.added_to_deck and card.children.center and card.children.floating_sprite then
|
||||
for k, v in ipairs(hunter) do
|
||||
if card.ability.extra.rounds_left <= v then
|
||||
|
|
@ -626,10 +626,13 @@ SMODS.Joker {
|
|||
},
|
||||
}
|
||||
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
|
||||
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})
|
||||
end
|
||||
end,
|
||||
|
|
@ -671,7 +674,7 @@ SMODS.Joker {
|
|||
end, 1)
|
||||
|
||||
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)
|
||||
end, 1)
|
||||
end
|
||||
|
|
@ -726,7 +729,7 @@ SMODS.Joker {
|
|||
return
|
||||
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()
|
||||
end,
|
||||
add_to_deck = function(_, card)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue