Skip to content

Commit 358d457

Browse files
committed
Added start_run to API
1 parent 8b3e478 commit 358d457

File tree

5 files changed

+58
-27
lines changed

5 files changed

+58
-27
lines changed

api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function BalatrobotAPI.update(dt)
4747
local _splitstring = { }
4848
local _j = 1
4949
for _str in _arg:gmatch('([^,]+)') do
50-
_splitstring[_j] = tonumber(_str)
50+
_splitstring[_j] = tonumber(_str) or _str
5151
_j = _j + 1
5252
end
5353
_actiontable[_i] = _splitstring

bot.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Bot.ACTIONS = {
2121
REARRANGE_CONSUMABLES = 16,
2222
REARRANGE_HAND = 17,
2323
PASS = 18,
24+
START_RUN = 19,
2425
}
2526

2627
Bot.ACTIONPARAMS = { }
@@ -96,6 +97,11 @@ Bot.ACTIONPARAMS[Bot.ACTIONS.PASS] = {
9697
num_args = 1,
9798
func = ""
9899
}
100+
Bot.ACTIONPARAMS[Bot.ACTIONS.START_RUN] = {
101+
num_args = 5,
102+
func = "start_run"
103+
}
104+
99105

100106
-- CHANGE ME
101107
Bot.SETTINGS = {
@@ -114,7 +120,7 @@ Bot.SETTINGS = {
114120
replay = false,
115121

116122
-- Receive commands from the API?
117-
api = true,
123+
api = false,
118124
}
119125

120126
--- Skips or selects the current blind
@@ -235,5 +241,9 @@ function Bot.rearrange_hand()
235241
--return Bot.ACTIONS.REARRANGE_HAND, { 2, 1, 3, 4, 5, 6, 7, 8 }
236242
end
237243

244+
function Bot.start_run()
245+
return Bot.ACTIONS.START_RUN, { Bot.SETTINGS.stake }, { Bot.SETTINGS.deck }, { Bot.SETTINGS.seed }, { Bot.SETTINGS.challenge }
246+
end
247+
238248

239249
return Bot

botlogger.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11

2-
-- WIP
3-
4-
--Bot = require('bot')
5-
--Hook = require('hook')
6-
72
Botlogger = { }
83
Botlogger.path = ''
94
Botlogger.filename = nil
@@ -105,6 +100,7 @@ function Botlogger.inithooks()
105100
Botlogger.q_use_or_sell_consumables = List.new()
106101
Botlogger.q_rearrange_consumables = List.new()
107102
Botlogger.q_rearrange_hand = List.new()
103+
Botlogger.q_start_run = List.new()
108104

109105
-- Hook bot functions
110106
if Bot.SETTINGS.replay == true or Bot.SETTINGS.api == true then

client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# WIP
3+
4+
import socket
5+
6+
if __name__ == "__main__":
7+
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
8+
client_socket.settimeout(1.0)
9+
10+
addr = ("127.0.0.1", 12345)
11+

middleware.lua

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -472,32 +472,46 @@ local function w_gamestate(...)
472472
local _t, _k, _v = ...
473473

474474
if _k == 'STATE' and _v == G.STATES.MENU then
475-
queueaction(function()
476-
local _play_button = G.MAIN_MENU_UI:get_UIE_by_ID('main_menu_play')
477-
G.FUNCS[_play_button.config.button]({
478-
config = { }
479-
})
480-
G.FUNCS.exit_overlay_menu()
481-
end)
482475

483-
queueaction(function()
484-
for k, v in pairs(G.P_CENTER_POOLS.Back) do
485-
if v.name == Bot.SETTINGS.deck then
486-
G.GAME.selected_back:change_to(v)
487-
G.GAME.viewed_back:change_to(v)
488-
end
476+
firewhenready(function()
477+
local _action, _stake, _deck, _seed, _challenge = Bot.start_run()
478+
_stake = _stake ~= nil and tonumber(_stake[1]) or 1
479+
_deck = _deck ~= nil and _deck[1] or "Red Deck"
480+
_seed = _seed ~= nil and _seed[1] or nil
481+
_challenge = _challenge ~= nil and _challenge[1] or nil
482+
if _action then
483+
return true, _action, _stake, _deck, _seed, _challenge
484+
else
485+
return false
489486
end
490-
491-
local _challenge = nil
492-
if Bot.SETTINGS.challenge and Bot.SETTINGS.challenge ~= '' then
487+
end,
488+
489+
function(_action, _stake, _deck, _seed, _challenge)
490+
491+
queueaction(function()
492+
local _play_button = G.MAIN_MENU_UI:get_UIE_by_ID('main_menu_play')
493+
G.FUNCS[_play_button.config.button]({
494+
config = { }
495+
})
496+
G.FUNCS.exit_overlay_menu()
497+
end)
498+
499+
queueaction(function()
500+
for k, v in pairs(G.P_CENTER_POOLS.Back) do
501+
if v.name == _deck then
502+
G.GAME.selected_back:change_to(v)
503+
G.GAME.viewed_back:change_to(v)
504+
end
505+
end
506+
493507
for i = 1, #G.CHALLENGES do
494-
if G.CHALLENGES[i].name == Bot.SETTINGS.challenge then
508+
if G.CHALLENGES[i].name == _challenge then
495509
_challenge = G.CHALLENGES[i]
496510
end
497511
end
498-
end
499-
G.FUNCS.start_run(nil, {stake = Bot.SETTINGS.stake, seed = Bot.SETTINGS.seed, challenge = _challenge})
500-
end, 1.0)
512+
G.FUNCS.start_run(nil, {stake = _stake, seed = _seed, challenge = _challenge})
513+
end, 1.0)
514+
end)
501515
end
502516
end
503517

0 commit comments

Comments
 (0)