I’m making a text-based rpg with python 3.3 and I am wanting a more dynamic inventory system for my game. I am currently using variables assigned to each item but with functions, the variables I am passing as arguments are becoming too many and quite cluttered. If there is a better way out there I would love help creating a better system.
Here is how my inventory call system looks right now:
print('Item1',item1)
print('Item2',item2)
print('Item3',item3)
and so on.
Well, I have an old text game I made and the inventory system I use is just a list named ‘inv’. Then all you have to do when you gain an item of whatever type is to append the inventory list with the string.
Then you can create a dictionary with the key as the item name and the value be a list you can reference. Try this:
And the list can be a bunch of different attributes such as buy sell price, strength or what have you. Hope this helps.