Update Beginner-Tutorial-Equipment.md

When adding an item to an empty slot, avoid adding `None` objects to the backpack.
This commit is contained in:
feyrkh 2024-09-29 13:08:56 -05:00 committed by GitHub
parent d361b5fddb
commit 7f123cb472
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -407,13 +407,14 @@ class EquipmentHandler:
for to_backpack_obj in to_backpack:
# put stuff in backpack
slots[WieldLocation.BACKPACK].append(to_backpack_obj)
if to_backpack_obj:
slots[WieldLocation.BACKPACK].append(to_backpack_obj)
# store new state
self._save()
```
Here we remember that every `EvAdventureObject` has an `inventory_use_slot` property that tells us where it goes. So we just need to move the object to that slot, replacing whatever is in that place from before. Anything we replace goes back to the backpack.
Here we remember that every `EvAdventureObject` has an `inventory_use_slot` property that tells us where it goes. So we just need to move the object to that slot, replacing whatever is in that place from before. Anything we replace goes back to the backpack, as long as it's actually an item and not `None`, in the case where we are moving an item into an empty slot.
## Get everything