Repository navigation
Expand file tree
/
Copy pathmain.lua
More file actions
133 lines (122 loc) · 4.52 KB
/
Copy pathmain.lua
File metadata and controls
133 lines (122 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
SMODS.current_mod.optional_features = function()
return {
retrigger_joker = true, -- Quantum edition, retrigger joker one time
quantum_enhancements = true, -- Hybrid deck, allow cards to hold two enhancements
}
end
SMODS.current_mod.calculate = function(self, context)
if context.check_enhancement and context.other_card and context.other_card.ability then
local second = context.other_card.ability.losted_second_enh
if second and G.P_CENTERS[second] then
return { [second] = true }
end
end
if context.debuff_card and G.GAME and G.GAME.blind and G.GAME.blind.debuff
and G.GAME.blind.debuff.suit and SMODS.has_enhancement(context.debuff_card, 'm_wild') then
return { prevent_debuff = true }
end
end
-- Main table for the mod
LOSTEDMOD = {
debug = false,
vars = {
the_joker_triggered = false,
},
funcs = {}
}
-- Default config (SMODS.current_mod.config loaded from config.lua)
LOSTEDMOD.config = SMODS.current_mod.config or {}
-- Debugging functions
function sendDebugMessage(msg)
if LOSTEDMOD.debug then
print("[Lost Edition DEBUG] " .. tostring(msg))
end
end
function sendErrorMessage(msg)
print("[Lost Edition ERROR] " .. tostring(msg))
end
-- List of modules to be loaded
local includes = {
'utilities',
'assets',
'compat',
'hooks/game',
'hooks/overrides',
'hooks/pow_mult',
'hooks/intro',
'themes',
'items',
'hooks/ui_definitions',
'sleeves',
}
-- Load modules
for _, include in ipairs(includes) do
local success, error_msg = pcall(function()
local init, error = SMODS.load_file("includes/" .. include .. ".lua")
if error then
sendErrorMessage("Failed to load " .. include .. " with error: " .. error)
else
if init then init() end
sendDebugMessage("Loaded module: " .. include)
end
end)
if not success then
sendErrorMessage("Error in module " .. include .. ": " .. error_msg)
end
end
-- JokerDisplay compatibility (loaded AFTER items so definitions aren't overwritten by inline joker_display_def)
if JokerDisplay then
sendDebugMessage("JokerDisplay object found, loading compat...")
if JokerDisplay.Definitions then
sendDebugMessage("JokerDisplay.Definitions exists with " .. tostring((function() local c=0; for _ in pairs(JokerDisplay.Definitions) do c=c+1 end; return c end)()) .. " entries")
else
sendErrorMessage("JokerDisplay.Definitions is nil!")
end
local jd_init, jd_error = SMODS.load_file("includes/joker_display.lua")
if jd_error then
sendErrorMessage("Failed to load JokerDisplay compat: " .. jd_error)
elseif jd_init then
local ok, err = pcall(jd_init)
if ok then
sendDebugMessage("JokerDisplay compat loaded OK")
else
sendErrorMessage("Error executing JokerDisplay compat: " .. tostring(err))
end
else
sendErrorMessage("JokerDisplay compat file returned nil")
end
if JokerDisplay.Definitions then
sendDebugMessage("After load: JokerDisplay.Definitions has " .. tostring((function() local c=0; for _ in pairs(JokerDisplay.Definitions) do c=c+1 end; return c end)()) .. " entries")
end
end
if not G.SETTINGS.music_selection then
G.SETTINGS.music_selection = "losted"
end
G.FUNCS.change_music = function(args)
G.ARGS.music_vals = G.ARGS.music_vals or { "losted", "balatro" }
G.SETTINGS.QUEUED_CHANGE.music_change = G.ARGS.music_vals[args.to_key]
G.SETTINGS.music_selection = G.ARGS.music_vals[args.to_key]
G:save_settings()
end
-- Reset jokers on run start
function SMODS.current_mod.reset_game_globals(run_start)
if G.GAME.current_round then
G.GAME.current_round.losted_most_common_rank = nil
G.GAME.current_round.losted_most_common_rank_cached = nil
G.GAME.current_round.losted_most_common_rank_hand = nil
G.GAME.current_round.losted_all_in_hands_set = nil
end
LOSTEDMOD.vars.active_welder = nil
LOSTEDMOD.vars.active_welder_cache_dirty = true
if run_start then
LOSTEDMOD.quantum_context_queue_count = 0
LOSTEDMOD.has_quantum_context_queue = false
G.GAME.losted_mysterious_completed = false
G.GAME.losted_the_joker_triggered = false
LOSTEDMOD.vars.the_joker_triggered = false
LOSTEDMOD.funcs.reset_losted_sarcophagus()
LOSTEDMOD.funcs.reset_losted_sticky()
end
LOSTEDMOD.funcs.reset_losted_obsidian_card()
LOSTEDMOD.funcs.reset_losted_moist_cake()
end