Skip to content

Commit

Permalink
Merge pull request #112 from harshiniwho/fix-the-inheritance-graph
Browse files Browse the repository at this point in the history
fix the inheritance graph
  • Loading branch information
arnauddupuis committed Oct 10, 2020
2 parents 867127e + 950c8f2 commit 69a4a19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pygamelib/actuators.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, parent):
The constructor simply construct an Actuator. It takes on positional paraneter:
the parent object.
"""
Actuator.__init__(self, parent)
super().__init__(parent)

def next_action(self):
"""
Expand Down
59 changes: 25 additions & 34 deletions pygamelib/board_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pygamelib import actuators


class BoardItem:
class BoardItem(object):
"""
Base class for any item that will be placed on a Board.
Expand All @@ -61,6 +61,7 @@ class BoardItem:
"""

def __init__(self, **kwargs):
super().__init__()
self.name = "Board item"
self.type = "item"
self.pos = [None, None]
Expand Down Expand Up @@ -297,7 +298,7 @@ class BoardItemVoid(BoardItem):
"""

def __init__(self, **kwargs):
BoardItem.__init__(self, **kwargs)
super().__init__(**kwargs)
self.name = "void_cell"

def pickable(self):
Expand Down Expand Up @@ -547,7 +548,7 @@ class Movable(BoardItem):
"""

def __init__(self, **kwargs):
BoardItem.__init__(self, **kwargs)
super().__init__(**kwargs)
# We probably need the item to store its own velocity at some point
# self.velocity = base.Vector2d(0,0)
# Set default values
Expand Down Expand Up @@ -717,8 +718,7 @@ def __init__(
"incorrect_range_step",
"range must be a factor of step" " in Projectile",
)
Movable.__init__(
self,
super().__init__(
model=model,
step=step,
name=name,
Expand Down Expand Up @@ -981,7 +981,7 @@ class Immovable(BoardItem):
"""

def __init__(self, **kwargs):
BoardItem.__init__(self, **kwargs)
super().__init__(**kwargs)
if "inventory_space" not in kwargs.keys():
self._inventory_space = 0
else:
Expand Down Expand Up @@ -1056,7 +1056,7 @@ def __init__(self, **kwargs):
self.perm = constants.PLAYER_AUTHORIZED
else:
self.perm = kwargs["perm"]
Immovable.__init__(self, **kwargs)
super().__init__(**kwargs)

def activate(self):
"""
Expand All @@ -1070,7 +1070,7 @@ def activate(self):
self.action(self.action_parameters)


class Character:
class Character(object):
"""A base class for a character (playable or not)
:param agility: Represent the agility of the character
Expand Down Expand Up @@ -1103,6 +1103,7 @@ class Character:
"""

def __init__(self, **kwargs):
super().__init__()
self.max_hp = None
self.hp = None
self.max_mp = None
Expand Down Expand Up @@ -1158,8 +1159,7 @@ def __init__(self, **kwargs):
kwargs["attack_power"] = 10
if "movement_speed" not in kwargs.keys():
kwargs["movement_speed"] = 0.1
Movable.__init__(self, **kwargs)
Character.__init__(self, **kwargs)
super().__init__(**kwargs)
if "inventory" in kwargs.keys():
self.inventory = kwargs["inventory"]
else:
Expand Down Expand Up @@ -1206,8 +1206,7 @@ class ComplexPlayer(Player, BoardComplexItem):
"""

def __init__(self, **kwargs):
Player.__init__(self, **kwargs)
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)


class NPC(Movable, Character):
Expand Down Expand Up @@ -1253,9 +1252,8 @@ def __init__(self, **kwargs):
if "attack_power" not in kwargs.keys():
kwargs["attack_power"] = 5
if "movement_speed" not in kwargs.keys():
kwargs["movement_speed"] = 0.25
Movable.__init__(self, **kwargs)
Character.__init__(self, **kwargs)
kwargs["movement_speed"] = 0.2
super().__init__(**kwargs)
if "actuator" not in kwargs.keys():
self.actuator = None
else:
Expand Down Expand Up @@ -1340,8 +1338,7 @@ class ComplexNPC(NPC, BoardComplexItem):
"""

def __init__(self, **kwargs):
NPC.__init__(self, **kwargs)
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)


class TextItem(BoardComplexItem):
Expand Down Expand Up @@ -1373,7 +1370,7 @@ class TextItem(BoardComplexItem):
"""

def __init__(self, text=None, **kwargs):
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)
if text is not None and not isinstance(text, base.Text) and type(text) is str:
self._text = base.Text(text)
elif text is not None and not isinstance(text, base.Text):
Expand Down Expand Up @@ -1447,7 +1444,7 @@ def __init__(self, **kwargs):
kwargs["name"] = "wall"
if "size" not in kwargs.keys():
kwargs["size"] = 1
Immovable.__init__(self, **kwargs)
super().__init__(**kwargs)

def pickable(self):
""" This represent the capacity for a :class:`~pygamelib.board_items.BoardItem` to
Expand Down Expand Up @@ -1509,8 +1506,7 @@ class ComplexWall(Wall, BoardComplexItem):
"""

def __init__(self, **kwargs):
Wall.__init__(self, **kwargs)
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)


class GenericStructure(Immovable):
Expand Down Expand Up @@ -1553,7 +1549,6 @@ def __init__(self, **kwargs):
kwargs["model"] = "#"
if "name" not in kwargs.keys():
kwargs["name"] = "structure"
Immovable.__init__(self, **kwargs)
if "value" not in kwargs.keys():
self.value = 0
else:
Expand All @@ -1571,6 +1566,7 @@ def __init__(self, **kwargs):
self.__is_restorable = kwargs["restorable"]
else:
self.__is_restorable = False
super().__init__(**kwargs)

def pickable(self):
"""This represent the capacity for a BoardItem to be picked-up by player or NPC.
Expand Down Expand Up @@ -1671,8 +1667,7 @@ class GenericActionableStructure(GenericStructure, Actionable):
"""

def __init__(self, **kwargs):
GenericStructure.__init__(self, **kwargs)
Actionable.__init__(self, **kwargs)
super().__init__(**kwargs)


class Treasure(Immovable):
Expand Down Expand Up @@ -1707,7 +1702,7 @@ class Treasure(Immovable):
def __init__(self, **kwargs):
if "model" not in kwargs.keys():
kwargs["model"] = "¤"
Immovable.__init__(self, **kwargs)
super().__init__(**kwargs)
if "value" not in kwargs.keys():
self.value = 10
else:
Expand Down Expand Up @@ -1771,8 +1766,7 @@ class ComplexTreasure(Treasure, BoardComplexItem):
"""

def __init__(self, **kwargs):
Treasure.__init__(self, **kwargs)
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)


class Door(GenericStructure):
Expand Down Expand Up @@ -1814,7 +1808,7 @@ class Door(GenericStructure):
def __init__(self, **kwargs):
if "model" not in kwargs.keys():
kwargs["model"] = "]"
Immovable.__init__(self, **kwargs)
super().__init__(**kwargs)
if "value" not in kwargs.keys():
self.value = 0
else:
Expand Down Expand Up @@ -1866,8 +1860,7 @@ class ComplexDoor(Door, BoardComplexItem):
"""

def __init__(self, **kwargs):
Door.__init__(self, **kwargs)
BoardComplexItem.__init__(self, **kwargs)
super().__init__(**kwargs)


class GenericStructureComplexComponent(GenericStructure, BoardItemComplexComponent):
Expand All @@ -1876,8 +1869,7 @@ class GenericStructureComplexComponent(GenericStructure, BoardItemComplexCompone
"""

def __init__(self, **kwargs):
GenericStructure.__init__(self, **kwargs)
BoardItemComplexComponent.__init__(self, **kwargs)
super().__init__(**kwargs)


class Tile(GenericStructure, BoardComplexItem):
Expand Down Expand Up @@ -1921,9 +1913,8 @@ def __init__(self, **kwargs):
kwargs["restorable"] = True
if "pickable" not in kwargs:
kwargs["pickable"] = False
GenericStructure.__init__(self, **kwargs)
super().__init__(**kwargs)
# kwargs["base_item_type"] = Door
BoardComplexItem.__init__(self, **kwargs)

def can_move(self):
"""A Tile cannot move.
Expand Down
2 changes: 1 addition & 1 deletion pygamelib/gfx/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ class SpriteCollection(UserDict):
"""

def __init__(self, data=dict()):
UserDict.__init__(self, data)
super().__init__(data)

@classmethod
def load(cls, data):
Expand Down
2 changes: 1 addition & 1 deletion pygamelib/gfx/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseParticle(board_items.Movable):
"""

def __init__(self, **kwargs):
board_items.Movable.__init__(self, **kwargs)
super().__init__(**kwargs)
self.size = [1, 1]
self.name = str(uuid.uuid4())
self.type = "base_particle"
Expand Down

0 comments on commit 69a4a19

Please sign in to comment.