1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/resources/Documentation/Examples/Shirts.txt
2019-03-16 13:12:11 +00:00

75 lines
4.1 KiB
Plaintext

* Precedence
(Shirts constructed from component parts; Some Assembly Required)
Building different styles of shirt from component sleeves and collars.
We now have the mechanisms in place to do some fairly sophisticated renaming of objects. For instance:
{*}"Some Assembly Required"
Garment type is a kind of value. The garment types are vest, t-shirt, polo shirt, mandarin blouse, button-down, shell, experiment.
Every turn:
assign identities.
When play begins: assign identities.
To assign identities:
repeat with item running through torsos:
reassess item.
To reassess (item - a torso):
if the number of things which are part of the item is 0:
now garment type of the item is vest;
rule succeeds;
if exactly two short sleeves are part of the item:
if a collar is part of the item,
now garment type of the item is polo shirt;
otherwise now garment type of the item is t-shirt;
rule succeeds;
if exactly two long sleeves are part of the item:
if a collar is part of the item,
now garment type of the item is button-down;
otherwise now garment type of the item is mandarin blouse;
rule succeeds;
if a collar is part of the item and the number of sleeves which are part of the item is 0, now garment type of the item is shell;
otherwise now garment type of the item is experiment.
Before cutting something which is worn by the player:
try taking off the noun.
Instead of cutting something when something is part of the noun:
say "You cut up [the noun], snipping off [a list of things which are part of the noun].";
now every thing which is part of the noun is in the holder of the noun.
Instead of cutting something which is part of something:
say "You carefully snip [the noun] free.";
now the player carries the noun.
Rule for printing the name of a torso: say "[garment type]".
A torso is a kind of thing. A torso is always wearable. Understand "shirt" or "blouse" as a torso. A torso has a garment type. Understand the garment type property as describing a torso. A sleeve is a kind of thing. A short sleeve is a kind of sleeve. A long sleeve is a kind of sleeve. A collar is a kind of thing.
Understand "sew [something] to [something]" as affixing it to. Affixing it to is an action applying to two things. Carry out affixing something to something: now the noun is part of the second noun. Report affixing something to something: assign identities; say "You sew [the noun] on, creating [a second noun]." Understand the command "stitch" as "sew".
Instead of affixing something to something when the second noun is worn: say "You're wearing [the second noun]!"
Instead of affixing a torso to something:
if the second noun is a torso, say "Couture for Siamese twins is a daring field, but a bit of a niche market.";
otherwise try affixing the second noun to the noun.
Instead of affixing a sleeve to something when at least two sleeves are part of the second noun: say "[The second noun] already sports [a list of sleeves that are part of the second noun]."
Instead of affixing a collar to something when a collar is part of the second noun: say "[The second noun] already sports [a list of collars that are part of the second noun]."
Instead of examining something when something is part of the noun: say "Stitched to [the noun] [is-are a list of things which are part of the noun]."
Here is where the issue of precedence arises. We want to encourage Inform to select a cuttable object that is part of something else, rather than one of the spares:
{**}Definition: a thing is removable if it is part of something. Understand "cut [removable thing]" as cutting.
The Boutique is a room. "Still festively strewn with the confetti and streamers of the Grand Opening party, and still almost totally customer-free."
The player carries a torso. The player carries three short sleeves. The player carries two long sleeves. The player carries two collars.
Test me with "sew collar to shirt / i / sew short sleeve to shirt / g / i / x polo shirt / cut collar / i / cut shirt / sew long sleeve to shirt / i / sew long sleeve to shirt / i / sew collar to shirt / g / i / wear button-down".