fix draw function being recursive

This commit is contained in:
2024-04-04 21:46:16 +02:00
parent e2df8a7d5d
commit 55f61928ea
+3 -5
View File
@@ -71,7 +71,7 @@ class Player(Serializable):
async def draw(self, amount: int):
"""Draw a card from the stack. Handles stack rebuild from discard automatically"""
try:
while amount <= 0:
while amount > 0:
if len(self.stack_pile) == 0:
if len(self.discard_pile) == 0:
raise RuntimeWarning("No more cards to draw !")
@@ -79,8 +79,6 @@ class Player(Serializable):
if len(self.stack_pile) > 0:
self.hand.append(self.stack_pile.pop())
return self.draw(amount - 1)
amount = amount - 1
finally:
await self.team.notify_controller(
"update", {"uuid": self.uuid, "hand": self.serialize_team()["hand"]}
)
await self.team.notify_controller("update", self.serialize_team())