late Sunday update: netcode changes, bot improvements, bot development
This commit is contained in:
+10
-3
@@ -13,6 +13,7 @@ GAME_EXEC_ARG_PORT = '--port={0}'
|
||||
GAME_EXEC_ARG_ID = '--server-id={0}'
|
||||
GAME_EXEC_ARG_SECRET = '--secret={0}'
|
||||
GAME_EXEC_ARG_BOTS = '--bots={0}'
|
||||
GAME_EXEC_ARG_BOT_DIFFICULTY = '--bot-difficulty={0}'
|
||||
GAME_EXEC_ARG_SERVER_ADDR = '--server-addr={0}'
|
||||
GAME_EXEC_ARG_API_ADDR = '--api-addr={0}'
|
||||
|
||||
@@ -23,7 +24,7 @@ try:
|
||||
with sqlite3.connect("database.db") as con:
|
||||
cur = con.cursor()
|
||||
cur.execute(
|
||||
'CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, name TEXT, secret TEXT, ip TEXT, running INTEGER, port INTEGER, player_count INTEGER, bots INTEGER)')
|
||||
'CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, name TEXT, secret TEXT, ip TEXT, running INTEGER, port INTEGER, player_count INTEGER, bots INTEGER, bot_difficulty REAL)')
|
||||
con.commit()
|
||||
except:
|
||||
con.rollback()
|
||||
@@ -42,10 +43,14 @@ def create_game():
|
||||
abort(400)
|
||||
|
||||
bots = False
|
||||
bot_difficulty = -1
|
||||
name = request.json.get('name')
|
||||
if 'bots' in request.json:
|
||||
bots = request.json.get('bots')
|
||||
|
||||
if 'bot-difficulty' in request.json:
|
||||
bot_difficulty = request.json.get('bot-difficulty')
|
||||
|
||||
game_count = 0
|
||||
try:
|
||||
with sqlite3.connect("database.db") as con:
|
||||
@@ -81,8 +86,8 @@ def create_game():
|
||||
remote_addr = request.headers.getlist(
|
||||
"X-Forwarded-For")[0].rpartition(' ')[-1]
|
||||
|
||||
cur.execute("INSERT INTO games (name,secret,ip,port,bots,player_count,running) VALUES (?,?,?,?,?,0,0)",
|
||||
(name, secret, remote_addr, port, bots))
|
||||
cur.execute("INSERT INTO games (name,secret,ip,port,bots,bot-difficulty,player_count,running) VALUES (?,?,?,?,?,0,0)",
|
||||
(name, secret, remote_addr, port, bots, bot_difficulty))
|
||||
con.commit()
|
||||
cur.execute("SELECT id FROM games WHERE secret=?",
|
||||
(secret,))
|
||||
@@ -98,6 +103,8 @@ def create_game():
|
||||
secret),
|
||||
GAME_EXEC_ARG_BOTS.format(
|
||||
int(bots)),
|
||||
GAME_EXEC_ARG_BOT_DIFFICULTY.format(
|
||||
float(bot_difficulty)),
|
||||
GAME_EXEC_ARG_SERVER_ADDR.format(
|
||||
'127.0.0.1'), # localhost
|
||||
GAME_EXEC_ARG_API_ADDR.format('http://127.0.0.1:5000/')])
|
||||
|
||||
Reference in New Issue
Block a user