In Fire or in Flood

Example 400
★★★

A BURN command; flammable objects which light other items in their vicinity and can burn for different periods of time; the possibility of having parts or contents of a flaming item which survive being burnt.

"In Fire or in Flood"
Part I - Rules for combustion
Heat is a kind of value. The heats are whole, damp, and flaming. A thing has a heat. A thing is usually whole.
A thing has a number called endurance. The endurance of a thing is usually 5. A thing has a number called turns of burning. A thing can be flammable or flame-retardant.
Before printing the name of something flaming:
   say "flaming ".
Before burning something when the player is not carrying something flaming:
   if a flaming portable thing (called the lighter) is touchable:
      say "(with [the lighter], which you first take)[command clarification break]";
      try taking the lighter.
Instead of burning something when the player is not carrying something flaming:
   say "You would first need a fire source."
Instead of burning something flame-retardant:
   say "[The noun] is not the sort of thing that catches fire."
Instead of burning something flammable when the player is carrying something flaming (called the flame source):
   say "You light [the noun] with [the flame source].";
   now the heat of the noun is flaming.
Instead of burning something when the player is in the noun:
   say "That seems dangerous given that you yourself are in [the noun]."
Instead of burning something when the player is on the noun:
   say "That seems dangerous given that you yourself are on [the noun]."
Instead of examining something:
   say "Hm, the [printed name] appears to be [heat]."
Before taking a flaming thing:
   let turns remaining be the endurance of the noun minus the turns of burning of the noun;
   if turns remaining is less than two, say "There's no portion of [the noun] sufficiently cool for you to pick up." instead.

But that's only a small part of the battle. The thing about fire is that it keeps on doing fiery things even when the player is otherwise occupied: destroying items that are on fire, and spreading to other things nearby. So we need a set of rules for the fire's behavior.

Every turn when something is flaming:
   follow the fire rules.
The fire rules is a rulebook.
A fire rule (this is the can't hold flaming objects rule):
   repeat with item running through flaming things:
      if the item is held by the player:
         let turns remaining be the endurance of the item minus the turns of burning of the item;
         if turns remaining is less than two:
            say "[The item] becomes too hot to hold! ";
            try dropping the item;
            if the item is held by the player, say "This is certainly painful."
A fire rule (this is the flames spread rule):
   repeat with item running through flaming things:
      if the turns of burning of the item is one:
         spread the flames from the item.
A fire rule (this is the fire destroys things rule):
   now started printing is false;
   repeat with item running through flaming things:
      increment the turns of burning of the item;
      if the turns of burning of the item is greater than the endurance of the item, destroy the item;
   if started printing is true, say "[paragraph break]";
   now started printing is false.

Because we've labelled all the fire rules, we could swap their order, or turn some of them off, while allowing the others run as usual. For instance, if there were a pair of fireproof gloves in the game, we might want to turn off the "can't hold flaming objects rule" whenever the player is wearing them.

This sort of flexibility is especially useful in the context of extensions. Someone writing an extension about burning would have no way of anticipating the need for a Fireproof Gauntlet of Thog, but the author would nonetheless be able to implement one easily.

Definition: a thing is vulnerable if it is flammable and it is whole.

The contact between things is a critical factor when it comes to fire, so we might add a couple of conditional relations do determine what is touching what.

Reliance relates a thing (called X) to a thing (called Y) when X is part of Y or X is in Y or X is on Y. The verb to be relying on means the reliance relation.
Contact relates a thing (called X) to a thing (called Y) when X is relying on Y or Y is relying on X. The verb to be joined to means the contact relation.

Having these at our disposal makes it much tidier to write what happens next:

To spread the flames from (item - a thing):
   now started printing is false;
   if the item is joined to a flammable whole thing (called the sacrifice):
      if the sacrifice is visible:
         now started printing is true;
         say "Flames engulf [the list of flammable whole things which are joined to the item].";
      now all the flammable whole things joined to the item are flaming.
Started printing is a truth state that varies. Started printing is false.
To destroy (item - a thing):
   let home be the holder of the item;
   if the item is part of something (called the superstructure), let home be the holder of the superstructure;
   if the item is visible:
      now started printing is true;
      say "[The item] burns away[if something is relying on the item], leaving [a list of things which are relying on the item] behind[end if]. ";
   if something is relying on the item,
      now all the things which are relying on the item are in the home;
   now the item is nowhere;
   now the item is damp;
   now every flaming thing which is part of the item is damp.
To destroy (item - a door):
   let home be the holder of the item;
   if item is visible:
      now started printing is true;
      say "[The item] burns away[if something flame-retardant is part of the item], leaving [a list of flame-retardant parts of the item] behind[end if]. ";
   if home is a room, now all of the flame-retardant parts of the item are in the home;
   now the item is damp;
   now the item is open;
   now the item is unopenable.
Before printing the name of a damp door:
   say "burnt-out frame of ".
Instead of opening or closing a damp door:
   say "[The noun] can no longer be opened or closed in any meaningful sense."
Instead of doing something other than examining or dropping to a flaming thing when the turns of burning of the noun is greater than 1:
   say "Fire has too thoroughly engulfed [the noun] for that to be a good idea."
Instead of taking something when the noun is in a flaming thing (called the receptacle):
   say "You don't quite dare reach into [the receptacle]."
Instead of touching something which is within a flaming thing (called the receptacle):
   say "It seems a little risky since [the receptacle] is on fire."
Instead of turning something when the noun is contained in a flaming thing (called the receptacle):
   say "It seems a little risky since [the receptacle] is on fire."
Instead of pushing or pulling something when the noun is inside a flaming thing (called the receptacle):
   say "[The receptacle] deters you."
Before burning something which is in a container when the holder of the noun contains the player:
   say "This could make things toasty for you..."

And that completes the rules which cover burning: things can catch fire, fire will spread, and gradually consume the world in flames. All of that was general and could be used in any setting, but we now provide a small game to show it off.

Part II - Escape from the Library of the Dead
The Library of the Dead is a room. "This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out."
The desk is a flammable supporter in the Library. A drawer is part of the desk. The drawer is a flammable closed container. It is openable, lockable, and locked. The desk is scenery.
A box is in the Library. A metal hinge is part of the box. The hinge is flame-retardant. The box is open, flammable, and openable. The shroud of Laertes is a flammable thing in the box.
Instead of examining something when something is part of the noun:
   say "You note [the list of things which are part of the noun]."
The world's last manuscript of the Psychagogoi by Aeschylus is on the desk. The manuscript is flammable. The manuscript has endurance 1.
The torch is a flammable flaming thing carried by the player. It has endurance 60. The asbestos sack is a flame-retardant player's holdall in the drawer.
The trapdoor is up of the Library and east of the Plaza. The trapdoor is a door. It is flammable, closed, lockable, and locked. "A trapdoor in the ceiling is your only hope of escape[if flaming]. Fortunately, it is rapidly burning through[end if]." The trapdoor has endurance 15.
Instead of going through the closed trapdoor, say "[The trapdoor] is closed."

We can then add a special fire rule to handle the trapdoor, which will be called as part of the same sequence. Again, this would be most important if the fire rules were part of a standard extension, and the trapdoor fire rule the author's own addition.

A fire rule:
   if the trapdoor is flaming and a random chance of 1 in 3 succeeds:
      let the caught thing be a random flammable whole thing which can be touched by the trapdoor;
      if the caught thing is a thing:
         say "A spark from [the trapdoor] catches [the caught thing]!";
         now the caught thing is flaming.
Instead of going to the Plaza:
   say "Out at last!";
   end the story finally.
Test me with "get manuscript / get shroud / light desk / look / g / open drawer / look / g / g / g / get sack / put shroud in sack / put manuscript in sack / close sack / light trapdoor / look / g / g / g / g / g / g / g / g / g / g / g / g / g / g / up".
Test me with "get manuscript / get shroud / light desk / look / g / open drawer / look / g / g / g / get sack / put shroud in sack / put manuscript in sack / close sack / light trapdoor / look / g / g / g / g / g / g / g / g / g / g / g / g / g / g / up".
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

On the desk is a world's last manuscript of the Psychagogoi by Aeschylus.

You can also see a box (in which is a shroud of Laertes) here.

>(Testing.)

>[1] get manuscript
Taken.

>[2] get shroud
Taken.

>[3] light desk
You light the desk with the flaming torch.

>[4] look
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see a box (empty) here.

Flames engulf the drawer.

>[5] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see a box (empty) here.

>[6] open drawer
Fire has too thoroughly engulfed the flaming drawer for that to be a good idea.

>[7] look
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see a box (empty) here.

>[8] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see a box (empty) here.

The flaming desk burns away, leaving a flaming drawer behind.

>[9] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see a flaming drawer (closed) and a box (empty) here.

The flaming drawer burns away, leaving an asbestos sack behind.

>[10] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape.

You can also see an asbestos sack (empty) and a box (empty) here.

>[11] get sack
Taken.

>[12] put shroud in sack
You put the shroud of Laertes into the asbestos sack.

>[13] put manuscript in sack
You put the world's last manuscript of the Psychagogoi by Aeschylus into the asbestos sack.

>[14] close sack
You close the asbestos sack.

>[15] light trapdoor
You light the trapdoor with the flaming torch.

A spark from the flaming trapdoor catches the box!

>[16] look
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

>[17] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

>[18] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

>[19] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

>[20] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

>[21] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a flaming box (empty) here.

The flaming box burns away, leaving a metal hinge behind.

>[22] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[23] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[24] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[25] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[26] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[27] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[28] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[29] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

>[30] g
Library of the Dead
This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out.

A trapdoor in the ceiling is your only hope of escape. Fortunately, it is rapidly burning through.

You can also see a metal hinge here.

The flaming trapdoor burns away.

>[31] up
Out at last!



*** The End ***