This commit is contained in:
Yohann D'ANELLO 2021-01-06 18:02:58 +01:00
parent ae505166b7
commit a8c0c197ed
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
5 changed files with 32 additions and 22 deletions

View File

@ -28,7 +28,7 @@ class StatsDisplay(Display):
string3 = "STR {}\nINT {}\nCHR {}\nDEX {}\nCON {}\nCRI {}%"\ string3 = "STR {}\nINT {}\nCHR {}\nDEX {}\nCON {}\nCRI {}%"\
.format(self.player.strength, .format(self.player.strength,
self.player.intelligence, self.player.charisma, self.player.intelligence, self.player.charisma,
self.player.dexterity, self.player.constitution,\ self.player.dexterity, self.player.constitution,
self.player.critical) self.player.critical)
self.addstr(self.pad, 3, 0, string3) self.addstr(self.pad, 3, 0, string3)
@ -54,15 +54,16 @@ class StatsDisplay(Display):
if self.player.equipped_secondary: if self.player.equipped_secondary:
self.addstr(self.pad, 11, 0, self.addstr(self.pad, 11, 0,
_("Equipped secondary:") + " " _("Equipped secondary:") + " "
f"{self.pack[self.player.equipped_secondary.name.upper()]}") + self.pack[self.player.equipped_secondary
.name.upper()])
if self.player.equipped_armor: if self.player.equipped_armor:
self.addstr(self.pad, 12, 0, self.addstr(self.pad, 12, 0,
_("Equipped chestplate:") + " " _("Equipped chestplate:") + " "
f"{self.pack[self.player.equipped_armor.name.upper()]}") + self.pack[self.player.equipped_armor.name.upper()])
if self.player.equipped_helmet: if self.player.equipped_helmet:
self.addstr(self.pad, 13, 0, self.addstr(self.pad, 13, 0,
_("Equipped helmet:") + " " _("Equipped helmet:") + " "
f"{self.pack[self.player.equipped_helmet.name.upper()]}") + self.pack[self.player.equipped_helmet.name.upper()])
self.addstr(self.pad, 14, 0, f"{self.pack.HAZELNUT} " self.addstr(self.pad, 14, 0, f"{self.pack.HAZELNUT} "
f"x{self.player.hazel}") f"x{self.player.hazel}")

View File

@ -107,7 +107,7 @@ class Item(Entity):
@staticmethod @staticmethod
def get_all_items() -> list: def get_all_items() -> list:
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,\ return [BodySnatchPotion, Bomb, Heart, Shield, Sword,
Chestplate, Helmet, RingCritical, RingXP] Chestplate, Helmet, RingCritical, RingXP]
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool: def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
@ -301,30 +301,33 @@ class Armor(Item):
d["constitution"] = self.constitution d["constitution"] = self.constitution
return d return d
class Shield(Armor): class Shield(Armor):
""" """
Class of shield items, they can be equipped in the other hand. Class of shield items, they can be equipped in the other hand.
""" """
def __init__(self, name: str = "shield", constitution: int = 2,\ def __init__(self, name: str = "shield", constitution: int = 2,
price: int = 6, *args, **kwargs): price: int = 6, *args, **kwargs):
super().__init__(name=name, constitution=constitution, *args, **kwargs) super().__init__(name=name, constitution=constitution, *args, **kwargs)
class Helmet(Armor): class Helmet(Armor):
""" """
Class of helmet items, they can be equipped on the head. Class of helmet items, they can be equipped on the head.
""" """
def __init__(self, name: str = "helmet", constitution: int = 2, \ def __init__(self, name: str = "helmet", constitution: int = 2,
price: int = 8, *args, **kwargs): price: int = 8, *args, **kwargs):
super().__init__(name=name, constitution=constitution, *args, **kwargs) super().__init__(name=name, constitution=constitution, *args, **kwargs)
class Chestplate(Armor): class Chestplate(Armor):
""" """
Class of chestplate items, they can be equipped on the body. Class of chestplate items, they can be equipped on the body.
""" """
def __init__(self, name: str = "chestplate", constitution: int = 4,\ def __init__(self, name: str = "chestplate", constitution: int = 4,
price: int = 15, *args, **kwargs): price: int = 15, *args, **kwargs):
super().__init__(name=name, constitution=constitution, *args, **kwargs) super().__init__(name=name, constitution=constitution, *args, **kwargs)
@ -362,6 +365,7 @@ class BodySnatchPotion(Item):
self.held_by.inventory.remove(self) self.held_by.inventory.remove(self)
class Ring(Item): class Ring(Item):
""" """
A class of rings that boost the player's statistics. A class of rings that boost the player's statistics.
@ -375,9 +379,9 @@ class Ring(Item):
critical: int critical: int
experience: float experience: float
def __init__(self, maxhealth: int = 0, strength: int = 0,\ def __init__(self, maxhealth: int = 0, strength: int = 0,
intelligence: int = 0, charisma: int = 0,\ intelligence: int = 0, charisma: int = 0,
dexterity: int = 0, constitution: int = 0,\ dexterity: int = 0, constitution: int = 0,
critical: int = 0, experience: float = 0, *args, **kwargs): critical: int = 0, experience: float = 0, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.maxhealth = maxhealth self.maxhealth = maxhealth
@ -416,14 +420,16 @@ class Ring(Item):
d["constitution"] = self.constitution d["constitution"] = self.constitution
return d return d
class RingCritical(Ring): class RingCritical(Ring):
def __init__(self, name: str = "ring_of_critical_damage", price: int = 15, def __init__(self, name: str = "ring_of_critical_damage", price: int = 15,
critical: int = 20, *args, **kwargs): critical: int = 20, *args, **kwargs):
super().__init__(name=name, price=price, critical=critical, \ super().__init__(name=name, price=price, critical=critical,
*args, **kwargs) *args, **kwargs)
class RingXP(Ring): class RingXP(Ring):
def __init__(self, name: str = "ring_of_more_experience", price: int = 25, def __init__(self, name: str = "ring_of_more_experience", price: int = 25,
experience: float = 2, *args, **kwargs): experience: float = 2, *args, **kwargs):
super().__init__(name=name, price=price, experience=experience, \ super().__init__(name=name, price=price, experience=experience,
*args, **kwargs) *args, **kwargs)

View File

@ -87,9 +87,11 @@ class Rabbit(Monster):
A rabbit monster A rabbit monster
""" """
def __init__(self, name: str = "rabbit", strength: int = 1, def __init__(self, name: str = "rabbit", strength: int = 1,
maxhealth: int = 15, critical: int = 30, *args, **kwargs) -> None: maxhealth: int = 15, critical: int = 30,
*args, **kwargs) -> None:
super().__init__(name=name, strength=strength, super().__init__(name=name, strength=strength,
maxhealth=maxhealth, critical=critical, *args, **kwargs) maxhealth=maxhealth, critical=critical,
*args, **kwargs)
class TeddyBear(Monster): class TeddyBear(Monster):
@ -101,6 +103,7 @@ class TeddyBear(Monster):
super().__init__(name=name, strength=strength, super().__init__(name=name, strength=strength,
maxhealth=maxhealth, *args, **kwargs) maxhealth=maxhealth, *args, **kwargs)
class GiantSeaEagle(Monster): class GiantSeaEagle(Monster):
""" """
An eagle boss An eagle boss

View File

@ -28,9 +28,9 @@ class Player(InventoryHolder, FightingEntity):
dexterity: int = 1, constitution: int = 1, level: int = 1, dexterity: int = 1, constitution: int = 1, level: int = 1,
current_xp: int = 0, max_xp: int = 10, inventory: list = None, current_xp: int = 0, max_xp: int = 10, inventory: list = None,
hazel: int = 42, equipped_main: Optional[Item] = None, hazel: int = 42, equipped_main: Optional[Item] = None,
equipped_armor: Optional[Item] = None, critical: int = 5,\ equipped_armor: Optional[Item] = None, critical: int = 5,
equipped_secondary: Optional[Item] = None, \ equipped_secondary: Optional[Item] = None,
equipped_helmet: Optional[Item] = None, xp_buff: float = 1,\ equipped_helmet: Optional[Item] = None, xp_buff: float = 1,
*args, **kwargs) -> None: *args, **kwargs) -> None:
super().__init__(name=name, maxhealth=maxhealth, strength=strength, super().__init__(name=name, maxhealth=maxhealth, strength=strength,
intelligence=intelligence, charisma=charisma, intelligence=intelligence, charisma=charisma,
@ -84,7 +84,7 @@ class Player(InventoryHolder, FightingEntity):
Add some experience to the player. Add some experience to the player.
If the required amount is reached, level up. If the required amount is reached, level up.
""" """
self.current_xp += int(xp*self.xp_buff) self.current_xp += int(xp * self.xp_buff)
self.level_up() self.level_up()
def remove_from_inventory(self, obj: Item) -> None: def remove_from_inventory(self, obj: Item) -> None:

View File

@ -146,8 +146,8 @@ class Map:
tile = self.tiles[y][x] tile = self.tiles[y][x]
if tile.can_walk(): if tile.can_walk():
break break
entity = choices(Entity.get_all_entity_classes(),\ entity = choices(Entity.get_all_entity_classes(),
weights = Entity.get_weights(), k=1)[0]() weights=Entity.get_weights(), k=1)[0]()
entity.move(y, x) entity.move(y, x)
self.add_entity(entity) self.add_entity(entity)