Entities are updated after a bow shot, fixes #70

This commit is contained in:
Yohann D'ANELLO 2021-01-10 19:25:12 +01:00
parent cddff5c2d9
commit 01ee49ddd4
2 changed files with 8 additions and 6 deletions

View File

@ -47,7 +47,7 @@ class Item(Entity):
Indicates what should be done when the item is used. 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. Indicates what should be done when the item is thrown.
""" """
@ -555,7 +555,7 @@ class LongRangeWeapon(Weapon):
self.held_by, self.damage self.held_by, self.damage
+ getattr(self.held_by, self.stat)) + getattr(self.held_by, self.stat))
self.held_by.map.logs.add_message(line) 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: def equip(self) -> None:
""" """
@ -621,17 +621,18 @@ class FireBallStaff(LongRangeWeapon):
def string(self) -> str: def string(self) -> str:
return " is shot by a fire ball." 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. Adds an explosion animation when killing something.
""" """
coord = super().throw(direction) coord = super().throw(direction)
if coord: if coord:
x = coord[0] y = coord[0]
y = coord[1] x = coord[1]
explosion = Explosion(y=y, x=x) explosion = Explosion(y=y, x=x)
self.held_by.map.add_entity(explosion) self.held_by.map.add_entity(explosion)
return y, x
class Monocle(Item): class Monocle(Item):

View File

@ -292,7 +292,8 @@ class Game:
return return
if self.player.equipped_main: 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: def handle_key_pressed_inventory(self, key: KeyValues) -> None:
""" """