Small fixes for playtesting

This commit is contained in:
2024-04-26 16:07:57 +02:00
parent be993fd1be
commit 0487576a60
6 changed files with 104 additions and 33 deletions
+62 -12
View File
@@ -12,6 +12,7 @@ from model import (
CardEffects,
EffectType,
EffectTimes,
Team,
)
@@ -40,7 +41,7 @@ class Turn(Serializable):
self.damage_reserve = 0
self.heal_reserve = 0
self.gold_reserve = 0
self.champions_health: Dict[UUID, int] = {}
self.champions_health: Dict[str, int] = {}
self.effects_availables: List[Effect] = []
self.cards_locked: List[Card] = []
self.discard_markers = 0
@@ -75,6 +76,10 @@ class Turn(Serializable):
for c in self.player.board:
if c.faction == card.faction:
self.effects_availables.append(effect)
case EffectTimes.PER_OTHER_CARD_OF_SAME_FACTION:
for c in self.player.board:
if c.faction == card.faction and c != card:
self.effects_availables.append(effect)
case EffectTimes.PER_CHAMPION:
for c in self.player.board:
if c.card_role == CardType.CHAMPION:
@@ -100,19 +105,21 @@ class Turn(Serializable):
await self.player.game.notify_controller("update", self.serialize())
def discard_card(self, card_id: str):
async def discard_card(self, card_id: str):
if self.discard_markers <= 0:
return print("You don't have any discard markers!")
card = self.player.game.search_card_in_pile(card_id, self.cards_locked)
if card is not None:
return print("Cannot discard: card is locked")
return self.player.discard_card(card_id)
self.discard_markers -= 1
await self.player.game.notify_controller("update", self.serialize())
return await self.player.discard_card(card_id)
def sacrifice_card(self, card_id: str):
card = self.player.game.search_card_in_pile(card_id, self.cards_locked)
if card is not None:
return print("Cannot sacrifice : card is locked")
return self.player.discard_card(card_id)
return self.player.sacrifice_card(card_id)
async def use_effect_with_check(self, effect_id: str, target: Optional[str]):
if self.discard_markers > 0:
@@ -177,7 +184,9 @@ class Turn(Serializable):
self.effects_availables.remove(effect)
for e in effect.sub_effects:
self.effects_availables.append(e)
for _ in range(e.amount):
self.effects_availables.append(e)
print([str(e.uuid) for e in self.effects_availables])
await self.player.game.notify_controller("update", self.serialize())
async def use_effect(self, effect_id: str, target: str):
@@ -193,13 +202,13 @@ class Turn(Serializable):
match effect.effect:
case CardEffects.GOLD:
self.gold_reserve += effect.amount
self.gold_reserve += 1
success = True
case CardEffects.DAMAGE:
self.damage_reserve += effect.amount
self.damage_reserve += 1
success = True
case CardEffects.HEAL:
self.heal_reserve += effect.amount
self.heal_reserve += 1
success = True
case CardEffects.PERPARE:
success = self.prepare(target)
@@ -246,10 +255,12 @@ class Turn(Serializable):
self.effects_availables.append(e)
return True
def start_turn(self) -> None:
async def start_turn(self) -> None:
self.champions_health = {}
for c in self.player.board:
if c.card_type == CardType.CHAMPION:
self.champions_health[c.uuid] = c.defense
self.champions_health[str(c.uuid)] = c.defense
await self.player.game.notify_controller("update", self.serialize())
def serialize(self):
data = super().serialize() | {
@@ -268,7 +279,7 @@ class Turn(Serializable):
print("card is not a champion")
return False
else:
return await self.player.put_on_stack_from_discard(self, card)
return await self.player.put_on_stack_from_discard(card)
async def stack_next_card_bought_check(self, card: Card) -> bool:
@@ -314,7 +325,16 @@ class Turn(Serializable):
await self.player.game.notify_controller("update", self.serialize())
await self.player.game.notify_controller("update", self.player.team.serialize())
async def damage(self, target: str):
def check_for_guard(self, team: "Team"):
for p in self.player.game.players:
if p.team != team:
continue
for c in p.board:
if c.guard == True:
return True
return False
async def damage_team(self, target: str):
team = next(
(t for t in self.player.game.teams if str(t.uuid) == target),
None,
@@ -323,9 +343,39 @@ class Turn(Serializable):
return print("team not found")
if team == self.player.team:
return print("KYS!")
if self.check_for_guard(team):
return print("You cannot attack this team if a guard is present")
if self.damage_reserve > 0:
self.damage_reserve -= 1
team.health -= 1
await self.player.game.notify_controller("update", self.serialize())
await self.player.game.notify_controller("update", team.serialize())
async def damage_champion(self, target: str):
if self.damage_reserve <= 0:
print("No damage left to attack")
return
for p in self.player.game.players:
if self.player.team == p.team:
continue
for c in p.board:
if str(c.uuid) != target:
continue
if c.card_type != CardType.CHAMPION:
continue
if not c.guard and self.check_for_guard(p.team):
print("You cannot attack this champion if a guard is present")
return
self.damage_reserve -= 1
p.turn.champions_health[str(c.uuid)] -= 1
if p.turn.champions_health[str(c.uuid)] <= 0:
await self.player.stun(c.uuid)
await self.player.game.notify_controller("update", self.serialize())
await self.player.game.notify_controller("update", p.turn.serialize())
return
print("card not found")