From 01ee49ddd44a12b0aa0bad39a6b01c76185b7b62 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 10 Jan 2021 19:25:12 +0100 Subject: [PATCH] Entities are updated after a bow shot, fixes #70 --- squirrelbattle/entities/items.py | 11 ++++++----- squirrelbattle/game.py | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 182c86b..ac5f74d 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -47,7 +47,7 @@ class Item(Entity): Indicates what should be done when the item is used. """ - def throw(self, direction: int) -> None: + def throw(self, direction: int) -> Any: """ Indicates what should be done when the item is thrown. """ @@ -555,7 +555,7 @@ class LongRangeWeapon(Weapon): self.held_by, self.damage + getattr(self.held_by, self.stat)) self.held_by.map.logs.add_message(line) - return (to_kill.x, to_kill.y) if to_kill else None + return (to_kill.y, to_kill.x) if to_kill else None def equip(self) -> None: """ @@ -621,17 +621,18 @@ class FireBallStaff(LongRangeWeapon): def string(self) -> str: return " is shot by a fire ball." - def throw(self, direction: int) -> None: + def throw(self, direction: int) -> Any: """ Adds an explosion animation when killing something. """ coord = super().throw(direction) if coord: - x = coord[0] - y = coord[1] + y = coord[0] + x = coord[1] explosion = Explosion(y=y, x=x) self.held_by.map.add_entity(explosion) + return y, x class Monocle(Item): diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index bde825f..83da5f3 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -292,7 +292,8 @@ class Game: return if self.player.equipped_main: - self.player.equipped_main.throw(direction) + if self.player.equipped_main.throw(direction): + self.map.tick(self.player) def handle_key_pressed_inventory(self, key: KeyValues) -> None: """