I was almost there, but I had some problems once I tried to introduce another NPC. It seems “the person asked” in the clothing conflict relationship doesn’t really work right when I used it while trying to list the items an NPC was wearing. So I needed a subtly different relationship called “garment covers”. The code below (maybe) fixes all the problems:
"What not to wear II" by Anonymous
Part 1 - Body areas
Body-area is a kind of value. The body-areas are feet, lower-body, legs, hips, upper-body, full-body, head, none.
[relates with areas include other areas]
Body-includes relates various body-area to various body-areas. The verb to body-include (it body-includes, they body-include, it body-included, it is body-including) implies the body-includes relation. The verb to be body-included by implies the reversed body-includes relation.
full-body body-includes hips, legs and upper-body. lower-body body-includes hips and legs.
[identity relationships]
feet body-includes feet. lower-body body-includes lower-body. legs body-includes legs. hips body-includes hips. upper-body body-includes upper-body. full-body body-includes full-body. head body-includes head.
Definition: A body-area is complex rather than not complex if it body-includes more than one body-area.
Part 2 - Garments
Chapter 1 - Defining base kinds
A garment-element is a kind of thing. A garment-element has a number called the layer-level. A garment-element has a body-area called the area.
[not actually needed - but you might add body-parts and then test if they are covered in a similar way to testing if a garment covers another garment]
A body-part is a kind of garment-element. A body-part has layer-level 0.
A garment is a kind of garment-element. A garment is wearable. A garment can be transparent.
A pair of pants is a kind of garment. The plural of pair of pants is pairs of pants. The area of a pair of pants is lower-body. A pair of pants usually has layer-level 5.
A pair of underpants is a kind of garment. The plural of pair of underpants is pairs of underpants. The area of a pair of underpants is hips. A pair of underpants usually has layer-level 2.
A foundation garment is a kind of garment. The area of a foundation garment is upper-body. A foundation garment usually has layer-level 2.
A pair of socks is a kind of garment. The plural of pair of socks is pairs of socks. The area of a pair of socks is feet. A pair of socks usually has layer-level 2.
A pair of shoes is a kind of garment. The plural of pair of shoes is pairs of shoes. The area of a pair of shoes is feet. A pair of shoes usually has layer-level 5.
A jacket is a kind of garment. The area of a jacket is usually upper-body. A jacket usually has layer-level 10.
A hat is a kind of garment. The area of a hat is head. A hat usually has layer-level 5.
A dress is a kind of garment. The area of a dress is full-body. A dress usually has layer-level 5.
A skirt is a kind of garment. The area of a skirt is lower-body. A skirt usually has layer-level 5.
A tie is a kind of garment. The area of a tie is upper-body. A tie usually has layer-level 7. A tie is always transparent.
A shirt is a kind of garment. The area of a shirt is upper-body. A shirt usually has layer-level 5.
Chapter 2 - Relationships
Covering relates a garment (called item) to a body-area (called test-area) when the area of the item body-includes the test-area. The verb to cover (it covers, they cover, it is covering, it is covered) implies the covering relation.
Definition: a garment-element (called item) is uppermost if the item is uppermost on a random person wearing the item.
To decide if (item - a garment) is uppermost on (actor - a person):
if (actor is nothing):
decide yes;
if the area of the item is not complex:
[if the item is not unwearable because of something opaque:]
if the item is not overlaid by something opaque:
decide yes;
otherwise:
decide no;
otherwise:
repeat with test-area running through body-area body-included by the area of the item:
if the actor is wearing an opaque garment (called the coverer) which covers the test-area and the layer-level of the coverer is greater than the layer-level of the item:
next;
otherwise:
decide yes;
decide no;
Garment covers relates a garment (called the top layer) to a garment (called the bottom layer) when the bottom layer is worn by a random person wearing the top layer and the top layer conflicts with the bottom layer.
The verb to be overlaid by implies the garment covers relation.
Clothing conflict relates a garment (called the top layer) to a garment (called the conflicting layer) when the conflicting layer is worn by the person asked and the top layer conflicts with the conflicting layer.
The verb to be unwearable because of implies the clothing conflict relation.
The verb to prevent wearing (he prevents wearing, they prevent wearing, he prevented wearing, he is preventing wearing) implies the reversed clothing conflict relation.
To decide if (top layer - a garment) conflicts with (conflicting layer - a garment):
[simplest case - if the two garment are the same, they don't conflict]
if the top layer is the conflicting layer:
decide no;
[simple case - if the top layer has a higher level, it doesn't conflict]
if the layer-level of the top layer is greater than the layer-level of the conflicting layer:
decide no;
[some part of the top layer area = some part of the conflicting layer area]
otherwise if a body-area body-included by the area of the conflicting layer is body-included by the area of the top layer:
decide yes;
otherwise:
decide no;
Chapter 3 - Rules for handling garments
Section 1 - removing
Before an actor taking off something which is unwearable because of something which is worn by the actor:
while the noun is unwearable because of something (called the impediment) which is worn by the actor:
say "(first removing [the impediment])[command clarification break]";
silently try actor taking off the impediment;
if the noun is unwearable because of the impediment, stop the action.
Check an actor taking off a garment:
if the noun is unwearable because of something (called the impediment) which is worn by the actor, say "[The impediment] is in the way." instead.
Report taking off something:
say "You are now wearing [a list of uppermost things worn by the player]." instead.
Section 2 - wearing
Before an actor wearing something unwearable because of a garment worn by the actor:
while the actor wears a garment (called the impediment) which prevent wearing the noun:
say "(first removing [the impediment])[command clarification break]";
silently try actor taking off the impediment;
if the actor is wearing the impediment, stop the action.
Instead of taking inventory:
say "You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of uppermost garments worn by the player][end if]."
Section 3 - The Scenario
The Dressing Room is a room.
some capris, some jeans, a corset, a plunge bra, a thong, boy-shorts, black satin D'Orsay pumps, brown leather boots, a camisole, a cocktail dress, a bolero, a cashmere shrug, a sheer wrap, and a linen tunic are in the dressing room.
The woolly socks are a pair of socks.
The D'Orsay pumps and the brown leather boots are pairs of shoes.
The thong and the boy-shorts are pairs of underpants.
The capris and the jeans are pairs of pants.
The tunic is a shirt.
The camisole, the corset, and the plunge bra are foundation garments.
The cocktail dress is a dress.
The bolero, the cashmere shrug, and the sheer wrap are jackets. The shrug and the wrap are transparent.
Jane Doe is a person in the dressing room. The description of Jane is "Jane is carrying [a list of things carried by Jane][if Jane wears something]. Jane is wearing [a list of uppermost garments worn by Jane][end if]."
Persuasion rule for asking somebody to try doing something:
persuasion succeeds.
Test me with "take all / wear capris / wear jeans / i / wear thong / i / wear dress / wear corset / wear dress / i / wear wrap / i / wear boots / wear pumps / i".
Test jane with "jane, take all / jane, wear thong / jane, wear dress / x jane / jane, wear bra / x jane / jane, wear dress / jane, wear bolero / x jane / jane, remove dress".