ADJEC red,green,blue,clear;
ADJEC glass, silver;

NOUN red message(road2);        // It's red so there can be others elsewhere
red message(WEIGH) = CAPAC;
red message(LDESC) = Proc() {"There is a message scratched in the dirt.\n";}
red message(SDESC) = Proc() {"a message in the dirt";}
red message(ACTION) = Proc()
{
    If ((Verb == read) | (Verb == examine)) {
	"'in' is a preposition.  'enter' is a verb.\n";
	$exit(1);
    }
}

NOUN keys (town4);
keys(WEIGH) = 2;
keys(LDESC) = Proc() {"There's a set of keys here.\n";}
keys(SDESC) = Proc() {"a set of keys";}
ADJEC tool;

NOUN tool box (farm5);
toolbox = tool box;
toolbox(WEIGH) = CAPAC;
toolbox(HOLDS) = 50;
toolbox(OPENS) = TRUE;
toolbox(LOCKS) = TRUE;
toolbox(LOCKED) = TRUE;
toolbox(LIGHT) = TRUE;
toolbox(LDESC) = Proc()
{
    If ($loc($ME) == toolbox) {
        "You are in a huge wooden structure, towering up at least 80 feet "
        "above your head, with wooden walls formed of immense 10-foot by "
        "50-foot boards.  Everything here, even the grains of dust which "
        "cover the wooden floor, seems immense.  ";
	If (toolbox.OPENED)
            "Above your head, the top of the structure is open, "
            "and sunlight streams in.\n";
        Else
            "The structure is closed at the top, but enough light "
            "comes in from between the boards to enable you to see.\n";
    }
    Else {
	"Against the house is a heavy ";
	If (toolbox.OPENED)
	    "toolbox with the lid open.\n";
	Else If (toolbox.LOCKED)
            "toolbox with a rusty lock, painted with an insignia "
            "composed of blue and green squares, joined at their "
            "corners.\n";
	Else
	    "toolbox, the lid of which is ajar.\n";
    }
}
toolbox(SDESC) = Proc()
{
    If ($loc($ME).toolbox)
	Return Sayer("Inside Huge Box", $arg(0));
    Else
	"a toolbox";
}
toolbox(ACTION) = Proc()
{
    If ($phase() == 7) {
	// This is the room action
	If ((Verb == drop) | (Verb == throw)) {
	    // We don't want to keep track of lots of small things
	    "You just lost ";
	    $sdesc(Dobj)();
	    " in a crack between the wooden floorboards!\n";
	    $move(Dobj, $ALL);
	}
    }
    Else If (Verb == lock) {
	If (toolbox == OPENED) {
	    "You must close it first.\n";
	    $exit(1);
	}
        Else If (toolbox == LOCKED) {
	    "It's already locked!\n";
	    $exit(1);
	}
        Else If ($loc(keys) == $ME) {
	    "The toolbox seals with a CLICK!\n";
	    toolbox.LOCKED = TRUE;
	    $exit(1);
	}
    }
    Else If (Verb == unlock) {
	If (!toolbox.LOCKED) {
	    "It's already unlocked!\n";
	    $exit(1);
	}
        Else If ($loc(keys) == $ME) {
	    "One of the keys fits!  The box is unlocked.\n";
	    toolbox.LOCKED = FALSE;
	    $exit(1);
	}
    }
    Else If (Verb == examine) {
	If (toolbox.OPENED)
	    "The toolbox is open.\n";
	Else If (toolbox.LOCKED)
	    "The toolbox is locked.\n";
	Else
	    "The toolbox is ajar.\n";
	$exit(1);
    }
}

NOUN silver spoon(farm6);
silver spoon(POINT) = 25;
silver spoon(WEIGH) = 1;
silver spoon(LDESC) = Proc() {"There is a beautiful silver spoon here.\n";}
silver spoon(SDESC) = Proc() {"a silver spoon";}


NOUN wetsuit(cel15);
WORN = MISC1;
wetsuit(LDESC) = Proc() {"There is a wetsuit here.\n";}
wetsuit(SDESC) = Proc()
{
    "a wetsuit";
    If (wetsuit.WORN) " (being worn)";
}
wetsuit(WEIGH) = 50;
wetsuit(ACTION) = Proc()
{
    If (Verb == wear) {
	If ($loc(wetsuit) != $ME) {
	    "You don't have the wetsuit!\n";
	    $exit(1);
	}
        Else If (wetsuit.WORN) {
	    "You are already wearing it!\n";
	    $exit(1);
	}
        Else {
	    wetsuit.WORN = TRUE;
	    "OK, you're wearing the wetsuit.\n";
	    $exit(1);
	}
    }
    Else If (Verb == remove) {
	If (wetsuit.WORN) {
	    wetsuit.WORN = FALSE;
	    "OK, you're no longer wearing the wetsuit.\n";
	    $exit(1);
	}
        Else {
	    "You are not wearing the wetsuit!\n";
	    $exit(1);
	}
    }
    Else If (Verb == drop) {
	If (wetsuit.WORN) {
	    "You'll have to remove the wetsuit first.\n";
	    Skip = TRUE;
	}
    }
}

NOUN signpost(Roadx);
signpost(RDLOC)=10;
signpost(WEIGH)=CAPAC;
signpost(LDESC) = Proc() {"There is a signpost by the side of the road.\n";}
signpost(SDESC) = Proc() {"a signpost";}
signpost(ACTION) = Proc()
{
    If ((Verb == read) | (Verb == examine)) {
        "Pointing east, it says: 'Unuchevala: 10 miles'\n";
        $exit(1);
    }
}

NOUN globe(toolbox);
globe(WEIGH) = 20;
globe(LDESC) = Proc()
{
    If (globe.LIGHT)
        "A globe of stone glows brightly here.\n";
    Else
        "There is a strange globe of polished stone here.\n";
}
globe(SDESC) = Proc()
{
    If (globe.LIGHT)
        "a glowing globe of stone";
    Else
        "a stone globe";
}
globe(ACTION) = Proc()
{
    If (Verb == rub) {
	If (globe.LIGHT) {
	    "The light from the stone globe fades away.\n";
	    globe.LIGHT = FALSE;
	}
        Else {
	    "The stone globe glows brightly!\n";
	    globe.LIGHT = TRUE;
	}
	MyLoc = -1;
	$exit(1);
    }
    Else If (Verb == examine) {
	If (globe.LIGHT) {
	    "The globe is glowing.\n";
	    $exit(1);
	}
    }
}


NOUN crowbar (town3);
crowbar(WEIGH) = 100;
crowbar(LDESC) = Proc() {"There is a long crowbar here.\n";}
crowbar(SDESC) = Proc() {"a crowbar";}

crydie = Proc()
{
    "What POWER!  The magic crystal releases a flood of energy in "
    "a split-second!  Unfortunately, you were a little close...\n";
    die();
}
// Dragon Stuff
AWAKE = MISC1;

NOUN dragon (cel06);


white=clear;
NOUN green crystal(cel07);
NOUN red crystal(cel08);
NOUN blue crystal(cel10);
NOUN clear crystal(cel09);

diamond = clear crystal;
sapphire =  blue crystal;
ruby = red crystal;
emerald = green crystal;

WORKD = MISC1;

green crystal(WEIGH)=15;
green crystal(POINT)=25;
green crystal(LDESC) = Proc() {"There is a beautiful green crystal here!\n";}
green crystal(SDESC) = Proc() {"a green crystal";}

green crystal(ACTION) = Proc()
{
    If (Verb == take) {
	If ((!dragon.KILLED) & ($loc($ME) == cel07)) {
	    If (!dragon.AWAKE) {
		"You hear a stirring nearby.\n";
		Tempr = Tempr + 2;
		dragon.AWAKE = TRUE;
		cel06.SEEN = FALSE;
	    }
            Else {
		Tempr = 0;
	    }
	}
    }
    Else If (Verb == drop) {
	If ((!dragon.KILLED) & ($loc($ME) == cel07)) {
	    Tempr = Tempr - 2;
            If (Tempr <= 0) {
                dragon.AWAKE = FALSE;
                "You hear a deep  Y A W N  nearby.\n";
            }
            cel06.SEEN = FALSE;
        }
    }
    Else If (Verb == touch) {
	If (Dobj == <red crystal>) {
	    If ($loc($ME) == toolbox) {
		"The red and green crystals flare briefly!\n";
		Grow();
		$move($ME, cel01);
		MyLoc = -1;
	    }
            Else {
		"Nothing happens.\n";
	    }
	    $exit(1);
        }
	Else If (Dobj == <blue crystal>) {
	    If (<green crystal>.WORKD > 2) {
		"Nothing happens.\n";
	    }
            Else {
		<green crystal>.WORKD = <green crystal>.WORKD + 1;
		"The blue and green crystals flare briefly!\n";
		$move($ME, toolbox);
		Shrink();
		MyLoc = -1;
	    }
	    $exit(1);
        }
	Else If (Dobj == <clear crystal>) {
	    "Nothing happens.\n";
	    $exit(1);
	}
    }
    Else If ($verb == break) {
	If (Dobj == <green crystal>) {
	    crydie();
	}
    }
}

red crystal(WEIGH)=15;
red crystal(POINT)=25;
red crystal(LDESC) = Proc() {"There is a beautiful red crystal here!\n";}
red crystal(SDESC) = Proc() {"a red crystal";}
red crystal(ACTION) = Proc()
{
    If (Verb == touch) {
	If (Dobj == <clear crystal>) {
	    If (!<clear crystal>.WORKD) {
		"The red and clear crystals flare briefly!\n";
		<clear crystal>.WORKD = TRUE;
		<clear crystal>.LIGHT = TRUE;
                "The clear crystal blazes forth with a magical "
                "incandescence brilliant enough to penetrate even "
                "the deepest darkness!!\n\n";
		$move($ME, cel04);
		MyLoc = -1;
		$sfus($ME, CRout, 7);
		$exit(1);
	    }
            Else {
		"Nothing happens.\n";
		$exit(1);
	    }
        }
	Else If (Dobj == <green crystal>) {
	    If ($loc($ME) == toolbox) {
		"The red and green crystals flare briefly!\n";
		Grow();
		$move($ME, cel01);
		MyLoc  = -1;
            }
            Else {
		"Nothing happens.\n";
	    }
	    $exit(1);
        }
	Else If (Dobj == <blue crystal>) {
	    If (($loc($ME) == desert) | ($loc($ME) == field)) {
		"The red and blue crystals flare briefly!\n";
		$move($ME, cel08);
		MyLoc = -1;
            }
	    Else If (!RBTouch) {
		"The red and blue crystals flare briefly!\n";
		RBTouch = TRUE;
            }
	    Else {
		"Nothing happens.\n";
	    }
	    $exit(1);
	}
    }
    Else If (Verb == break) {
	If (Dobj == <red crystal>) {
	    crydie();
	}
    }
}


blue crystal(WEIGH)=15;
blue crystal(POINT)=25;
blue crystal(LDESC) = Proc() {"There is a beautiful blue crystal here!\n";}
blue crystal(SDESC) = Proc() {"a blue crystal";}
blue crystal(ACTION) = Proc()
{
    If (Verb == touch) {
	If (Dobj == <red crystal>) {
                If (($loc($ME) == desert) | ($loc($ME) == field)) {
		"The red and blue crystals flare briefly!\n";
		RBTouch = TRUE;
		$move($ME, cel08);
		MyLoc = -1;
            }
	    Else If (!RBTouch) {
		"The red and blue crystals flare briefly!\n";
		RBTouch = TRUE;
            }
	    Else {
		"Nothing happens.\n";
	    }
	    $exit(1);
        }
	Else If (Dobj == <green crystal>) {
	    If (<green crystal>.WORKD > 2) {
		"Nothing happens.\n";
            }
	    Else {
		"The blue and green crystals flare briefly!\n";
		$move($ME, toolbox);
		Shrink();
		MyLoc = -1;
		<green crystal>.WORKD = <green crystal>.WORKD + 1;
	    }
	    $exit(1);
        }
	Else If (Dobj == <clear crystal>) {
	    "Nothing happens.\n";
	    $exit(1);
	}
    }
    Else If (Verb == break) {
	If (Dobj == <blue crystal>) {
	    crydie();
	}
    }
}

CRout = Proc()
{
    <clear crystal>.LIGHT = FALSE;
    "The glowing magical crystal seems to have gone dark.\n";
}

clear crystal(WEIGH)=15;
clear crystal(POINT)=25;
clear crystal(LDESC) = Proc()
{
    "There is a beautiful clear crystal here";
    If (<clear crystal>.LIGHT) {
	" (GLOWING!)";
    }
    "!\n";
}
clear crystal(SDESC) = Proc()
{
    "a clear crystal";
    If (<clear crystal>.LIGHT) {
	" (GLOWING!)";
    }
}
clear crystal(ACTION) = Proc()
{
    If (Verb == touch) {
	If (Dobj == <red crystal>) {
	    If (!<clear crystal>.WORKD) {
		"The red and clear crystals flare briefly!\n";
		<clear crystal>.WORKD = TRUE;
		<clear crystal>.LIGHT = TRUE;
                "The clear crystal blazes forth with a magical incandescence "
                "brilliant enough to penetrate even the deepest "
                "darkness!!\n\n";
		$move($ME, cel04);
		MyLoc = -1;
		$sfus($ME, CRout, 7);
		$exit(1);
	    }
            Else {
		"Nothing happens.\n";
		$exit(1);
	    }
	}
        Else If (Dobj == <green crystal>) {
	    "Nothing happens.\n";
	    $exit(1);
	}
        Else If (Dobj == <blue crystal>) {
	    "Nothing happens.\n";
	    $exit(1);
	}
    }
    Else If (Verb == break) {
	If (Dobj == <red crystal>) {
	    crydie();
	}
    }
}


NOUN	wood(cel20);
ROUTINE	KillDragon;
DRdem = Proc(isLdesc) // Dragon Daemon.  Increases temper in $my presence
{
    If (dragon.KILLED | !dragon.AWAKE) {
	If (isLdesc) "\n";
	Return 0;
    }
    If ($loc($ME) == $loc(dragon)) {
	If ($loc(<green crystal>) == $ME) {      // even worse!
	    Tempr = Tempr + 1;
	}
	Tempr = Tempr + 1;
	If (wood.FLAME & ($loc(wood) == $loc($ME))) {
	    KillDragon();
	    Return 0;
	}
    }
    If (Tempr >= 7) {
        "Jeez, I didn't know ice dragons could reach their boiling point! "
        "In a final flare of rage, he opens his mouth and breathes his frigid "
        "breath in a blast in your direction.  It's a bit much for you.";
	die();
    }
    Else If (Tempr >= 6)
	"Gee, he looks like he's really at the edge!";
    Else If (Tempr >= 5)
	"This is one upset dragon!  Be careful!";
    Else If (Tempr >= 3)
	"He's getting angrier...";
    If (isLdesc) "\n";
}

dragon(WEIGH) = CAPAC;
dragon(LDESC) = Proc()
{
    If (dragon.AWAKE)
        "There is a fierce ice dragon glaring balefully in your direction.  ";
    Else
        "There is a large white dragon sleeping peacefully in the middle "
        "of the cavern floor.  ";
    DRdem(1);
}
dragon(SDESC) = Proc()
{
    If (dragon.AWAKE)
        "a fierce dragon.  ";
    Else
        "a somnolent dragon.  ";
    If (MyLoc != $loc($ME)) {
        DRdem(0);
    }
}

dragon(ACTION) = Proc()                 // Man, the things you can try here...
{
    If (dragon.AWAKE) {                 // This is the harder stuff
        If (Verb == strike) {
            "This just seems to get him angrier!\n";
            Tempr = Tempr + 1;
            $exit(1);
        }
        Else If (Verb == throw) {
            If (Iobj == dragon) {
                If (Dobj.WEIGH > 75) {
                    "This just bruises him!  Now he's getting mad!\n";
                    Tempr = Tempr + 1;
                    $exit(1);
                }
                Else {
                    "That object is just too light to hurt him.\n";
                    $exit(1);
                }
            }
            Else { // Dobj action
                "This amuses the dragon no end!\n";
                $exit(1);
            }
        }                                       // end of Throw  case
    }
    Else { // he's snoozing
        If (Verb == wake) {
            "You manage to waken him.  He's not happy.\n";
            Tempr = 1;
            dragon.AWAKE = TRUE;
            If (($loc(wood) == $loc($ME)) & wood.FLAME) {
                KillDragon();
            }
            $exit(1);
        }
        Else If (Verb == strike) {
            "Now you woke him up!  He's upset, too!\n";
            Tempr = 2;
            dragon.AWAKE = TRUE;
            $exit(1);
        }
        Else If (Verb == throw) {
            If (Iobj == dragon) {
                If (Dobj.WEIGH > 75) {
                    "It's just heavy enough to waken him.  The bruise "
                    "doesn't help his temper any either.\n";
                    dragon.AWAKE = TRUE;
                    Tempr = 3;
                    $exit(1);
                }
                Else {
                    "That object is just too light to wake him.\n";
                    $exit(1);
                }
            }
            Else {
                "Don't hurt yourself trying!\n";
                $exit(1);
            }
        }					// end of Throw  case
    }
}


NOUN money;
money(WEIGH) = 1;
money(LDESC) = Proc() {"There is a stack of money here!\n";}
money(SDESC) = Proc() {"a stack of money";}
money(POINT) = 25;
stack = money;
FOUND = MISC1;


NOUN bed (farm7);
bed(WEIGH) = CAPAC;
bed(SDESC) = Proc() {"an old, rickety bed";}

bed(ACTION) = Proc()
{
    If (Verb == move) {
	If (bed.OPENED) {
	    "Stop messing with the bed, it's fragile!\n";
	    $exit(1);
	}
        "Moving the bed seems to have loosened one of the wall panels "
        "on the west wall.\n";
	bed.OPENED = TRUE;
	$exit(1);
    }
    Else If ((Verb == look) & (Iobj == bed)) {
	If (Prep == under) {
	    If (!money.FOUND) {
		"You find some money under the bed!\n";
		$move(money, $loc($ME));
		money.FOUND = TRUE;
		$exit(1);
	    }
        }
	Else If (bed.OPENED) {
	    "The bed has been moved.\n";
	    $exit(1);
	}
    }
}

NOUN panel (farm7);
panel(OPENS) = TRUE;
panel(WEIGH) = CAPAC;
panel(ACTION) = Proc()
{
    If ((Verb == open) | (Verb == pry)) {
	If ((Iobj == crowbar) & ($loc(crowbar) == $ME)) {
	    If (!bed.OPENED) {
		"There aren't any loose enough.\n";
		$exit(1);
	    }
            "The loose panel comes away, revealing a secret stairway "
            "down, down...\n";
	    panel.OPENED = TRUE;
        }
        Else {
	    "You can't seem to get the panel open.\n";
	}
	$exit(1);
    }
}


NOUN bottle(town6);
bottle (WEIGH) = 5;
bottle (LDESC) = Proc() {"There is a bottle here.\n";}
bottle (SDESC) = Proc() {"a bottle";}
bottle (TRANS) = TRUE;
bottle (ACTION) = Proc()
{
    If (Verb == open) {
	"Hm, the bottle is somehow sealed shut.\n";
	$exit(1);
    }
    Else If (Verb == break) {
	"Wow, is that heavy glass!  It won't break!\n";
	$exit(1);
    }
    Else If (Verb == strike) {
	If (Iobj == bottle)
	    "Weird thing to do with it.\n";
	Else
	    "Nice try, but it isn't even scratched.\n";
	$exit(1);
    }
}

NOUN ship(bottle);
ship (LDESC) = Proc() {"There is a golden model ship here!\n";}
ship (SDESC) = Proc() {"a golden model ship";}
ship (WEIGH) = 5;
ship (POINT) = 50;
model = ship;

NOUN well(town5);
well(NOTAKE) = TRUE;
well(OPENED) = TRUE;
well (ACTION) = Proc()
{
    If (Iobj == well) {
	If (Verb == drop) {
	    TWN5y();
	}
    }
}

NOUN painting(cel08);
painting(ACTION) = Proc()
{
    If (Verb == take) {
	"You can't take the painting.\n";
	Skip = TRUE;
    }
    Else {
	"Fiddling with the painting is silly.\n";
	$exit(1);
    }
}

NOUN grate(riverx);
grate(Loc21) = GRATELOC;
grate(ACTION) = Proc()
{
    If (Verb == take) {
	"You can't take the grate.\n";
	Skip = TRUE;
    }
    Else {
	"Fiddling with the grate is useless.\n";
	$exit(1);
    }
}

NOUN insignia;
insignia(NOTAKE) = TRUE;
insignia (WEIGH) = CAPAC;
insignia (ACTION) = Proc()
{
    If (Verb == examine) {
        "The insignia consists of ";
	If ($loc($ME) == cel01)
            "red and green squares ";
	Else If ($loc($ME) == cel04)
            "red and clear squares ";
	Else If ($loc($ME) == cel08)
            "red and blue squares ";
	Else If ($loc($ME) == farm5)
            "blue and green squares ";
        "joined at the corners.\n"
	$exit(1);
    }
    "There's nothing useful to do with the insignia.\n";
    $exit(1);
}
square=insignia;

NOUN glass box(cel08);
glass box(HOLDS)=1;
glass box(TRANS)=TRUE;
glass box(OPENS)=TRUE;
glass box(OPENED)=FALSE;
glass box(SHRNK)=TRUE;          // First seen as a tiny box
glass box(LDESC) = Proc()
{
    If ($ME.SHRNK == <glass box>.SHRNK) {
	"There is a big glass case here.\n";
	<glass box>.WEIGH = CAPAC;
	<glass box>.HOLDS = 50;
    }
    Else {
	If ($ME.SHRNK) {
            "Before you looms a huge glass wall, inscribed with the words, "
            "'program error!'\n";
        }
	Else {
	    "There is a tiny glass box with a snap lid here.\n";
	    <glass box>.WEIGH = 5;
	    <glass box>.HOLDS = 1;
	}
    }
}
glass box(SDESC) = Proc()
{
    If ($ME.SHRNK == <glass box>.SHRNK) {
	"a glass case";
	<glass box>.WEIGH = CAPAC;
	<glass box>.HOLDS = 50;
    }
    Else {
	If ($ME.SHRNK) {
            "a huge glass wall, inscribed with the words, "
            "'program error'";
	}
        Else {
	    "a tiny glass box";
	    <glass box>.WEIGH = 5;
	    <glass box>.HOLDS = 1;
	}
    }
}
glass box(ACTION) = Proc()
{
    If (Verb == examine) {
	If (<glass box>.OPENED)
	    "The case is opened.\n";
	Else
	    "The case is closed (pun not intended).\n";
	$exit(1);
    }
}
case=glass box;

NOUN statue(glass box);
sand = statue;
sand(SHRNK)=TRUE;
sand(WEIGH)=1;
sand(LDESC) = Proc()
{
    If (sand.SHRNK & !$ME.SHRNK) {
	sand.POINT = 0;
	"There is a grain of sand here.\n";
    }
    Else {
	"There is a beautiful porcelain statue here!\n";
	sand.POINT = 50;
    }
}
sand(SDESC)= Proc()
{
    If (sand.SHRNK & !$ME.SHRNK) {
	sand.POINT = 0;
	"a grain of sand";
    }
    Else {
	"a porcelain statue";
	sand.POINT = 50;
    }
}
sand(ACTION) = Proc()
{
    If (Verb == take) {
	If (sand.SHRNK & !$ME.SHRNK) {
	    "You fumble the grain of sand and lose it on the ground.\n";
	    $move(sand, $ALL);
	    Skip = TRUE;
	}
    }
}

NOUN hole;
hole(NOTAKE) = TRUE;
hole(ACTION) = Proc()
{
    "You can't do anything useful with the hole.\n";
    $exit(1);
}

NOUN rock(road5);
rock(LDESC) = Proc() {"There is a plain-looking rock here.\n";}
rock(SDESC) = Proc() {"an ordinary rock";}
rock(ACTION) = Proc()
{
    If ((Verb == take) & (Dobj == rock)) {
	"Mmph!  Heavy!\n";
    }
}
rock(WEIGH)=100;

IFOUND = MISC1;
NOUN ivory(riverx);
ivory(WEIGH) = 5;
ivory(POINT) = 25;
ivory(Loc21) = GRATELOC;
ivory(LDESC) = Proc()
{
    "There is a beautiful piece of ivory ";
    If (!ivory.IFOUND) {
	"wedged in the grate.\n";
	ivory.IFOUND = TRUE;
    }
    Else {
	"here.\n";
    }
}
ivory(SDESC) = Proc()
{
    "a piece of ivory";
    If (!ivory.IFOUND) {
	" (wedged in the grate)";
	ivory.IFOUND = TRUE;
    }
}


NOUN matches(cel12);
matches(LDESC) = Proc() {"There is a book of waterproof matches here.\n";}
matches(SDESC) = Proc() {"a book of matches";}
matches(ACTION) = Proc()
{
    If (((Verb == light) | (Verb == burn)) & (Dobj == matches)) {
	"OK, you light a match, which quickly burns out.\n";
	$exit(1);
    }
}
matches(WEIGH) = 1;
book = matches;

WoodBurn = Proc()
{
    If ($loc(wood) == $loc($ME)) {
	"The wood burns down to a pile of ashes, which blows away.\n";
    }
    $move(wood, $ALL);
    wood.FLAME = FALSE;
}


// NOUN wood(cel20);
wood(LDESC) = Proc()
{
    "There is a pile of ";
    If (wood.FLAME) "burning ";
    "wood here.\n";
}
wood(SDESC) = Proc()
{
    "a pile of ";
    If (wood.FLAME) "burning ";
    "wood";
}
wood(WEIGH) = 100;
wood(ACTION) = Proc()
{
    If (wood.FLAME) {
	"The wood is too hot to touch.\n";
	If ((Verb == take)  | (Verb == drop)) {
	    Skip = TRUE;
	    Return 0;
        }
	Else {
	    $exit(1);
	}
    }
    Else If ((Verb == burn) | (Verb == light)) {
	If (!Iobj) {
	    "You must tell me how to do that!\n";
	    $exit(1);
	}
        Else If (Iobj != matches) {
	    "That doesn't seem to work.\n";
	    $exit(1);
        }
	Else If ($loc(wood) == $ME) {
	    "You can't manage that while you are holding the wood.\n";
	    $exit(1);
	}
        "You strike a match and apply it to the wood, which bursts "
        "into flames.\n";
	If (dragon.AWAKE & ($loc($ME) == $loc(dragon))) {
	    KillDragon();
        }
	Else {
	    wood.FLAME = TRUE;
	    $sfus($ME, WoodBurn, 3);
	}
	$exit(1);
    }
}


KillDragon = Proc()
{
    "The dragon, attracted by the bright flame of the burning wood, snaps it "
    "up in its jaws.  Suddenly, the dragon realizes what it has done!  It "
    "tries to spit out the wood, but it is too late!  The dragon evaporates "
    "with a deafening whistle and a burst of steam!  ";
    If (($loc(bottle) == $loc($ME)) | ($loc(bottle) == $ME)) {
        "The sound of the whistle shatters the bottle, "
        "releasing the golden ship model!  ";
	$move(ship, $loc($ME));
	$move(bottle, $ALL);
    }
    "Upon the death of the dragon, the ice melts with astonishing speed.\n";
    $dfus($ME, WoodBurn);
    $move(wood, $ALL);
    dragon.KILLED = TRUE;
    $move(dragon, $ALL);
    SCORE = SCORE + 100;
    cel06.SEEN = FALSE;
    cel05.SEEN = FALSE;
    cel03.SEEN = FALSE;
    cel10.SEEN = FALSE;
    cel08.SEEN = FALSE;
}

NOUN goblet(cel19);
FREED = MISC1;
goblet(WEIGH) = 5;
goblet(POINT) = 25;
goblet(LDESC) = Proc()
{
    If (!goblet.FREED)
	"There is a beautiful golden goblet frozen in the ice!\n";
    Else
	"There is a beautiful golden goblet here!\n";
}
goblet(SDESC) = Proc()
{
    "a golden goblet";
    If (!goblet.FREED) " (frozen in the ice)";
}
goblet(ACTION) = Proc()
{
    If (!goblet.FREED) {
        "There's not much you can do with the goblet while it's frozen "
        "in the ice.\n";
	$exit(1);
    }
}

NOUN newspaper(town2);
paper = newspaper;
newspaper(LDESC) = Proc()
{
    "There is a newspaper fluttering in the breeze here.\n";
}
newspaper(SDESC) = Proc() {"a newspaper";}
newspaper(ACTION) = Proc()
{
    If ((Verb == read) | (Verb == examine)) {
	"		UNUCHEVALA NEWS -- VOLUME II NUMBER 1\n"
        "\n"
        "VANDALS THREATEN COWLEY\n"
        "\n"
        "\tLast night,  unknown vandals attacked the farm of Mr. Cowley, "
        "north of town.  They sprayed \"DIE, HEATHENS\" on  his front "
        "door (in reference to his admittedly strange  beliefs).   Cowley "
        "says that this is not the first such threat he has received. "
        "However, he says that he will deal with the vandals in his own "
        "way.   Unfortunately,  we have been unable to contact Mr. Cowley "
        "personally, since he has not been seen hereabouts "
        "since last night.\n"
        "\n"
        "DROUGHT IMMINENT, SAY LOCAL FARMERS\n"
        "\n"
        "\tThe  Unuchevala  River has recently  been  falling,  and "
        "little relief is in sight for our  local farmers.   \"I'm agonna "
        "leave here, purty soon,\" said one farmer  (who chose to "
        "remain anonymous).   \"It's all that danged Cowley's fault, "
        "messin'  about  with  things  that  ain't natrawl-like.  I "
        "caint even raise 'nuff to feed myself, not mentionin' the "
        "resta the town.\"\n"
        "\n"
	"WEATHER -- Continued dry, with no rain in sight.\n"
        "\n";
	$exit(1);
    }
    Else If ((Verb == burn) | (Verb == light)) {
	If (!Iobj) {
	    "You must tell me how to do that!\n";
	    $exit(1);
        }
	Else If (Iobj != matches) {
	    "That doesn't seem to work.\n";
	    $exit(1);
        }
	Else If ($loc(newspaper) == $ME) {
	    "You can't manage to do that while holding the newspaper.\n";
	    $exit(1);
	}
        "The newspaper lights easily, burning down to ashes which blow away.\n";
	If (($loc($ME) == $loc(dragon)) & dragon.AWAKE) {
            // give the player a hint
            "The dragon notices the flash and approaches the newspaper, "
            "but the fire dies down before the dragon can reach it.\n";
	}
	$move(newspaper, $ALL);
	$exit(1);
    }
}

NOUN ice;
ice(NOTAKE) = TRUE;
ice(ACTION) = Proc()
{
    If ((Verb == break) | (Verb == hit)) {
	If (Dobj == ice) {
	    If (!Iobj) {
		"You must tell me how to do that.\n";
		$exit(1);
	    }
	    If ($loc($ME) == cel19) {
		If (Iobj.WEIGH > 20) {
		    If (!goblet.FREED) {
			"You manage to free the goblet.\n";
			goblet.FREED = TRUE;
			$move(goblet, cel19);
			$exit(1);
		    }
		}
            }
	    Else If ($loc($ME) == cel13) {
		If (!cel13.HOLED) {
		    If (Iobj.WEIGH > 75) {
                        "You swing at the ice with the " $name(Iobj)
                        ", which breaks through and sinks into "
                        "the icy waters below!\n";
			$move(Iobj, $ALL);
			cel13.HOLED = TRUE;
			$exit(1);
		    }
		}
	    }
	    "The ice chips a bit, but does not break.\n";
	    $exit(1);
   	}
    }
    "You can't do that!\n";
    $exit(1);
}