|
@ -13,6 +13,7 @@ import sys |
|
|
parser = argparse.ArgumentParser() |
|
|
parser = argparse.ArgumentParser() |
|
|
parser.add_argument("game_id") |
|
|
parser.add_argument("game_id") |
|
|
parser.add_argument("--step", action="store_true") |
|
|
parser.add_argument("--step", action="store_true") |
|
|
|
|
|
parser.add_argument("--born-per-round", nargs="+", type=int) |
|
|
parser.add_argument("--restore", action="store_true") |
|
|
parser.add_argument("--restore", action="store_true") |
|
|
parser.add_argument("--set-step-mode", type=str) |
|
|
parser.add_argument("--set-step-mode", type=str) |
|
|
parser.add_argument("--set-step-s", type=int) |
|
|
parser.add_argument("--set-step-s", type=int) |
|
@ -26,16 +27,6 @@ game_id = args.game_id |
|
|
game = ses.query(db.Game).filter_by(game_id=game_id).one_or_none() |
|
|
game = ses.query(db.Game).filter_by(game_id=game_id).one_or_none() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.set_step_mode: |
|
|
|
|
|
game.step_mode = db.StepMode(args.set_step_mode) |
|
|
|
|
|
ses.commit() |
|
|
|
|
|
if args.set_step_s: |
|
|
|
|
|
game.step_every_s = db.StepMode(args.set_step_s) |
|
|
|
|
|
ses.commit() |
|
|
|
|
|
if args.restore: |
|
|
|
|
|
lib.game_restore_broken(args.game_id) |
|
|
|
|
|
if args.step: |
|
|
|
|
|
lib.game_step(args.game_id) |
|
|
|
|
|
if args.autosteps: |
|
|
if args.autosteps: |
|
|
while True: |
|
|
while True: |
|
|
def sleep(timeout=1): |
|
|
def sleep(timeout=1): |
|
@ -67,3 +58,22 @@ if args.autosteps: |
|
|
step_in = game.step_every_s - diff |
|
|
step_in = game.step_every_s - diff |
|
|
print(f"Step in {step_in:.2f} s (every {game.step_every_s})") |
|
|
print(f"Step in {step_in:.2f} s (every {game.step_every_s})") |
|
|
sleep(step_in) |
|
|
sleep(step_in) |
|
|
|
|
|
else: |
|
|
|
|
|
game.lock() |
|
|
|
|
|
if args.born_per_round: |
|
|
|
|
|
print(args.born_per_round) |
|
|
|
|
|
c = game.get_configuration() |
|
|
|
|
|
c["born_per_round"] = args.born_per_round |
|
|
|
|
|
game.configuration = db.new_big_data(c) |
|
|
|
|
|
ses.commit() |
|
|
|
|
|
print(game.get_configuration()) |
|
|
|
|
|
if args.set_step_mode: |
|
|
|
|
|
game.step_mode = db.StepMode(args.set_step_mode) |
|
|
|
|
|
ses.commit() |
|
|
|
|
|
if args.set_step_s: |
|
|
|
|
|
game.step_every_s = db.StepMode(args.set_step_s) |
|
|
|
|
|
ses.commit() |
|
|
|
|
|
if args.restore: |
|
|
|
|
|
lib.game_restore_broken(args.game_id) |
|
|
|
|
|
if args.step: |
|
|
|
|
|
lib.game_step(args.game_id) |
|
|