Fighting now takes into account the constitution. Closes #51
This commit is contained in:
parent
9b8dfb00da
commit
4bddf076ea
|
@ -226,6 +226,21 @@ class Weapon(Item):
|
||||||
d["damage"] = self.damage
|
d["damage"] = self.damage
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def equip(self, armor: bool = False) -> None:
|
||||||
|
"""
|
||||||
|
When a weapon is equipped, the player gains strength.
|
||||||
|
"""
|
||||||
|
super().equip()
|
||||||
|
self.held_by.strength += self.damage
|
||||||
|
|
||||||
|
def unequip(self) -> None:
|
||||||
|
"""
|
||||||
|
Remove the strength earned by the weapon.
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
super().unequip()
|
||||||
|
self.held_by.strength -= self.damage
|
||||||
|
|
||||||
|
|
||||||
class Sword(Weapon):
|
class Sword(Weapon):
|
||||||
"""
|
"""
|
||||||
|
@ -236,21 +251,6 @@ class Sword(Weapon):
|
||||||
super().__init__(name=name, price=price, *args, **kwargs)
|
super().__init__(name=name, price=price, *args, **kwargs)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def equip(self, armor: bool = False) -> None:
|
|
||||||
"""
|
|
||||||
When a sword is equipped, the player gains strength.
|
|
||||||
"""
|
|
||||||
super().equip()
|
|
||||||
self.held_by.strength += self.damage
|
|
||||||
|
|
||||||
def unequip(self) -> None:
|
|
||||||
"""
|
|
||||||
Remove the strength earned by the sword.
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
super().unequip()
|
|
||||||
self.held_by.strength -= self.damage
|
|
||||||
|
|
||||||
|
|
||||||
class Shield(Item):
|
class Shield(Item):
|
||||||
constitution: int
|
constitution: int
|
||||||
|
|
|
@ -443,11 +443,12 @@ class FightingEntity(Entity):
|
||||||
"""
|
"""
|
||||||
Take damage from the attacker, based on the stats
|
Take damage from the attacker, based on the stats
|
||||||
"""
|
"""
|
||||||
self.health -= amount
|
damage = max(0, amount - self.constitution)
|
||||||
|
self.health -= damage
|
||||||
if self.health <= 0:
|
if self.health <= 0:
|
||||||
self.die()
|
self.die()
|
||||||
return _("{name} takes {amount} damage.")\
|
return _("{name} takes {damage} damage.")\
|
||||||
.format(name=self.translated_name.capitalize(), amount=str(amount))\
|
.format(name=self.translated_name.capitalize(), damage=str(damage))\
|
||||||
+ (" " + _("{name} dies.")
|
+ (" " + _("{name} dies.")
|
||||||
.format(name=self.translated_name.capitalize())
|
.format(name=self.translated_name.capitalize())
|
||||||
if self.health <= 0 else "")
|
if self.health <= 0 else "")
|
||||||
|
|
Loading…
Reference in New Issue