Browse Source

Strategická: Zobrazování starších kol

master
Jiří Kalvoda 2 years ago
parent
commit
1bb59161d8
  1. 14
      server/hra/web/game.py

14
server/hra/web/game.py

@ -19,7 +19,7 @@ import hra.db as db
from hra.web import app from hra.web import app
import hra.web.jinja_mac as jinja_mac import hra.web.jinja_mac as jinja_mac
from hra.util import hash_passwd from hra.util import hash_passwd
from hra.web.pages import BasePage, web_game_view, right_for_team from hra.web.pages import BasePage, web_game_view, right_for_team, OptionalIntField
wlogic_by_mode = {} wlogic_by_mode = {}
@ -59,6 +59,8 @@ class OccupyViewConfig(FlaskForm):
status = RadioField("", choices=(status_minimalistic, status_left, status_up), default=status_minimalistic) status = RadioField("", choices=(status_minimalistic, status_left, status_up), default=status_minimalistic)
big_fields = BooleanField("Široká políčka (trojciferné počty)") big_fields = BooleanField("Široká políčka (trojciferné počty)")
round = OptionalIntField("Kolo k zobrazení")
submit = SubmitField("Refresh/Potvrdit") submit = SubmitField("Refresh/Potvrdit")
show_data_only = SubmitField("Zobrazit stránku pouze s daty") show_data_only = SubmitField("Zobrazit stránku pouze s daty")
@ -67,7 +69,15 @@ class Occupy(WLogic):
def view(self, state: db.State, team: Optional[db.Team], teams: List[db.Team]): def view(self, state: db.State, team: Optional[db.Team], teams: List[db.Team]):
meta_refresh_without_reaming = 15 meta_refresh_without_reaming = 15
conff = OccupyViewConfig(formdata=request.args, csrf_enabled=False)
conff.validate()
game = state.game game = state.game
if conff.round.data is not None:
state = db.get_session().query(db.State).filter_by(game_id=game.game_id, round=conff.round.data).one_or_none()
if state is None:
raise werkzeug.exceptions.NotFound("Zadané kolo neexisstuje")
team_id = team.team_id if team else None team_id = team.team_id if team else None
if game.step_mode == db.StepMode.automatic: if game.step_mode == db.StepMode.automatic:
time_reaming = (state.create_time - datetime.now()).total_seconds() + game.step_every_s time_reaming = (state.create_time - datetime.now()).total_seconds() + game.step_every_s
@ -76,9 +86,7 @@ class Occupy(WLogic):
s = state.get_state() s = state.get_state()
if team is not None: if team is not None:
s = self.logic.personalize_state(s, team.team_id, state.round) s = self.logic.personalize_state(s, team.team_id, state.round)
conff = OccupyViewConfig(formdata=request.args, csrf_enabled=False)
q = db.get_session().query(db.Log).order_by(db.Log.log_id.desc()) q = db.get_session().query(db.Log).order_by(db.Log.log_id.desc())
conff.validate()
moves = [] moves = []

Loading…
Cancel
Save