Here’s something I put together. I haven’t totally stress-tested it but the cases I’ve tried have worked. (Note that I didn’t try to prevent the player from wearing more than one hat.)
[code]Use American dialect and the serial comma.
Testroom is a room.
Clothing is a kind of thing. Clothing is wearable.
Color is a kind of value. The colors are red, green, and blue. Clothing has a color. Understand the color property as describing clothing.
A hat is a kind of clothing.
Hat style is a kind of value. The hat styles are bowler, derby, and fedora. A hat has a hat style. Understand the hat style property as describing a hat.
Colors already printed is initially false. [A truth state flag. If I don’t put this in, it’ll say things like “You’re wearing a green green homurg hat and green tie” and that’s no good.]
Before printing the name of a hat when colors already printed is false: say "[color of the item described] [hat style of the item described] ".
The description of a hat is usually “It’s a [hat style of the item described] that is [color of the item described].”
Before printing the name of clothing when the item described is not a hat and colors already printed is false: say "[color of the item described] ".
A coat is a kind of clothing.
A tie is a kind of clothing.
A cravat is a kind of clothing.
A skirt is a kind of clothing.
pants are a kind of clothing. Pants are plural-named. The indefinite article of pants is usually “some”.
socks are a kind of clothing. Socks are plural-named. The indefinite article of socks is usually “some”.
A shirt is a kind of clothing.
Coloration relates a thing (called X) to a color (called Y) when the color of X is Y. The verb to be colored means the coloration relation.
Cocoloration relates a clothing (called X) to a clothing (called Y) when the color of X is the color of Y and X is not Y. The verb to be the same color as means the cocoloration relation.
The description of the player is “You’re wearing [color-sorted list of clothes of the player].”
To say color-sorted list of clothes of (subject - a person):
[let’s make a list of lists of cocolored clothing worn by the player]
let master clothes list be a list of lists of clothing;
let miscellaneous clothes list be a list of clothing;
repeat with hue running through colors:
let shade list be the list of (clothing worn by the player) that is colored hue;
if the number of entries in shade list is 1:
add shade list to miscellaneous clothes list;
otherwise if shade list is not empty:
add shade list to master clothes list; [this is tricky–adding shade list to misc. clothes list adds its entry to it, while adding it to master clothes list adds the list itself as a new entry–because adding a list to a list is different from adding it to a list of lists]
if master clothes list is empty:
if miscellaneous clothes list is empty:
say “nothing”;
otherwise:
say “[miscellaneous clothes list with indefinite articles]”;
otherwise:
now colors already printed is true;
let N be the number of entries in master clothes list;
repeat with counter running from 1 to N:
let shade list be entry counter of master clothes list;
sort shade list in indefinite article order; [this should put “a” and things that don’t have indefinite articles–which are also “a”–to the front, I hope]
say "[if the indefinite article of entry 1 of shade list is not empty][indefinite article of entry 1 of shade list][otherwise]a[end if] [color of entry 1 of shade list] ";
say shade list;
if counter is 1 and (N is greater than 1 or miscellaneous clothes list is not empty):
say ", with "; [this is why we keep track of counter instead of just repeating through master clothes list]
otherwise if counter is less than N or miscellaneous clothes list is not empty:
say " and ";
now colors already printed is false;
say “[miscellaneous clothes list with indefinite articles]”.
One red coat, one blue tie, one red cravat, one blue skirt, one green pants, one green socks, one green shirt, and one blue bowler hat are in testroom.[/code]
Some things to note:
The handling of pants is not super elegant. I figured that it was OK to say “a green shirt, socks, and pants” and “some green socks and pants” but not so much “some green socks, shirt, and pants.” So I sort the shade list in order of the indefinite article to force the stuff whose indefinite article is “a” to the front–except somehow those things have an indefinite article of “” instead of “a,” so I had to include a special check for that. This may not be super robust if you have indefinite articles other than “some” and “”.
If any of your color names start with vowels then the indefinite articling will get hairy (since you’ll need “an orange shirt”). My advice: just don’t implement anything orange.
You will notice that I ditched the printing of the hat style in the description of yourself. You might be able to recover this with a more complicated “Before printing the name of” rule that suppresses the color but not hat style when the flag that tells it not to print colors is active, or you could just fold the hat style into the printed name of the hat.
Anyway, I realize this is a pretty complicated code example, but I hope it’s helpful!
…oh, and abbreviating “red pants and tailcoat” to “red suit” gives me the heebie-jeebies just thinking about it. Maybe you could write a routine for turning a list of individual clothing items into a list of more complicated descriptions, so it takes the shade list, sees if there’s a coat and pants in it, and turns that into “suit”? That seems like it’d have a lot of complicated ifs in it for sure.