Now with EXPLOSIONS!

This commit is contained in:
eichhornchen 2021-01-08 19:18:29 +01:00
parent 591630b8a7
commit 746379bad6

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from random import choice, randint
from typing import Optional
from typing import Optional, Any
from ..interfaces import Entity, FightingEntity, Map, InventoryHolder
from ..translations import gettext as _
@ -484,7 +484,7 @@ class LongRangeWeapon(Item):
self.damage = damage
self.range = rang
def throw(self, direction: int) -> str:
def throw(self, direction: int) -> Any:
to_kill = None
for entity in self.held_by.map.entities:
if entity.is_fighting_entity():
@ -509,6 +509,7 @@ class LongRangeWeapon(Item):
.format(name=to_kill.translated_name.capitalize())+ self.string + " " \
+ to_kill.take_damage(self.held_by, self.damage + \
getattr(self.held_by, self.stat)))
return (to_kill.x, to_kill.y) if to_kill else None
def equip(self) -> None:
"""
@ -569,3 +570,15 @@ class FireBallStaff(LongRangeWeapon):
@property
def string(self) -> str:
return " is shot by a fire ball."
def throw(self, direction: int) -> None:
"""
Adds an explosion animation when killing something.
"""
A = super().throw(direction)
if A:
x=A[0]
y=A[1]
explosion = Explosion(y=y, x=x)
self.held_by.map.add_entity(explosion)