Startegická: Zobrazení a editace konfigurace
This commit is contained in:
parent
518879428e
commit
fbf85454b5
2 changed files with 24 additions and 10 deletions
|
@ -13,6 +13,7 @@ import sys
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("game_id")
|
||||
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("--set-step-mode", type=str)
|
||||
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()
|
||||
|
||||
|
||||
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:
|
||||
while True:
|
||||
def sleep(timeout=1):
|
||||
|
@ -67,3 +58,22 @@ if args.autosteps:
|
|||
step_in = game.step_every_s - diff
|
||||
print(f"Step in {step_in:.2f} s (every {game.step_every_s})")
|
||||
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)
|
||||
|
|
|
@ -10,6 +10,7 @@ import werkzeug.exceptions
|
|||
import wtforms
|
||||
from wtforms.fields import EmailField
|
||||
from wtforms.widgets import NumberInput
|
||||
import pprint
|
||||
|
||||
import hra.config as config
|
||||
import hra.web.html as html
|
||||
|
@ -268,6 +269,9 @@ def web_game(game_id):
|
|||
with b.form(method="POST", _class="btn-group", action=app.url_for(web_game_step.__name__, game_id=game_id)):
|
||||
b.button(_class="btn btn-primary", type="submit", name="su", value="yes")("Krok")
|
||||
|
||||
if g.org:
|
||||
b.h3("Aktuální konfigurace")
|
||||
b.p().pre(pprint.pformat(game.get_configuration()))
|
||||
return b.print_file()
|
||||
|
||||
@app.route("/game/<int:game_id>/step", methods=['POST'])
|
||||
|
|
Loading…
Reference in a new issue