Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknugent1529 committed Mar 24, 2024
1 parent b105d67 commit 9ce51ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def serialize_board(board:Board, playerid:int) -> List[List[Tuple[int, str, int]
# visible = True
if not visible:
owner = -1
if type == NEUTRAL:
troops = 0
# if type == NEUTRAL:
troops = 0
next_row.append((owner, type, troops))
ret.append(next_row)
return ret
Expand Down
9 changes: 7 additions & 2 deletions game/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def increment_troops(self, all:bool=False) -> Tuple[int, int]:
conquered = self.conquered_cities
if True or all:
conquered += self.conquered_land
print(conquered)
conquered = list(set(conquered))
print(conquered)
for city in conquered:
r, c = city
if self.board[r][c].type == NEUTRAL and not all:
Expand Down Expand Up @@ -225,7 +228,8 @@ def move(self, move:Move) -> MoveResult:
self.board[r][c].owner = move.player
self.board[r][c].troops = troops_to_move
gained_land = True
self.conquered_land.append((r, c))
if (r,c) not in self.conquered_land:
self.conquered_land.append((r, c))
self.make_visible(move.player, r, c)
print("player: move.player")

Expand All @@ -236,7 +240,8 @@ def move(self, move:Move) -> MoveResult:
self.board[r][c].owner = move.player
self.board[r][c].troops = troops_to_move - self.board[r][c].troops
gained_land = True
self.conquered_cities.append((r, c))
if (r,c) not in self.conquered_cities:
self.conquered_cities.append((r, c))
self.make_visible(move.player, r, c)
else:
self.board[r][c].troops -= troops_to_move
Expand Down
2 changes: 1 addition & 1 deletion game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update(self):
# Every turn, increment city troops
# Every 25 turns, increment the round (all troops)
self.turn += 1
p1_increment, p2_increment = self.board.increment_troops((self.turn % 25 == 0))
p1_increment, p2_increment = self.board.increment_troops((self.turn % 25) == 0)
self.p1.army += p1_increment
self.p2.army += p2_increment

Expand Down

0 comments on commit 9ce51ef

Please sign in to comment.