Open K-Mistele opened 6 years ago
Hmm. based on how code is written now, this would be less than optimal. It would be extremely difficult to do without creating circular dependencies. Thoughts?
We can just create a load inventory function that accepts a name and a save inventory function that writes to a file in csv or json or even plaintext...
@Michael-N I'm not sure I understand what you're saying there....
@K-Mistele Create a inventory.py with class inventory
Here is some pseudo code for how it might be implemented in adventure.py to clean up the spaghetti code ect...
# does not contain the players inventory ... just loads it from a separate txt file
import Inventory
# playerInventory now represents the players inventory data
playerInventory = Inventory('<playername>-inventory.txt')
# use and auto update the inventory
playerInventory.use('<potionName>', instanceArgs=[passedVar,suchAs, playerObject]) # calls a potion class function associated with that name else raises an error or exception
#save changes made to the inventory to the file
playerInventory.save()
# this code prepares for resuming games, as well as minifies spaghetti code and makes inventory more manageable
This will involve serializing classes and reconstructing a few
Currently, potions and inventory items are stored in
adventure.py
Could they be stored in a separate file without creating a circular dependency?The file would need to import
inventory_classes.py
, but would still need a way to put the inventory items into the player's inventory in adventure.py