Added documentation for some classes again
This commit is contained in:
parent
4c4a140a45
commit
6f9317fbc2
|
@ -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 \
|
||||
|
|
|
@ -5,6 +5,9 @@ from ..interfaces import FightingEntity, Map
|
|||
|
||||
|
||||
class Monster(FightingEntity):
|
||||
"""
|
||||
The class for all monsters in the dungeon
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
|
@ -38,6 +41,9 @@ class Monster(FightingEntity):
|
|||
|
||||
|
||||
class Beaver(Monster):
|
||||
"""
|
||||
A beaver monster
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
name = "beaver"
|
||||
|
@ -46,6 +52,9 @@ class Beaver(Monster):
|
|||
|
||||
|
||||
class Hedgehog(Monster):
|
||||
"""
|
||||
A really mean hedgehog monster
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
name = "hedgehog"
|
||||
|
@ -54,6 +63,9 @@ class Hedgehog(Monster):
|
|||
|
||||
|
||||
class Rabbit(Monster):
|
||||
"""
|
||||
A rabbit monster
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
name = "rabbit"
|
||||
|
@ -62,6 +74,9 @@ class Rabbit(Monster):
|
|||
|
||||
|
||||
class TeddyBear(Monster):
|
||||
"""
|
||||
A cute teddybear monster
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
name = "teddy_bear"
|
||||
|
|
|
@ -5,6 +5,9 @@ from ..interfaces import FightingEntity
|
|||
|
||||
|
||||
class Player(FightingEntity):
|
||||
"""
|
||||
The class of the player
|
||||
"""
|
||||
name = "player"
|
||||
maxhealth: int = 20
|
||||
strength: int = 5
|
||||
|
|
|
@ -3,6 +3,10 @@ from types import TracebackType
|
|||
|
||||
|
||||
class TermManager: # pragma: no cover
|
||||
"""
|
||||
The TermManager object initializes the terminal, returns a screen object and
|
||||
de-initializes the terminal after use
|
||||
"""
|
||||
def __init__(self):
|
||||
self.screen = curses.initscr()
|
||||
# convert escapes sequences to curses abstraction
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
1 1
|
||||
##############################################################################################################
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
#............................................................................................................#
|
||||
##############################################################################################################
|
Loading…
Reference in New Issue