Added documentation for some classes again
This commit is contained in:
@ -5,6 +5,9 @@ from ..interfaces import Entity, FightingEntity, Map
|
||||
|
||||
|
||||
class Item(Entity):
|
||||
"""
|
||||
A class for items
|
||||
"""
|
||||
held: bool
|
||||
held_by: Optional["Player"]
|
||||
|
||||
@ -13,6 +16,9 @@ class Item(Entity):
|
||||
self.held = False
|
||||
|
||||
def drop(self, y: int, x: int) -> None:
|
||||
"""
|
||||
The item is dropped from the inventory onto the floor
|
||||
"""
|
||||
if self.held:
|
||||
self.held_by.inventory.remove(self)
|
||||
self.held = False
|
||||
@ -21,6 +27,9 @@ class Item(Entity):
|
||||
self.move(y, x)
|
||||
|
||||
def hold(self, player: "Player") -> None:
|
||||
"""
|
||||
The item is taken from the floor and put into the inventory
|
||||
"""
|
||||
self.held = True
|
||||
self.held_by = player
|
||||
self.map.remove_entity(self)
|
||||
@ -28,6 +37,9 @@ class Item(Entity):
|
||||
|
||||
|
||||
class Heart(Item):
|
||||
"""
|
||||
A heart item to return health to the player
|
||||
"""
|
||||
name: str = "heart"
|
||||
healing: int = 5
|
||||
|
||||
@ -40,6 +52,9 @@ class Heart(Item):
|
||||
|
||||
|
||||
class Bomb(Item):
|
||||
"""
|
||||
A bomb item intended to deal damage to ennemies at long range
|
||||
"""
|
||||
name: str = "bomb"
|
||||
damage: int = 5
|
||||
exploding: bool
|
||||
@ -53,6 +68,9 @@ class Bomb(Item):
|
||||
self.exploding = True
|
||||
|
||||
def act(self, m: Map) -> None:
|
||||
"""
|
||||
Special exploding action of the bomb
|
||||
"""
|
||||
if self.exploding:
|
||||
for e in m.entities:
|
||||
if abs(e.x - self.x) + abs(e.y - self.y) <= 1 and \
|
||||
|
Reference in New Issue
Block a user