From 18e8a10088f8084b1fc2e0ac912458da26e132bf Mon Sep 17 00:00:00 2001 From: Nathanael Lu Date: Mon, 11 Mar 2024 20:46:28 -0400 Subject: [PATCH] added elixir cost for template --- clash_royale/envs/game_engine/card.py | 3 ++- clash_royale/envs/game_engine/player.py | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/clash_royale/envs/game_engine/card.py b/clash_royale/envs/game_engine/card.py index 82e744e..cc7d5d6 100644 --- a/clash_royale/envs/game_engine/card.py +++ b/clash_royale/envs/game_engine/card.py @@ -5,6 +5,7 @@ class Card(): This class is created for Player class to refer to statistics of cards. ''' - def __init__(self, elixir: int) -> None: + def __init__(self, elixir: int, elixir_cost: int) -> None: self.elixir: int = elixir + self.elixir_cost: int = elixir_cost pass diff --git a/clash_royale/envs/game_engine/player.py b/clash_royale/envs/game_engine/player.py index 5bc54a0..4e93872 100644 --- a/clash_royale/envs/game_engine/player.py +++ b/clash_royale/envs/game_engine/player.py @@ -76,19 +76,17 @@ def pop(self, card_index: int) -> None: self.deck.put(self.hand[card_index], block = False) self.hand[card_index] = self.next - self.next: Card = self.deck.get(block = False) - + self.next = self.deck.get(block = False) def play_card(self, card_index: int) -> None: """ - - Called with the index of cards in hand to update the state of available cards, next cards, and elixir. + Called with the index of cards in hand to update the state of + available cards, next cards, and elixir. Should be called with the initial rendering of entity. - """ - assert(card_index < 4) + assert card_index >= 0 and card_index < 4 elixir_cost: float = self.hand[card_index].elixir_cost assert(elixir_cost <= self.elixir) self.pop(card_index)