back to single responsibility again. "removeObject" tried to do too much and ties us in knots elsewhere.
When transferring an object form a location, creature or player to another, the pattern to follow should be
getObject (to get it's details)
verify it exists
test that it can be transferred
remove the object from the source
add the object to the destination.
The add and remove need a "transfer" function that adds and removes with all validation removed so that these are guaranteed to succeed without "losing" or duplicating objects.
This means we need to rely on much more validation - maybe with a "canTransfer" function first.
Either way it needs cleaning up.
This should also help with inventory object bleed across other objects.
back to single responsibility again. "removeObject" tried to do too much and ties us in knots elsewhere.
When transferring an object form a location, creature or player to another, the pattern to follow should be getObject (to get it's details) verify it exists test that it can be transferred remove the object from the source add the object to the destination.
The add and remove need a "transfer" function that adds and removes with all validation removed so that these are guaranteed to succeed without "losing" or duplicating objects.
This means we need to rely on much more validation - maybe with a "canTransfer" function first.
Either way it needs cleaning up. This should also help with inventory object bleed across other objects.