Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion card_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ def upgrade(self):

def apply(self, origin, target):
origin.attack(target, self)
origin.draw_pile.insert(random.randint(0, len(origin.draw_pile) - 1), Wound())
# Handle when the player has no draw pile
if len(origin.draw_pile) == 0:
origin.draw_pile.append(Wound())
else:
origin.draw_pile.insert(random.randint(0, len(origin.draw_pile) - 1), Wound())

class BattleTrance(Card):
def __init__(self):
Expand Down
21 changes: 13 additions & 8 deletions effect_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,18 @@ def __init__(self, host, amount):
"Combust",
StackType.INTENSITY,
EffectType.BUFF,
"At the end of your turn, deals X damage to ALL enemies.",
f"At the end of your turn, lose 1 HP and deals {amount} damage to ALL enemies.",
amount,
)

def callback(self, message, data: tuple[Player, list[Enemy]]):
if message == Message.END_OF_TURN:
player, enemies = data
player.take_sourceless_dmg(1)
for enemy in enemies:
enemy.health -= self.amount
ansiprint(f"{enemy.name} took {self.amount} damage from <buff>Combust</buff>.")
enemy.take_sourceless_dmg(self.amount)



class DarkEmbrace(Effect):
Expand Down Expand Up @@ -424,15 +427,15 @@ def callback(self, message, data: tuple[Player, Card, Enemy, list[Enemy]]):
player, card, target, enemies = data
if card.type == CardType.ATTACK:
for enemy in enemies:
enemy.health -= self.amount
enemy.take_sourceless_dmg(self.amount)
ansiprint(
f"{enemy.name} took {self.amount} damage from <buff>Fire Breathing</buff>."
)


class FlameBarrier(Effect):
# "Gain 12 <keyword>Block</keyword>. Whenever you're attacked this turn, deal 4 damage back."
registers = [Message.ON_ATTACKED]
registers = [Message.AFTER_ATTACK]

def __init__(self, host, amount):
super().__init__(
Expand All @@ -444,10 +447,12 @@ def __init__(self, host, amount):
amount,
)

def callback(self, message, data):
if message == Message.ON_ATTACKED:
target = data
target.health -= 4
def callback(self, message, data: tuple[Player|Enemy, Player|Enemy, int]):
if message == Message.AFTER_ATTACK:
attacker, victim, damage = data
if victim == self.host:
ansiprint(f"{attacker.name} took 4 damage from {victim.name}'s <buff>Flame Barrier</buff>.")
attacker.take_sourceless_dmg(4)


class Metallicize(Effect):
Expand Down
5 changes: 5 additions & 0 deletions enemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ def take_turn(self, player: Player, enemies: list["Enemy"]):
if self.state == State.ALIVE:
self.execute_move(player, enemies)

def take_sourceless_dmg(self, dmg):
self.health -= dmg
if self.health <= 0:
self.die()

def callback(self, message, data):
global bus
if message == Message.START_OF_TURN:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def patched_input(*args, **kwargs):


@pytest.mark.timeout(10)
@pytest.mark.parametrize("seed", list(range(30)))
@pytest.mark.parametrize("seed", list(range(50)))
def test_e2e(seed, monkeypatch, sleepless):
'''Test the game from start to finish
Plays with (more or less) random inputs to test the game.
Expand Down