item1 = {
name: 'chest'
contains: [
"inside": [ 'closeable', 'lockable', 'locked' ],
"behind": [ 'searchable' ],
"on top of": []
]
}
item2 = {
name: 'curtain'
contains: [
"behind": [ 'searchable', 'closeable', 'closed' ]
]
}
I ran into an interesting question last night and was wondering what others had done to address. Currently, I am dealing with containment in what seems to be the popular way: Players have inventory, locations have inventory, containers have inventory. Inventories are lists of objects.
I may be making a bigger deal about this than I should be but.. what about situations where you can have an object on something as well as in it? Or under it? Like, a desk. A desk can have things on top of it and inside of it. A bed could have something on it and under it. Currently, I have the notion of containment behavior which can be attached to any object. If it has the behavior it can contain stuff (pack, pouch, chest, bag, etc). So to deal with this issue I am contemplating two approaches:
1. Add behaviors for prepositional classes. On top. under. Behind. Etc. Each such behavior would have an inventory. Which could be kind of a pain and lead to searching multiple lists to process certain commands.
2. Reconstruct my notion of containment to include type. So instead of a list of objects there would be a tag indicating, for each object (in an inventory) its relationship to its container. So a desk would have a list of things, some of which were on top of it and some that were inside of it (or underneath or behind).
Or, perhaps, I should just not care? I think the only reason I am thinking about caring is because it would add detail to the environment. So if the user says "Take everything" then they might miss something under the bed. Or, there might be a scenario where putting something "on the table" would trigger an action from an NPC. Rather than just saying "drop item".
As a side note, this is leading me to deal with another issue where behaviors on objects need to know about each other. If I have a container, lock, and open/close behavior then the container needs to know if it is opened before items can be retrieved. Similarly, you can't open a container if its locked. I feel like I am close to a reasonably elegant solution. Just not quite there yet. As always, use cases are necessarily triggering changes to the architecture.
As always, thanks for any input.
David