Repaired the use functionnality of the main item, as well as the load system for Armor items.

This commit is contained in:
eichhornchen 2021-01-06 11:13:17 +01:00
parent f3fe04e13a
commit a9aeb9ca3a
3 changed files with 15 additions and 10 deletions

View File

@ -276,7 +276,6 @@ class Sword(Weapon):
def __init__(self, name: str = "sword", price: int = 20, def __init__(self, name: str = "sword", price: int = 20,
*args, **kwargs): *args, **kwargs):
super().__init__(name=name, price=price, *args, **kwargs) super().__init__(name=name, price=price, *args, **kwargs)
self.name = name
class Armor(Item): class Armor(Item):
@ -307,24 +306,27 @@ 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, constitution: int = 2, *args, **kwargs): def __init__(self, name: str = "shield", constitution: int = 2,\
super().__init__(name="shield", constitution=constitution, *args, **kwargs) price: int = 6, *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, constitution: int = 2, *args, **kwargs): def __init__(self, name: str = "helmet", constitution: int = 2, \
super().__init__(name="helmet", constitution=constitution, *args, **kwargs) price: int = 8, *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, constitution: int = 4, *args, **kwargs): def __init__(self, name: str = "chestplate", constitution: int = 4,\
super().__init__(name="chestplate", constitution=constitution, *args, **kwargs) price: int = 15, *args, **kwargs):
super().__init__(name=name, constitution=constitution, *args, **kwargs)
class BodySnatchPotion(Item): class BodySnatchPotion(Item):

View File

@ -127,8 +127,8 @@ class Game:
elif key == KeyValues.INVENTORY: elif key == KeyValues.INVENTORY:
self.state = GameMode.INVENTORY self.state = GameMode.INVENTORY
self.display_actions(DisplayActions.UPDATE) self.display_actions(DisplayActions.UPDATE)
elif key == KeyValues.USE and self.player.equipped_item: elif key == KeyValues.USE and self.player.equipped_main:
self.player.equipped_item.use() self.player.equipped_main.use()
elif key == KeyValues.SPACE: elif key == KeyValues.SPACE:
self.state = GameMode.MAINMENU self.state = GameMode.MAINMENU
elif key == KeyValues.CHAT: elif key == KeyValues.CHAT:

View File

@ -374,7 +374,7 @@ class Entity:
TeddyBear, GiantSeaEagle TeddyBear, GiantSeaEagle
from squirrelbattle.entities.friendly import Merchant, Sunflower from squirrelbattle.entities.friendly import Merchant, Sunflower
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \
Heart, Sword Heart, Sword, Shield, Chestplate, Helmet
return { return {
"Tiger": Tiger, "Tiger": Tiger,
"Bomb": Bomb, "Bomb": Bomb,
@ -388,6 +388,9 @@ class Entity:
"Sunflower": Sunflower, "Sunflower": Sunflower,
"Sword": Sword, "Sword": Sword,
"Eagle": GiantSeaEagle, "Eagle": GiantSeaEagle,
"Shield": Shield,
"Chestplate": Chestplate,
"Helmet": Helmet,
} }
def save_state(self) -> dict: def save_state(self) -> dict: