Skip to content

Commit 5d63bf6

Browse files
authored
Merge pull request #289 from Balatro-Multiplayer/toneblock-fixes
Oracle fixes
2 parents fc3c2e6 + 963c083 commit 5d63bf6

File tree

2 files changed

+60
-41
lines changed

2 files changed

+60
-41
lines changed

lovely/decks.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[manifest]
2+
version = "1.0.0"
3+
dump_lua = true
4+
priority = 2147483600
5+
6+
# max
7+
[[patches]]
8+
[patches.pattern]
9+
target = 'functions/common_events.lua'
10+
pattern = '''G.GAME.dollars = G.GAME.dollars + mod'''
11+
position = 'before'
12+
payload = '''
13+
if G.GAME.modifiers.oracle_max then
14+
mod = oracle_apply_dollar_cap(mod, G.GAME.dollars, G.GAME.modifiers.oracle_max)
15+
if oracle_should_show_max(mod, G.GAME.dollars, G.GAME.modifiers.oracle_max) then
16+
text = "MAX"
17+
col = G.C.RED
18+
end
19+
end
20+
'''
21+
match_indent = true
22+
times = 1
23+
24+
# show max alert
25+
# janky since we check the text instead of a condition but hey easily fixed
26+
[[patches]]
27+
[patches.pattern]
28+
target = 'functions/common_events.lua'
29+
pattern = ''' attention_text({
30+
text = text..tostring(math.abs(mod)),'''
31+
position = 'before'
32+
payload = '''
33+
if text == "MAX" then
34+
oracle_show_max_alert(dollar_UI)
35+
return
36+
end
37+
'''
38+
match_indent = true
39+
times = 1

objects/decks/AA_oracle.lua

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
function oracle_apply_dollar_cap(mod, current_dollars, max_dollars)
2+
return math.min(max_dollars - current_dollars, mod)
3+
end
4+
5+
function oracle_should_show_max(mod, current_dollars, max_dollars)
6+
return mod == 0 and current_dollars >= max_dollars
7+
end
8+
9+
function oracle_show_max_alert(dollar_UI)
10+
attention_text({
11+
text = "MAX",
12+
scale = 0.8,
13+
hold = 0.7,
14+
cover = dollar_UI.parent,
15+
cover_colour = G.C.RED,
16+
align = "cm",
17+
})
18+
play_sound("timpani", 0.9, 0.7)
19+
play_sound("timpani", 1.2, 0.7)
20+
end
21+
122
SMODS.Back({
223
key = "oracle",
324
config = { vouchers = { "v_clearance_sale" }, consumables = { "c_medium" } },
@@ -8,44 +29,3 @@ SMODS.Back({
829
end,
930
mp_credits = { art = { "aura!", "Ganpan140" }, code = { "Toneblock" } },
1031
})
11-
12-
-- billionth create card hook ever
13-
local ease_dollars_ref = ease_dollars
14-
function ease_dollars(mod, instant)
15-
if G.GAME.modifiers.oracle_max then
16-
local lmod = (G.GAME.dollar_buffer or 0) > 0 and mod or 0 -- this whole thing is really uncomfortable but seems to work
17-
local dollars = G.GAME.dollars + ((G.GAME.dollar_buffer or 0) - lmod)
18-
if mod >= 0 and dollars >= G.GAME.modifiers.oracle_max then -- recreate the function for max anim
19-
local function _mod()
20-
local dollar_UI = G.HUD:get_UIE_by_ID("dollar_text_UI")
21-
dollar_UI.config.object:update()
22-
G.HUD:recalculate()
23-
attention_text({
24-
text = "MAX",
25-
scale = 0.8,
26-
hold = 0.7,
27-
cover = dollar_UI.parent,
28-
cover_colour = G.C.RED,
29-
align = "cm",
30-
})
31-
play_sound("timpani", 0.9, 0.7) -- timpani spam makes good sfx
32-
play_sound("timpani", 1.2, 0.7)
33-
end
34-
if instant then
35-
_mod()
36-
else
37-
G.E_MANAGER:add_event(Event({
38-
trigger = "immediate",
39-
func = function()
40-
_mod()
41-
return true
42-
end,
43-
}))
44-
end
45-
return
46-
else
47-
mod = math.min(mod, G.GAME.modifiers.oracle_max - dollars)
48-
end
49-
end
50-
return ease_dollars_ref(mod, instant)
51-
end

0 commit comments

Comments
 (0)