diff --git a/obsazovani.md b/obsazovani.md index 0252fc2..a3df049 100644 --- a/obsazovani.md +++ b/obsazovani.md @@ -11,9 +11,10 @@ Parametry: - `main` - Hlavní hra - `test_{0,1,..}` Testovací hra daného uživatele (číslo je jako který tým hrají) - round_id: To zjistí z otazu na stav +- min_round: Validní odpovědi pouze pokud je tento nebo pozdější tah, jinak "too-early" Stav: -GET na `/api/state?game=&token=` +GET na `/api/state?game=&token=&min_round=` ```json { status: "ok" @@ -39,7 +40,7 @@ GET na `/api/state?game=&token=` nebo { - status: "working" # Server počítá následující stav, klient má počkat + status: "working" nebo "too-early" # Server počítá následující stav nebo je některý z předchozích tahů, klient má počkat wait: # Jak dlouho má klient čekat, než se zeptá znovu } ``` diff --git a/server/hra/web/api.py b/server/hra/web/api.py index 5059925..0fe506b 100644 --- a/server/hra/web/api.py +++ b/server/hra/web/api.py @@ -35,6 +35,12 @@ def api_state(): team = get_context() game = team.game team_id = team.team_id + min_round = args_get("min_round", int, True) + if min_round is not None and min_round > game.current_round: + return json.dumps({ + "status": "too-early", + "wait": 5.0, + }) state = game.current_state() if state is None: return json.dumps({