I am looking for best practices/advice on how to handle objects whose description changes during the game.
As an example: we have 2 buckets of paint, yellow and red.
Defined as follows (pseudo code):
OBJECT paintbucket1, “paint”, “bucket”, “can”, “yellow”
OBJECT paintbucket2, “paint”, “bucket”, “can”’ “red”
We allow the player to pour the paint from one can in the other, thus creating a can with orange paint and an empty can.
If done so, both cans have to stop responding to their original color, one can has to start responding to “orange” and the other one to “empty”.
In general, when an object changes, I have a new object standing by in an inaccessible storage and I simply swap the objects. This works well if the new object also has completely different properties (like a stone coal transforming into a diamond).
But in this case, the objects stay almost the same, only an attribute - the color and full/empty - changes. It can easily be modeled by defining properties/attributes for color and filled, but how to make sure the interpreter takes it into account when parsing the user input?
One way I can think of is to have functions in the modeling language to add or remove object descriptions. Something like (pseudo code):
REMOVE “red” FROM paintbucket1
ADD “orange” TO paintbucket1
Another way could be to have “special” properties or attributes that are also consulted by the interpreter when mapping user input to objects. Again in pseudo code:
ATTRIBUTE color USED_BY_INTERPRETER
ATTRIBUTE full-empty USED_BY_INTERPRETER
Would these be viable approaches? Or are there better ways?
Thanks for reading…