In this game, I’ve separated the inventory into clothing, worn objects that aren’t clothing (eg, binoculars around the neck) and carried objects, listing contents of containers separately after the appropriate category:
"Test" by Colleen Boye
[clothing and inventory management]
A garment is a kind of wearable thing.
Definition: a thing is a non-garment if it is not a garment.
[suppresses listing contents of things like the pistol cylinder]
A container can be interesting or uninteresting. A container is usually interesting.
[lists the contents of a container]
Pedantically listing something is an activity on things.
Rule for pedantically listing a thing (called X):
if X is open or X is transparent:
if X contains something and X is interesting:
if X contains exactly one thing:
say "[The X] [contain] ";
list the contents of X, giving brief inventory information;
say ".[line break]";
otherwise:
say "[The X] [contain]: [line break]";
list the contents of X, with newlines, indented, giving brief inventory information, with extra indentation.
[custom way of listing inventory]
Instead of taking inventory:
if the number of things enclosed by the player is 0, say "You are empty-handed." instead;
if the player wears a garment:
now all things enclosed by the player are unmarked for listing;
now all garments worn by the player are marked for listing;
say "The clothing you are wearing: [line break]";
list the contents of the player, with newlines, indented, with extra indentation, giving brief inventory information, listing marked items only;
[contents of clothing containers listed individually]
repeat with X running through garments worn by the player:
carry out the pedantically listing activity with X;
[containers enclosed by clothing]
repeat with Y running through interesting containers enclosed by X:
carry out the pedantically listing activity with Y;
if the player wears a non-garment: [binoculars, etc]
now all things enclosed by the player are unmarked for listing;
now every non-garment worn by the player is marked for listing;
say "You are also wearing: [line break]";
list the contents of the player, with newlines, indented, with extra indentation, giving brief inventory information, listing marked items only;
[contents of worn non-clothing containers listed individually]
repeat with X running through non-garment things worn by the player:
carry out the pedantically listing activity with X;
[containers enclosed by non-clothing]
repeat with Y running through interesting containers enclosed by X:
carry out the pedantically listing activity with Y;
if the player carries something:
now all things enclosed by the player are unmarked for listing;
now all things carried by the player are marked for listing;
say "You are carrying: [line break]";
list the contents of the player, with newlines, indented, giving brief inventory information, with extra indentation, listing marked items only;
[lists contents of carried containers individually]
repeat with X running through things carried by the player:
carry out the pedantically listing activity with X;
[containers enclosed by carried objects]
repeat with Y running through interesting containers enclosed by X:
carry out the pedantically listing activity with Y.
[example]
The airport is a room.
The player is in the airport.
The coat is a garment.
The pockets are part of the coat. They are plural-named. They are a container.
Rule for printing the name of the pockets while taking inventory: say "coat pockets".
A train ticket is in the pockets.
A pen is in the pockets.
The binoculars are a wearable thing. They are plural-named.
Rule for printing the name of the binoculars while taking inventory:
say "pair of binoculars".
The wrong suitcase is a container.
A thing called someone else's clothing is in the wrong suitcase.
The player wears the coat. The player wears the binoculars. The player carries the wrong suitcase.
test me with "i".
There are a few further refinements I’d like add. First, as with the binoculars, sometimes I want a plural-named item to be treated as singular only when taking inventory. It should show up as “a pair of binoculars,” not “some pair of binoculars.”
Second, if there are multiple identical containers with identical contents, I’d like them to group together (eg, “Each box of Girl Scout cookies contains 20 thin mints.”). But naturally, they should be separate if they have different contents, and with appropriate adjectives modifying the names (“One box of Girl Scout cookies contains 20 thin mints. Another box of Girl Scout cookies contains 16 samoas. A third box of Girl Scout cookies contains 25 trefoils.”).
Third, I’d like to mark items that weren’t in your inventory last time you checked (bold, with an asterisk, whatever).
Can anyone help me with these problems?