Archived
fix draw function being recursive
This commit is contained in:
+3
-5
@@ -71,7 +71,7 @@ class Player(Serializable):
|
|||||||
async def draw(self, amount: int):
|
async def draw(self, amount: int):
|
||||||
"""Draw a card from the stack. Handles stack rebuild from discard automatically"""
|
"""Draw a card from the stack. Handles stack rebuild from discard automatically"""
|
||||||
try:
|
try:
|
||||||
while amount <= 0:
|
while amount > 0:
|
||||||
if len(self.stack_pile) == 0:
|
if len(self.stack_pile) == 0:
|
||||||
if len(self.discard_pile) == 0:
|
if len(self.discard_pile) == 0:
|
||||||
raise RuntimeWarning("No more cards to draw !")
|
raise RuntimeWarning("No more cards to draw !")
|
||||||
@@ -79,8 +79,6 @@ class Player(Serializable):
|
|||||||
|
|
||||||
if len(self.stack_pile) > 0:
|
if len(self.stack_pile) > 0:
|
||||||
self.hand.append(self.stack_pile.pop())
|
self.hand.append(self.stack_pile.pop())
|
||||||
return self.draw(amount - 1)
|
amount = amount - 1
|
||||||
finally:
|
finally:
|
||||||
await self.team.notify_controller(
|
await self.team.notify_controller("update", self.serialize_team())
|
||||||
"update", {"uuid": self.uuid, "hand": self.serialize_team()["hand"]}
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user