Created
September 8, 2020 00:28
-
-
Save JHay0112/1ddcc5bc5895fb816458db6a009f83bb to your computer and use it in GitHub Desktop.
Item Types vs. Child Objects Trial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
child.py | |
Author: Jordan Hay | |
Date: 2020-09-08 | |
Item/inventory objects for Dracula's Castle | |
''' | |
# - Imports | |
# - Classes | |
# The base Item class | |
class Item: | |
# - __init__() | |
# Initialise Item Object | |
# | |
# self | |
# name (str) - The name of the item | |
def __init__(self, name): | |
# Set item attributes | |
self._name = name | |
# Weapon class, child of Item | |
class Weapon(Item): | |
# - __init__() | |
# Initialise Weapon Object | |
# | |
# self | |
# name (str) - The name of the weapon | |
# attack_damage (int) - The damage the weapon does | |
def __init__(self, name, attack_damage): | |
# Set weapon attributes | |
self._attack_damage = attack_damage | |
# Set attributes associated with parent item | |
super().__init__(name) | |
# Inventory class, used for item management | |
class Inventory: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
types.py | |
Author: Jordan Hay | |
Date: 2020-09-09 | |
Item/inventory objects for Dracula's Castle | |
''' | |
# - Imports | |
# - Classes | |
# The base Item class | |
class Item: | |
# Item Types | |
WEAPON = "weapon" # Weapon type items, e.g. swords | |
POTION = "potion" # Potion type items, e.g. healing potion | |
ARMOUR = "armour" # Armour type items, e.g. shield | |
KEY = "key" # Key items, e.g. Key to the crypt | |
OTHER = "other" # All other item types | |
def __init__(self, name, item_type = OTHER): | |
# Set object attributes | |
self._name = name | |
self._item_type = item_type | |
# Inventory class, used for item management | |
class Inventory: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment