-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbalatrobot.lua
More file actions
80 lines (71 loc) · 2.39 KB
/
balatrobot.lua
File metadata and controls
80 lines (71 loc) · 2.39 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
-- Load required files
assert(SMODS.load_file("src/lua/settings.lua"))() -- define BB_SETTINGS
-- Configure Balatro with appropriate settings from environment variables
BB_SETTINGS.setup()
-- Endpoints for the BalatroBot API
BB_ENDPOINTS = {
-- Health endpoint
"src/lua/endpoints/health.lua",
-- Gamestate endpoints
"src/lua/endpoints/gamestate.lua",
-- Save/load endpoints
"src/lua/endpoints/save.lua",
"src/lua/endpoints/load.lua",
-- Screenshot endpoint
"src/lua/endpoints/screenshot.lua",
-- Game control endpoints
"src/lua/endpoints/set.lua",
"src/lua/endpoints/add.lua",
-- Gameplay endpoints
"src/lua/endpoints/menu.lua",
"src/lua/endpoints/start.lua",
-- Blind selection endpoints
"src/lua/endpoints/skip.lua",
"src/lua/endpoints/select.lua",
-- Play/discard endpoints
"src/lua/endpoints/play.lua",
"src/lua/endpoints/discard.lua",
-- Cash out endpoint
"src/lua/endpoints/cash_out.lua",
-- Shop endpoints
"src/lua/endpoints/next_round.lua",
"src/lua/endpoints/reroll.lua",
"src/lua/endpoints/buy.lua",
"src/lua/endpoints/pack.lua",
-- Rearrange endpoint
"src/lua/endpoints/rearrange.lua",
-- Sell endpoint
"src/lua/endpoints/sell.lua",
-- Use consumable endpoint
"src/lua/endpoints/use.lua",
-- If debug mode is enabled, debugger.lua will load test endpoints
}
-- Enable debug mode
if BB_SETTINGS.debug then
assert(SMODS.load_file("src/lua/utils/debugger.lua"))() -- define BB_DEBUG
BB_DEBUG.setup()
end
-- Load core modules
assert(SMODS.load_file("src/lua/core/server.lua"))() -- define BB_SERVER
assert(SMODS.load_file("src/lua/core/dispatcher.lua"))() -- define BB_DISPATCHER
-- Load gamestate and errors utilities
BB_GAMESTATE = assert(SMODS.load_file("src/lua/utils/gamestate.lua"))()
assert(SMODS.load_file("src/lua/utils/errors.lua"))()
-- Initialize Server
local server_success = BB_SERVER.init()
if not server_success then
return
end
local dispatcher_ok = BB_DISPATCHER.init(BB_SERVER, BB_ENDPOINTS)
if not dispatcher_ok then
return
end
-- Hook into love.update to run server update loop and detect GAME_OVER
local love_update = love.update
love.update = function(dt) ---@diagnostic disable-line: duplicate-set-field
-- Check for GAME_OVER before game logic runs
BB_GAMESTATE.check_game_over()
love_update(dt)
BB_SERVER.update(BB_DISPATCHER)
end
sendInfoMessage("BalatroBot loaded - version " .. SMODS.current_mod.version, "BB.BALATROBOT")