|
|
@ -10,7 +10,7 @@ import werkzeug.exceptions |
|
|
|
import wtforms |
|
|
|
from wtforms.fields import EmailField |
|
|
|
from wtforms.widgets import NumberInput |
|
|
|
from typing import Optional, Any |
|
|
|
from typing import Optional, Any, List |
|
|
|
|
|
|
|
import hra.config as config |
|
|
|
import hra.web.html as html |
|
|
@ -42,12 +42,13 @@ class WLogic: |
|
|
|
|
|
|
|
@add_wlogic |
|
|
|
class Occupy(WLogic): |
|
|
|
def view(self, state: db.State, team: Optional[db.Team]): |
|
|
|
def view(self, state: db.State, team: Optional[db.Team], teams: List[db.Team]): |
|
|
|
s = state.get_state() |
|
|
|
if team is not None: |
|
|
|
s = self.logic.personalize_state(s, team.team_id, state.round) |
|
|
|
b = BasePage() |
|
|
|
b.h2(f"Hra {self.game.print()} kolo {state.round}") |
|
|
|
b.p().b(_class=f"game_team_{team.team_id}")(f"Pohled týmu {team.print()}") |
|
|
|
with b.table(_class="game_table"): |
|
|
|
for i, row in enumerate(s["map"]): |
|
|
|
with b.tr(): |
|
|
@ -58,6 +59,8 @@ class Occupy(WLogic): |
|
|
|
with b.td(): |
|
|
|
classes = [] |
|
|
|
with b.a(href=f"#cell_{i}_{j}"): |
|
|
|
if x["protected_for_team"] is not None: |
|
|
|
classes.append("game_protected") |
|
|
|
if x["hill"]: |
|
|
|
classes.append("game_hill") |
|
|
|
b(Markup(" ")) |
|
|
@ -76,6 +79,7 @@ class Occupy(WLogic): |
|
|
|
for i, row in enumerate(s["map"]): |
|
|
|
for j, x in enumerate(row): |
|
|
|
occupied_by_team = x["occupied_by_team"] |
|
|
|
protected_for_team = x["protected_for_team"] |
|
|
|
home_for_team = x["home_for_team"] |
|
|
|
members = x["members"] |
|
|
|
with b.div(id=f"cell_{i}_{j}", _class="game_tab"): |
|
|
@ -84,13 +88,15 @@ class Occupy(WLogic): |
|
|
|
b.p().b("Pohoří") |
|
|
|
else: |
|
|
|
if occupied_by_team is not None: |
|
|
|
b.p(_class=f"game_team_{occupied_by_team}").b(f"Obsazeno týmem: {occupied_by_team}") |
|
|
|
b.p(_class=f"game_team_{occupied_by_team}").b(f"Obsazeno týmem: {teams[occupied_by_team].print()}") |
|
|
|
if protected_for_team is not None: |
|
|
|
b.p(_class=f"game_team_{protected_for_team}").b(f"Ochranné území týmu: {teams[protected_for_team].print()}") |
|
|
|
if home_for_team is not None: |
|
|
|
b.p(_class=f"game_team_{home_for_team}").b(f"Domov týmu: {home_for_team}") |
|
|
|
b.p(_class=f"game_team_{home_for_team}").b(f"Domov týmu: {teams[home_for_team].print()}") |
|
|
|
b.p().b(f"Počet osob: {len(members)}") |
|
|
|
with b.ul(): |
|
|
|
for m in members: |
|
|
|
b.li(_class=f"game_team_{home_for_team}")(f"Voják {m['id']} týmu {m['team']}") |
|
|
|
b.li(_class=f"game_team_{home_for_team}")(f"Voják {m['id']} týmu {teams[m['team']].print()}") |
|
|
|
|
|
|
|
|
|
|
|
b.wrap( |
|
|
|