Browse Source

Strategická: Protected bude také v API

master
Jiří Kalvoda 2 years ago
parent
commit
d07354c2c5
  1. 1
      obsazovani.md
  2. 4
      server/hra/game.py

1
obsazovani.md

@ -36,6 +36,7 @@ GET na `/api/state?game=<jmeno_hry>&token=<token>&min_round=<min_round>`
map: [[{ map: [[{
home_for_team: <Optional[int]> home_for_team: <Optional[int]>
occupied_by_team: <Optional[int]> occupied_by_team: <Optional[int]>
protected_for_team: <Optional[int]>
hill: <bool> hill: <bool>
members: [{ members: [{
type: "soldier" # Pro budoucí rozšiřování type: "soldier" # Pro budoucí rozšiřování

4
server/hra/game.py

@ -70,6 +70,7 @@ class Occupy(Logic):
{ {
"home_for_team": None, "home_for_team": None,
"occupied_by_team": None, "occupied_by_team": None,
"protected_for_team": None,
"hill": (self.configuration["hills"] "hill": (self.configuration["hills"]
[j % self.configuration["height_per_team"]] [j % self.configuration["height_per_team"]]
[i % self.configuration["width_per_team"]] [i % self.configuration["width_per_team"]]
@ -87,6 +88,8 @@ class Occupy(Logic):
for _ in range(self.teams_width): for _ in range(self.teams_width):
map[home_y][home_x]["home_for_team"] = team_id map[home_y][home_x]["home_for_team"] = team_id
map[home_y][home_x]["occupied_by_team"] = team_id map[home_y][home_x]["occupied_by_team"] = team_id
for x, y in self.PROTECTED_AREA:
map[(home_y+y) % self.map_height][(home_x+x) % self.map_width]["protected_for_team"] = team_id
# Initial stav vojáků: # Initial stav vojáků:
for soldier_id in range(max(1, self.budget_for_round(0) // self.spawn_price)): for soldier_id in range(max(1, self.budget_for_round(0) // self.spawn_price)):
map[home_y][home_x]["members"].append(self.generate_soldier(team_id, soldier_id)) map[home_y][home_x]["members"].append(self.generate_soldier(team_id, soldier_id))
@ -206,6 +209,7 @@ class Occupy(Logic):
for field in row: for field in row:
new_field = { new_field = {
"home_for_team": field["home_for_team"], "home_for_team": field["home_for_team"],
"protected_for_team": field["protected_for_team"],
"occupied_by_team": field["occupied_by_team"], "occupied_by_team": field["occupied_by_team"],
"hill": field["hill"], "hill": field["hill"],
"members": [] "members": []

Loading…
Cancel
Save