Merge branch 'master' into 'equipment'
# Conflicts: # squirrelbattle/display/statsdisplay.py # squirrelbattle/entities/items.py # squirrelbattle/entities/player.py # squirrelbattle/interfaces.py # squirrelbattle/locale/de/LC_MESSAGES/squirrelbattle.po # squirrelbattle/locale/es/LC_MESSAGES/squirrelbattle.po # squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po # squirrelbattle/tests/game_test.py
This commit is contained in:
@@ -10,7 +10,7 @@ from ..translations import gettext as _
|
||||
|
||||
class Item(Entity):
|
||||
"""
|
||||
A class for items
|
||||
A class for items.
|
||||
"""
|
||||
held: bool
|
||||
held_by: Optional[InventoryHolder]
|
||||
@@ -26,7 +26,7 @@ class Item(Entity):
|
||||
|
||||
def drop(self) -> None:
|
||||
"""
|
||||
The item is dropped from the inventory onto the floor
|
||||
The item is dropped from the inventory onto the floor.
|
||||
"""
|
||||
if self.held:
|
||||
self.held_by.remove_from_inventory(self)
|
||||
@@ -59,7 +59,7 @@ class Item(Entity):
|
||||
|
||||
def hold(self, holder: InventoryHolder) -> None:
|
||||
"""
|
||||
The item is taken from the floor and put into the inventory
|
||||
The item is taken from the floor and put into the inventory.
|
||||
"""
|
||||
self.held = True
|
||||
self.held_by = holder
|
||||
@@ -68,7 +68,7 @@ class Item(Entity):
|
||||
|
||||
def save_state(self) -> dict:
|
||||
"""
|
||||
Saves the state of the entity into a dictionary
|
||||
Saves the state of the item into a dictionary.
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["held"] = self.held
|
||||
@@ -76,6 +76,9 @@ class Item(Entity):
|
||||
|
||||
@staticmethod
|
||||
def get_all_items() -> list:
|
||||
"""
|
||||
Returns the list of all item classes.
|
||||
"""
|
||||
return [BodySnatchPotion, Bomb, Heart, Shield, Sword,
|
||||
Chestplate, Helmet, RingCritical, RingXP]
|
||||
|
||||
@@ -83,7 +86,7 @@ class Item(Entity):
|
||||
"""
|
||||
Does all necessary actions when an object is to be sold.
|
||||
Is overwritten by some classes that cannot exist in the player's
|
||||
inventory
|
||||
inventory.
|
||||
"""
|
||||
if buyer.hazel >= self.price:
|
||||
self.hold(buyer)
|
||||
@@ -97,7 +100,7 @@ class Item(Entity):
|
||||
|
||||
class Heart(Item):
|
||||
"""
|
||||
A heart item to return health to the player
|
||||
A heart item to return health to the player.
|
||||
"""
|
||||
healing: int
|
||||
|
||||
@@ -108,14 +111,15 @@ class Heart(Item):
|
||||
|
||||
def hold(self, entity: InventoryHolder) -> None:
|
||||
"""
|
||||
When holding a heart, heal the player and don't put item in inventory.
|
||||
When holding a heart, the player is healed and
|
||||
the item is not put in the inventory.
|
||||
"""
|
||||
entity.health = min(entity.maxhealth, entity.health + self.healing)
|
||||
entity.map.remove_entity(self)
|
||||
|
||||
def save_state(self) -> dict:
|
||||
"""
|
||||
Saves the state of the header into a dictionary
|
||||
Saves the state of the heart into a dictionary.
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["healing"] = self.healing
|
||||
@@ -141,7 +145,7 @@ class Bomb(Item):
|
||||
|
||||
def use(self) -> None:
|
||||
"""
|
||||
When the bomb is used, throw it and explodes it.
|
||||
When the bomb is used, it is thrown and then it explodes.
|
||||
"""
|
||||
if self.held:
|
||||
self.owner = self.held_by
|
||||
@@ -150,7 +154,7 @@ class Bomb(Item):
|
||||
|
||||
def act(self, m: Map) -> None:
|
||||
"""
|
||||
Special exploding action of the bomb
|
||||
Special exploding action of the bomb.
|
||||
"""
|
||||
if self.exploding:
|
||||
if self.tick > 0:
|
||||
@@ -176,7 +180,7 @@ class Bomb(Item):
|
||||
|
||||
def save_state(self) -> dict:
|
||||
"""
|
||||
Saves the state of the bomb into a dictionary
|
||||
Saves the state of the bomb into a dictionary.
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["exploding"] = self.exploding
|
||||
@@ -193,13 +197,13 @@ class Explosion(Item):
|
||||
|
||||
def act(self, m: Map) -> None:
|
||||
"""
|
||||
The explosion instant dies.
|
||||
The bomb disappears after exploding.
|
||||
"""
|
||||
m.remove_entity(self)
|
||||
|
||||
def hold(self, player: InventoryHolder) -> None:
|
||||
"""
|
||||
The player can't hold any explosion.
|
||||
The player can't hold an explosion.
|
||||
"""
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user