Added rings that can augment the player's statistics. Also added a new statistic : xp_buff, which helps the player level up sooner.
This commit is contained in:
@ -108,7 +108,7 @@ class Item(Entity):
|
||||
@staticmethod
|
||||
def get_all_items() -> list:
|
||||
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\
|
||||
Chestplate, Helmet]
|
||||
Chestplate, Helmet, RingCritical, RingXP]
|
||||
|
||||
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
|
||||
"""
|
||||
@ -361,3 +361,69 @@ class BodySnatchPotion(Item):
|
||||
self.held_by.recalculate_paths()
|
||||
|
||||
self.held_by.inventory.remove(self)
|
||||
|
||||
class Ring(Item):
|
||||
"""
|
||||
A class of rings that boost the player's statistics.
|
||||
"""
|
||||
maxhealth: int
|
||||
strength: int
|
||||
intelligence: int
|
||||
charisma: int
|
||||
dexterity: int
|
||||
constitution: int
|
||||
critical: int
|
||||
experience: float
|
||||
|
||||
def __init__(self, maxhealth: int = 0, strength: int = 0,\
|
||||
intelligence: int = 0, charisma: int = 0,\
|
||||
dexterity: int = 0, constitution: int = 0,\
|
||||
critical: int = 0, experience: float = 0, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.maxhealth = maxhealth
|
||||
self.strength = strength
|
||||
self.intelligence = intelligence
|
||||
self.charisma = charisma
|
||||
self.dexterity = dexterity
|
||||
self.constitution = constitution
|
||||
self.critical = critical
|
||||
self.experience = experience
|
||||
|
||||
def equip(self) -> None:
|
||||
super().equip()
|
||||
self.held_by.maxhealth += self.maxhealth
|
||||
self.held_by.strength += self.strength
|
||||
self.held_by.intelligence += self.intelligence
|
||||
self.held_by.charisma += self.charisma
|
||||
self.held_by.dexterity += self.dexterity
|
||||
self.held_by.constitution += self.constitution
|
||||
self.held_by.critical += self.critical
|
||||
self.held_by.xp_buff += self.experience
|
||||
|
||||
def unequip(self) -> None:
|
||||
super().unequip()
|
||||
self.held_by.maxhealth -= self.maxhealth
|
||||
self.held_by.strength -= self.strength
|
||||
self.held_by.intelligence -= self.intelligence
|
||||
self.held_by.charisma -= self.charisma
|
||||
self.held_by.dexterity -= self.dexterity
|
||||
self.held_by.constitution -= self.constitution
|
||||
self.held_by.critical -= self.critical
|
||||
self.held_by.xp_buff -= self.experience
|
||||
|
||||
def save_state(self) -> dict:
|
||||
d = super().save_state()
|
||||
d["constitution"] = self.constitution
|
||||
return d
|
||||
|
||||
class RingCritical(Ring):
|
||||
def __init__(self, name: str = "ring_of_critical_damage", price: int = 15,
|
||||
critical: int = 20, *args, **kwargs):
|
||||
super().__init__(name=name, price=price, critical=critical, \
|
||||
*args, **kwargs)
|
||||
|
||||
class RingXP(Ring):
|
||||
def __init__(self, name: str = "ring_of_more_experience", price: int = 25,
|
||||
experience: float = 2, *args, **kwargs):
|
||||
super().__init__(name=name, price=price, experience=experience, \
|
||||
*args, **kwargs)
|
||||
|
Reference in New Issue
Block a user