Browse Source

Strategická: Načtení kopců z configu

master
David Klement 2 years ago
parent
commit
811280a8b2
  1. 33
      server/bin/create_game
  2. 10
      server/hra/game.py

33
server/bin/create_game

@ -15,6 +15,39 @@ configuration = {
"teams_height": 4, "teams_height": 4,
"width_per_team": 30, "width_per_team": 30,
"height_per_team": 30, "height_per_team": 30,
# seed=5
"hills": [
".xx....x......................",
".xxx...xx.....................",
"...x...............x......x...",
".......xx..........xx.........",
".......xx.....................",
".......x......................",
"..............................",
".............xxx......xx......",
".............xx.......xx......",
"......................xx......",
"...xx....x............x.......",
"...xx....xx...................",
"..............................",
"......x.......................",
".....x........................",
".x............................",
".x.....................x......",
".x....................xx......",
"......................xx......",
"..xx...................x......",
".xxx..........................",
"..............................",
"............xxx......xx.......",
"............xx.......xx.......",
".......................x......",
".....x........x........x......",
"..............xxx........x....",
"..............................",
".............x................",
"............xx................"
]
} }
g = db.Game(game_mode=mode, configuration=configuration, teams_count=teams_count) g = db.Game(game_mode=mode, configuration=configuration, teams_count=teams_count)

10
server/hra/game.py

@ -52,18 +52,20 @@ class Occupy(Logic):
# Počáteční stav # Počáteční stav
def zero_state(self) -> Any: def zero_state(self) -> Any:
# TODO: Zatím negeneruju "hills"
map = [ map = [
[ [
{ {
"home_for_team": None, "home_for_team": None,
"occupied_by_team": None, "occupied_by_team": None,
"hill": False, "hill": (self.configuration["hills"]
[j % self.configuration["height_per_team"]]
[i % self.configuration["width_per_team"]]
== "x"),
"members": [] "members": []
} }
for _ in range(self.map_width) for i in range(self.map_width)
] ]
for _ in range(self.map_height) for j in range(self.map_height)
] ]
team_id = 0 team_id = 0
home_y = self.configuration["height_per_team"] // 2 home_y = self.configuration["height_per_team"] // 2

Loading…
Cancel
Save