From fbf85454b5ef54300e424ec70f919558e475222c Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda Date: Wed, 14 Sep 2022 19:12:16 +0200 Subject: [PATCH] =?UTF-8?q?Startegick=C3=A1:=20Zobrazen=C3=AD=20a=20editac?= =?UTF-8?q?e=20konfigurace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/control_game | 30 ++++++++++++++++++++---------- server/hra/web/pages.py | 4 ++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/server/bin/control_game b/server/bin/control_game index 5231ff0..a282107 100755 --- a/server/bin/control_game +++ b/server/bin/control_game @@ -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) diff --git a/server/hra/web/pages.py b/server/hra/web/pages.py index ea01171..df56787 100644 --- a/server/hra/web/pages.py +++ b/server/hra/web/pages.py @@ -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//step", methods=['POST'])