Subclassed and removed some debugging code

This commit is contained in:
eichhornchen 2021-01-08 18:38:54 +01:00
parent f6210a6356
commit 903a06c36c
2 changed files with 29 additions and 12 deletions

View File

@ -477,13 +477,10 @@ class ScrollofWeakening(Item):
_(f"The ennemies have -{max(1, self.held_by.intelligence//2)} strength for 3 turns"))
self.held_by.inventory.remove(self)
class Bow(Item):
"""
A type of throwable weapon that deals damage based on the player's dexterity.
"""
def __init__(self, name: str = "bow", price: int = 22, damage = 4,
rang = 3, *args, **kwargs):
super().__init__(name=name, price=price, *args, **kwargs)
class LongRangeWeapon(Item):
def __init__(self, damage: int = 4,
rang: int = 3, *args, **kwargs):
super().__init__(*args, **kwargs)
self.damage = damage
self.range = rang
@ -510,11 +507,34 @@ class Bow(Item):
if to_kill:
self.held_by.map.logs.add_message(_("{name} is shot by an arrow.")\
.format(name=to_kill.translated_name.capitalize())+ " " \
+ to_kill.take_damage(self.held_by, self.damage + self.held_by.dexterity))
+ to_kill.take_damage(self.held_by, self.damage + getattr(self.held_by, self.stat)))
def equip(self) -> None:
"""
Equip the bow.
Equip the weapon.
"""
self.held_by.remove_from_inventory(self)
self.held_by.equipped_main = self
@property
def stat(self) -> str:
"""
The stat that is used when using the object: dexterity for a bow
or intelligence for a magic staff.
"""
class Bow(LongRangeWeapon):
"""
A type of long range weapon that deals damage based on the player's dexterity
"""
def __init__(self, name: str = "bow", price: int = 22, damage: int = 4,
rang: int = 3, *args, **kwargs):
super().__init__(name=name, price=price, damage=damage, \
rang=rang, *args, **kwargs)
@property
def stat(self) -> str:
"""
Here it is dexterity
"""
return "dexterity"

View File

@ -38,9 +38,6 @@ class Player(InventoryHolder, FightingEntity):
self.max_xp = max_xp
self.xp_buff = xp_buff
self.inventory = self.translate_inventory(inventory or [])
b = Bow()
b.held_by=self
self.inventory.append(b)
self.paths = dict()
self.hazel = hazel
self.equipped_main = self.dict_to_item(equipped_main) \