Closed andye456 closed 4 years ago
This was due to the fact the Python dictionaries are used by-reference so if you create a python dictionary and assign it to more than one variable then change it in one instance it will change it for all instances. I fixed this by assigning a copy() of the variable to the item store.
e.g. a = {"foo":5, "bar":10} b,c = [],[] b.append(a) c.append(a)
b[0]['foo']=200 print(c[0]['foo']) 200
What you need to do is: b.append(a.copy()) c.append(a.copy()) Then they will be "passed by value" and altering b won't affect c
Scenario: Healing1 is used until it is depleted (0 uses left). At which point it is removed from the inventory. If a new healing1 is picked up then it will have it's uses initialised to 0, but it can be used an infinite number of times. It should have it's uses initialised to 5. The "uses" is part of the healing1 object and has the value set to 0 when it is in the room and available to pick up.