/*
 *
 * Hamlet - The Text Adventure
 *
 * Places
 *
 * code and data dealing with 'the map'
 *
 */

var Place = new Object;
NUM_PLCS = 0;
function pl(name,fullname,description,append,sights,special,exits, hExits)
{
	Place[++NUM_PLCS] = new Object;
	Place[NUM_PLCS].id = NUM_PLCS;
	Place[NUM_PLCS].name = name;
	Place[NUM_PLCS].fullname = fullname;
	Place[NUM_PLCS].description = description;
	Place[NUM_PLCS].append = append;
	Place[NUM_PLCS].sights = sights;
	Place[NUM_PLCS].special = special;
	Place[NUM_PLCS].exits = exits;
	Place[NUM_PLCS].hExits = hExits ? hExits : '';
	eval(name + ' = Place[' + NUM_PLCS + '];');
}

pl('nowhere',
'nowhere',
'You\'re nowhere! You shouldn\'t be here!',
'',
'',
'');

pl('bedroom',
'Bedroom',
'You are in your luxurious palatial boudoir, all of ten feet square. \
There is a four-poster bed, and not much else. A portrait hangs \
on the wall.',
'',
'portrait::It is a painting of your late father - who, rather \
confusingly, was also called Hamlet - in the usual \
cheesy royal portrait pose./\
/wall::There is a portrait of your father on the wall.\
/bed::A four poster bed, draped in black, and unmade.\
/door::The door is painted black.',
'make.bed::Nope. You can\'t be bothered to make the bed.\
/move.portrait::Behind the portrait the wall is a bit cleaner, \
but there\'s nothing interesting.',
'north::outside_bedroom',
'out::north'
);

pl('outside_bedroom',
'Outside bedroom',
'This is an east-west corridor in the palace. Your bedroom door \
is in the south wall. An opening in the north wall leads on \
to the balcony.',
'',
'door::The door is painted black. A sign reads, \"Hamlet\'s Room. \
Keep Out!\"',
'',
'north::balcony.east::outside_ophelias_room.south::bedroom.west::top_of_stairs',
'in::south.out::north'
);

pl('balcony',
'Balcony',
'You are on the palace balcony.[[ balcony_append() ]]',
'',
'bat::*describe_bat()',
'take.bat::*catch_bat()\
/fight.bat::*catch_bat()\
/talk.ghost::*talk_ghost()\
/jump::A ghostly mist stops you from jumping off the balcony.\n\
\"What do you think you\'re doing, son?\" says the ghost. \"Do you want \
to end up like me?\"\
/down::You can\'t see a safe way down from here.',
'south::outside_bedroom',
'in::south'
);
function balcony_append()
{
	var txt = ' ';
	if(gs('ctbat')==0)
		txt += ('Bats are flapping around in the twilight. ');
	return(txt + 'Miles and miles of crinkly Danish countryside \
stretch out below you.');
}
function describe_bat()
{
	if(gs('ctbat')==0)
		say('Irritating, screechy little winged weasels. One of them flew \
right past your ear just then.')
	else
		thingsee(bat);
}
function catch_bat()
{
	if(gs('ctbat')==1)
	{
		if(Token[1]=='take')
			take(bat);
		else // nasty code-duplicating fudge
		{
			if(!in_inv(bat) && thingloc(bat)!=balcony)
				say('You haven\'t got the bat.')
			else
				say('I think you have already proved you can beat the bat in a fight.');
		}
		return;
	}
	sgs('ctbat',1);
	inc_score();
	give_hero(bat);
	say('You manage to grab one of the bats. Then - ouch! The \
blighter bit you! You teach it a lesson by bashing its little head \
in.\n\
Alarmed, all the other bats flutter away.');
}

pl('outside_ophelias_room',
'End of corridor',
'You are at the east end of a corridor in the palace. There is a \
door in the south wall. The corridor continues to the west.',
'',
'door::The door is painted a sickening shade of pink. A flowery \
sign reads, \"Ophelia\'s lovely room.\"',
'',
'south::ophelias_room.west::outside_bedroom',
'in::south'
);

pl('ophelias_room',
'Ophelia\'s room',
'This room has horrid pink walls. There \
are drawings of flowers, kittens and other disgustingly cute \
things all over. A portrait hangs on the west wall. \
There is a door in the north wall, and a large open window.',
'',
'window::The window is positioned directly above a big lake.\
/lake::Big and wet.\
/door::The door is painted the same awful pink as the rest of the \
room.\
/portrait::It is a portrait of Ophelia\'s father, Polonius - a \
sneering old man in a ridiculous grey wig who is our family\'s \
Lord Chamberlain. On the canvas there have been written the \
words, \"My Daddy xxxxx I WOVE HIM!\"',
'close.window::You prefer to leave the window open. It lets in a nice \
cool breeze.\
/look.out.window::The window is positioned directly above a big lake.\
/jump.window::*jump_out_window()\
/jump.out.window::*jump_out_window()\
/move.portrait::Behind the portrait the wall is a bit cleaner, \
but there\'s nothing interesting.\
/drop.body::*drop_body()\
/out::I wouldn\'t recommend jumping out the window.\
/jump::I wouldn\'t recommend jumping out the window.',
'north::outside_ophelias_room',
'out::north'
);
function jump_out_window()
{
	die('Okay. You have jumped out the window and, consequentially, \
plummeted a couple of hundred feet to your death in the lake below.',
randomDeath());
}
function drop_body()
{
	if(drop(body) && personloc(ophelia)==ophelias_room)
		ophelias_death();
}

pl('top_of_stairs',
'Top of stairs',
'You are at the top of a stone spiral staircase in the palace. A \
corridor leads east.',
'',
'stairs::Bare stone steps. They look safe enough.',
'down::*downstairs()',
'east::outside_bedroom.down::first_floor_landing',
''
);
function downstairs()
{
	if(gs('ghosttalk')==0)
		say('Suddenly, a ghostly mist surrounds you and blocks your way downstairs!')
	else
	{
		set_heroloc(first_floor_landing);
		look();
	}
}

// avoid "first floor" in place descriptions, it confuses the yanks
pl('first_floor_landing',
'Landing',
'You are on a landing halfway up a stone spiral staircase in the \
palace. A corridor leads east.',
'',
'stairs::Bare stone steps. They look safe enough.',
'',
'east::queens_bedchamber.up::top_of_stairs.down::bottom_of_stairs',
'in::east'
);

pl('queens_bedchamber',
'Queen\'s bedchamber',
'The decor in this chamber has \
been done in frilly white lace with studded leather \
trimming.[[ append_curtain() ]]',
'',
'bed::A big circular bed with stains you\'d rather not think about./\
stain::Just leave it!/\
curtain::*describe_curtain()/',
'fight.curtain::*fight_curtain()/\
open.curtain::*open_curtain()\
/talk.curtain::*talk_curtain()\
/move.curtain::Something seems to be holding the curtain where it is.',
'west::first_floor_landing',
'out::west'
);
function open_curtain()
{
	if(gs('klpln')==0)
		say('Something seems to be holding the curtain shut.')
	else
		say('The curtain is in pieces on the floor!');
}
function talk_curtain()
{
	if(gs('klpln')==0)
		say('\"Don\'t be silly,\" says the curtain. \"Curtains can\'t talk!\"')
	else
		say('The remains of the curtain are in no mood to talk.');
}
function append_curtain()
{
	if(gs('klpln')==0)
		return(' A curtain hangs in a corner.')
	else
		return(' A ripped, blood-stained curtain lies on the floor.');
}
function describe_curtain()
{
	if(gs('klpln')==0)
		say('The curtain definitely looks out of place against \
the rest of the room. It is attached to some kind of free-standing frame, \
and looks just about big enough to hide a man.')
	else
		say('The curtain is in blood stained shreds on the floor.');
}
function fight_curtain()
{
	if(gs('klpln')==1)
	{
		say('I think you ought to leave the curtain alone from now on.');
		return;
	}
	
	if(!in_inv(dagger))
	{
		say('You punch the curtain. It emits an \"Oof!\" but remains standing.');
		return;
	}
	
	say('With a cry of \"Death to all soft furnishings!\" you leap frenzied \
toward the curtain and plunge the dagger into it repeatedly. After a dozen \
stabs or so you notice it is bleeding... oh.\n\
The dead body of Polonius slides out on to the floor.');
	inc_score();
	set_thingloc(body,queens_bedchamber);
	sgs('klpln',1);
}

pl('bottom_of_stairs',
'Bottom of stairs',
'You are at the bottom of a stone spiral staircase in the palace. \
A door leads east.',
'',
'stairs::Bare stone steps. They look safe enough.\
/door::Just an ordinary door.',
'',
'east::throne_room.up::first_floor_landing',
''
);

pl('throne_room',
'Throne room',
'This room is designed to make \
one point - that its occupants are RICH. There are expensive \
looking chandeliers all over the ceiling, but the centre of attention \
is (unsurprisingly) the massive throne in the middle of the floor. There \
are doors in the south and west walls, and a doorway in the north wall leading \
through to the entrance lobby.',
'',
'throne::The throne is huge, made of stone, and encrusted with jewels. \
Come to think of it, it can\'t be all that comfy.\
/ceiling::There are big glittering glass chandeliers all over the \
ceiling.\
/chandelier::Big and made of glass.\
/door::Just ordinary doors.',
'sit::*sit_on_throne()',
'north::lobby.south::kitchen.west::bottom_of_stairs',
''
);
function sit_on_throne()
{
	if(personloc(claudius)==throne_room)
		say('Claudius is already sitting on the throne.')
	else
		say('You sit on the throne for a while, but you don\'t feel any better.');
}

pl('kitchen',
'Kitchen',
'This kitchen has an oven, and some \
cupboards on the wall. A ladder leads down through \
a trap door in the floor.',
'',
'door::The trap door is set into the floor. It is open, with \
a ladder leading down through it.\
/cupboard::Attractive eye-level kitchen cabinets.\
/oven::A large, black, cast iron, coal-fired oven.',
'open.cupboard::*open_cupboard()\
/open.oven::There is nothing in the oven.\
/cook::Please, You\'re a royal! You have servants to do that sort of thing!',
'north::throne_room.down::dungeon',
'out::north'
);
function open_cupboard()
{
	if(gs('cpbd')==1)
	{
		say('The cupboards are empty.');
		return;
	}

	sgs('cpbd',1);
	inc_score();
	set_thingloc(pepper,kitchen);
	set_thingloc(salt,kitchen);
	say('You find some salt and pepper in one of the cupboards.');
}

pl('dungeon',
'Dungeon entrance',
'The \
usual eerie green lights and chains adorn the walls. A \
corridor leads south, and a ladder leads up through a trap \
door.',
'',
'door::The trap door is set into the ceiling. It is open, with \
a ladder leading up through it.',
'',
'up::kitchen.south::guardroom',
''
);

pl('guardroom',
'Guardroom',
'You are in a circular guardroom in the dungeon. There is a \
provocative calendar on the wall, and empty lager cans litter \
the floor.',
'',
'calendar::\"Ye Merry Wyves Calendar 1102,\" a collection of \
woodcarvings by the local Women\'s Institute.\
/lager::Carlsberg. (Probably.)',
'south::*guardroom_south()',
'north::dungeon.south::cell',
''
);
function guardroom_south()
{
	if(personloc(othello)==guardroom)
		say('Othello blocks your way.\n\
\"Sorry,\" he says. \"Prisoners and torturers only beyond this point!\"')
	else
		move('south');
}

pl('cell',
'Cell',
'A small, cramped dungeon cell, with evil greenish liquid \
dripping down the walls.',
'',
'',
'',
'north::guardroom',
'out::north'
);


pl('lobby',
'Lobby',
'This is a small square room \
with a purple carpet, just inside the huge front doors. \
There is a smaller, internal door in the south wall.',
'',
'door::The front doors of the palace are huge, oaken, studded, heavily fortified, \
and wide open.',
'out::*leave_palace()/north::*leave_palace()',
'out::palace_gates.south::throne_room',
'north::out'
);
lobby.block = 'Rosencrantz and Guildenstern bar your way.\n\
\"Sorry,\" says Rosencrantz, \"but...\"\n\
\"It\'s just that...\" says Guildenstern.\n\
\"Well...\" Rosencrantz continues.\n\
\"Er...\" Guildenstern contributes.\n\
\"It\'s like this. The King says you\'re mad...\"\n\
\"...and that you\'re absolutely not to leave the palace...\"\n\
\"...under any circumstances.\"\n\
\"Not that we agree with him of course.\"\n\
\"...of course...\"\n\
\"Sorry.\"';
function leave_palace()
{
	if(personloc(rosencrantz)==lobby)
		say(lobby.block)
	else
	{
		set_heroloc(palace_gates);
		look();
	}
		
}

pl('palace_gates',
'Palace gates',
'You are in the palace gardens, just outside the big front doors of \
the building and south of the huge front gates. A \
path runs east-west along the lawn, and the main driveway runs \
north through the massive palace gates.',
'',
'door::The front doors of the palace are huge, oaken, studded, heavily fortified, \
and wide open.\
/gate::The front gates of the palace gardens are big, ornate, and made of wrought \
iron. They are wedged permanently open.',
'',
'north::roundabout.east::vegetable_patch.west::garden_nw.in::lobby',
'south::in.out::north'
);

pl('garden_nw',
'North-west gardens',
'You are in the north-west corner of the palace gardens. \
A high wall partitions the gardens from the rest of the world.',
'',
'',
'up::The garden wall is far too high to climb.',
'east::palace_gates.south::orchard',
''
);

pl('orchard',
'Orchard',
'This is where your \
father was found dead a while ago. A high wall partitions the \
gardens from the rest of the world. The palace itself is just \
to the east.',
'',
'',
'up::The garden wall is far too high to climb.\
/east::There are no doors on this side of the palace.',
'north::garden_nw',
''
);

pl('vegetable_patch',
'Vegetable patch',
'The ground here, in the north-east corner of the gardens, has been ploughed into neat little \
furrows. A high wall partitions the gardens from the rest of \
the world. Just to the south there is a large lake.',
'',
'lake::Big and wet.',
'swim::I don\'t feel like swimming. The water is freezing!\
/south::The lake blocks my way south.\
/up::The garden wall is far too high to climb.\
/dig::*dig_carrot()',
'west::palace_gates',
''
);
function dig_carrot()
{
	if(!in_inv(shovel))
	{
		say('You haven\'t got anything to dig with.');
		return;
	}
	
	if(gs('dgcrt')==1)
		say('You dig for a while, but don\'t find anything.')
	else
	{
		say('You dig up a carrot.');
		set_thingloc(carrot,vegetable_patch);
		sgs('dgcrt',1);
		inc_score();
	}
}

pl('roundabout',
'Town Square',
'A quadrangle of grass on the main east-west road. \
To the south are the huge gates to the gardens of Elsinore palace.',
'',
'gate::The front gates of the palace gardens are big, ornate, and made of \
wrought iron. They are wedged permanently open.',
'',
'east::outside_theatre.west::outside_smithy.south::palace_gates',
''
);

pl('outside_theatre',
'Outside theatre',
'You are on the man east-west road, just outside a large building \
signposted \"ELSINORE THEATRE.\" The wall of the palace garden is \
to the south.',
'',
'',
'',
'east::outside_stable.west::roundabout.in::theatre',
''
);

pl('theatre',
'Theatre',
'The theatre hall has some rows of velvety \
chairs with various suspect looking stains, and a small stage \
at one end. The place is completely devoid of people. A notice \
reads: \"SILENCE.\" There is a vending machine in a corner.',
'',
'machine::The machine is marked \"ACME TICKET-O-MATIC\". It has a \
big red button on the front.\
/up::There is a lighting rig hanging from the ceiling.\
/ceiling::There is a lighting rig hanging from the ceiling.\
/stain::On closer inspection, the stains are all completely innocuous.',
'push.button::*make_ticket()\
/talk.macbeth::*say_macbeth()\
/talk::You\'re supposed to keep quiet in a theatre, philistine!\n\
Fortunately, you didn\'t say anything _really_ offensive.\
/shout.macbeth::*say_macbeth()\
/talk::You\'re supposed to keep quiet in a theatre, philistine!\n\
Fortunately, you didn\'t say anything _really_ offensive.\
/shout::You\'re supposed to keep quiet in a theatre, philistine!\n\
Fortunately, you didn\'t say anything _really_ offensive.',
'out::outside_theatre',
''
);
function say_macbeth()
{
	if(gs('gtrpe')==1)
	{
		say('\"MACBETH!!!\"\n\
The ground shakes for a few seconds.');
		return;
	}
	
	sgs('gtrpe',1);
	inc_score();
	set_thingloc(rope,theatre);
	say('\"MACBETH!!!\"\n\
The ground shakes for a few seconds. Above your head, you hear something break. \
A length of rope falls down from the ceiling.');
}
function make_ticket()
{
	if(gs('madetkt')==1)
		say('Nothing happens.')
	else
	{
		say('BEEP! A ticket comes out of the machine.');
		set_thingloc(ticket,theatre);
		inc_score();
		sgs('madetkt',1);
	}
}

pl('outside_stable',
'Outside stable',
'This is the east end of the main road through town, just \
outside a wooden building marked "STABLE."',
'',
'',
'',
'west::outside_theatre.in::stable',
''
);

pl('stable',
'Stable',
'The air here is gritty and dark and contains the \
dawdling aromas of various animals.',
'',
'',
'',
'out::outside_stable',
''
);

pl('outside_smithy',
'Outside blacksmith\'s hut',
'You are beside a square wooden shack on the main east-west road. \
A sign on the door of the shack reads \"BLACKSMITH.\" \
A sandy path leads northward. The wall of the palace garden is \
to the south.',
'',
'',
'',
'north::beach.east::roundabout.west::road_ww.in::smithy',
''
);

pl('smithy',
'Blacksmith\'s hut',
'The blacksmith himself is nowhere to be seen. There is a strange \
looking machine bolted to the floor.',
'',
'machine::The machine has a rotary grindstone spinning round \
and round.',
'grind.scissors::*sharpen_scissors();\
/grind::*grind_other();\
/push.scissors.machine::*sharpen_scissors();',
'out::outside_smithy'
);
function sharpen_scissors()
{
	if(!in_inv(scissors))
	{
		say('You are not carrying the scissors.');
		return;
	}
	if(gs('shrpscs')==1)
	{
		say('The scissors seem sharp enough already.');
		return;
	}
	else
	{
		sgs('shrpscs',1);
		inc_score();
		say('You press the blades of the scissors against the spinning \
grindstone for a moment. They seem sharper now!');
	}
}
function grind_other()
{
	if(!Token[2])
	{
		say('I don\'t know what do you want to grind.');
		return;
	}
	if(!is_thingname(Token[2]))
	{
		say('You can\'t grind that.');
		return;
	}

	var th = eval(Token[2])
	if(!in_inv(th))
	{
		say('You are not carrying the ' + th.name + '.');
		return;
	}
	
	say('Sparks fly from the grindstone.');
}

pl('road_ww',
'West end of road',
'This is the west end of the main road through town. \
A signpost points south along a dusty track to \"ELSINORE FUNERAL HOME.\"',
'',
'',
'',
'north::harbour.east::outside_smithy.south::graveyard',
''
);

pl('graveyard',
'Graveyard',
'There is a nasty smell, a number of holes in the \
ground, graves everywhere, and some cracked headstones lying around. The \
wall of the palace garden is to the east.',
'',
'grave::The graves are those of various passed-on Danish kings, from \
Kvorak the Hairy to your father. None of them look particularly \
interesting.\
/shovel::*look_shovel()',
'dig::*dig_grave()\
/take.shovel::*take_shovel()',
'north::road_ww',
''
);
function dig_grave()
{
	if(in_inv(shovel))
		say('You think better of digging up the graves.')
	else
		say('You haven\'t got anything to dig with.');
}
// shovel should be visible when the gravedigger has it...
function look_shovel()
{
	if(personloc(gravedigger)==graveyard)
		say(shovel.description) +
		  ' The gravedigger is holding on to it tightly.'
	else
		thingsee(shovel);
}
// ...and give the player a shot at taking it
function take_shovel()
{
	if(personloc(gravedigger)==graveyard)
		say('The gravedigger refuses to relinquish the shovel.')
	else
		take(shovel);
}

pl('beach',
'Beach',
'The choppy waves of the sea are pounding against \
the pebble strewn shore, all very picturesque. The sea is just north of \
you. To the west you can see the harbour.',
'',
'sea::The sea is big, blue and wet.',
'swim::You don\'t feel like swimming. The water is freezing!\
/dig::*dig_beach()',
'south::outside_smithy.west::harbour',
''
);
function dig_beach()
{
	if(!in_inv(shovel))
	{
		say('You haven\'t got anything to dig with.');
		return;
	}

	if(gs('dgbch')==1)
	{
		say('You dig for a while, but don\'t find anything else.');
		return;
	}
	
	inc_score();
	sgs('dgbch',1);
	set_thingloc(chest,beach);
	say('You dig up a treasure chest!');
}

pl('harbour',
'Harbour',
'There are several rickety wooden jetties to which \
some small boats are moored in the water, and seagulls squawking overhead. A \
gangplank leads into the side of a particularly large ship.',
'',
'sea::The sea is big, blue and wet./\
ship::A big wooden longboat. It has \"DENMARK-ENGLAND FERRY\" \
painted on the side.',
'swim::You don\'t feel like swimming. The water is freezing!',
'east::beach.south::road_ww.west::outside_inn.in::ship_denmark',
''
);

pl('outside_inn',
'Waterfront',
'You are by the waterfront just west of the harbour. There is a squat \
stone building here with no windows. A plaque above its door reads \
\"THE CROAKING RAVEN INN. PROP. N. QUICKLY.\"',
'',
'sea::The sea is big, blue and wet.',
'swim::You don\'t feel like swimming. The water is freezing!',
'east::harbour.in::inn',
'south::in'
);

pl('inn',
'Inn',
'This is a seedy looking inn with tobacco stained walls, ripped \
leather furniture, and so much spit n\' sawdust that it squelches. \
There is a small door in the south wall, marked \"PRIVATE SUITE.\"',
'',
'',
'south::*enter_suite()/in::*enter_suite()\
/buy::*buy_drink()',
'south::private_suite.out::outside_inn',
'in::south.north::out'
);
function enter_suite()
{
	if(gs('btdrnk')==0)
		say('Nell calls you back. \"Oi! Paying customers only in there!\"');
	else
	{
		set_heroloc(private_suite);
		look();
	}
}
function buy_drink()
{
	if(!in_inv(coins))
	{
		say('You haven\'t got any money.');
		return;
	}
	
	sgs('btdrnk',1)
	inc_score();
	take_away(coins);
	set_thingloc(whisky,inn);
	say('You hand over the gold coins. \"That\'ll do nicely!\" says Nell.\n\
She puts a flask of whisky down on the bar.');
}

pl('private_suite',
'Back room',
'The wallpaper in this room is brightly \
coloured and truly tasteless. There is a bright orange couch \
in the middle of the floor.',
'',
'couch::The couch a horrible orange colour, and somewhat lumpy.\
/handkerchief::*look_hanky()\
/ceiling::You see your own face staring back down from the mirrored ceiling.',
'sit::You sit awkwardly on the couch. It is even less comfortable than \
it looks.\
/take.handkerchief::*take_hanky()',
'north::inn',
'out::north'
);
function look_hanky()
{
	if(gs('hnky')==0)
		say(handkerchief.description)
	else
		thingsee(handkerchief);
}
function take_hanky()
{
	if(gs('hnky')==0)
		say('Desdemona won\'t give you the handkerchief.\n\
\"You don\'t need it!\" she says.')
	else
		take(handkerchief);
}

pl('ship_denmark',
'Sailing ship',
'You are aboard a big wooden ship with an impressive array of \
sails and rigging. A gangplank leads out to a harbour.',
'',
'sea::The sea is big, blue and wet.',
'swim::You don\'t feel like swimming. The water is freezing!',
'out::harbour',
''
);

pl('ship_england',
'Sailing ship',
'You are aboard a big wooden sailing ship with an impressive array of \
sails and rigging. A gangplank leads out to a harbour.',
'',
'sea::The sea is big, blue and wet.',
'swim::You don\'t feel like swimming. The water is freezing!',
'out::southhampton',
''
);

pl('southhampton',
'Southhampton Dock',
'This is the principal port on the south coast of England. There are some \
white cliffs to see, and not much else. A gangplank leads \
into the side of a large ship.',
'',
'sea::The sea is big, blue and wet./\
cliff::Big and white./\
ship::A big wooden longboat. It has \"DENMARK-ENGLAND FERRY\" \
painted on the side.',
'swim::You don\'t feel like swimming. The water is freezing!',
'in::ship_england.north::bosworth',
''
);

pl('bosworth',
'Bosworth Field',
'You are in a muddy area. Strewn around are a few broken pieces \
of armour, rusty sword blades, and severed limbs, so there has \
evidently been a battle going on here recently.',
'',
'',
'',
'north::moorland.south::southhampton',
''
);

pl('moorland',
'Moorland',
'Some drab, foggy moorland, with patches of unhealthy \
looking grass and jagged rocks all over.',
'',
'',
'',
'north::outside_dunsinane.south::bosworth',
''
);

pl('outside_dunsinane',
'Outside tower',
'You stand by the bottom of a huge circular stone tower \
which extends up into the grey clouds. A plaque above the open \
portcullis reads: \"DUNSINANE.\"',
'',
'tower::The tower is circular, about a hundred yards across, \
made of grey stone, and very, very, tall.',
'in::*enter_dunsinane()',
'south::moorland.in::dunsinane',
''
);
function enter_dunsinane()
{
	if(!worn(crown))
		say('The sudden appearance of Banquo\'s sword at your throat \
makes it difficult for you to enter the tower.\n\
\"Oi, commoner!\" he says aloofly. \"Only royalty can go in there!\"');
	else
	{
		if(gs('in_dun')==0)
		{
			sgs('in_dun',1);
			inc_score();
		}
		set_heroloc(dunsinane);
		look();
	}
}

pl('dunsinane',
'Bottom of tower',
'You stand in the ground floor of a tower. Fiery torches flicker on the \
stone walls, lighting up... not much. The tower continues a long way \
above you.[[ append_dunsinane() ]]',
'',
'thread::A thin, almost invisible thread of string hanging down from \
nowhere in particular.\
/dagger::*look_dagger()\
/rope::*look_rope()\
/up::The tower continues a great distance above you[[ gs("strpe") == 1 ? "" : \
", but you can\'t see a way up" ]].',
'cut.thread::*cut_thread()\
/take.dagger::*take_dagger()\
/up.rope::*move(\'up\')',
'out::outside_dunsinane',
''
);
function append_dunsinane()
{
	var txt = '';

	if(gs('ctthrd')==0)
		txt += (' There appears to be a dagger hanging in mid-air.');
	if(gs('strpe')==1)
	{
		dunsinane.exits = 'out::outside_dunsinane.up::tower1';
		txt += ' A rope leads upwards into the gloom.';
	}
	else
		dunsinane.exits = 'out::outside_dunsinane';

	return(txt);
}
function cut_thread()
{
	if(gs('ctthrd')==1)
	{
		say('There\'s nothing worth cutting here.');
		return;
	}
	
	if(!in_inv(scissors))
	{
		say('You haven\'t got anything to cut with.');
		return;
	}
	
	if(gs('shrpscs')==0)
	{
		say('The scissors are too blunt to cut the thread.');
		return;
	}
	
	inc_score();
	sgs('ctthrd',1);
	set_thingloc(dagger,dunsinane);
	say('You cut through the thread with the scissors. The \
dagger clatters to the ground.');
}
function look_rope()
{
	if(gs('strpe')==1)
		say('A sturdy cloth rope. It looks easily climbable.');
	else
		thingsee(rope);
}
function look_dagger()
{
	if(gs('ctthrd')==0)
		say('On closer inspection, the dagger is suspended \
by a thin thread.');
	else
		thingsee(dagger);
}
function take_dagger()
{
	if(gs('ctthrd')==0)
		say('You have it not, and yet you see it still.');
	else
		take(dagger);
}

pl('tower1',
'First floor of tower',
'It is gloomy here, and there is a musty \
smell. A rope leads down through a hatch in the floor. A wooden staircase \
leads further up.',
'',
'stairs::Plain woodens steps. They look safe enough.\
/rope::A sturdy cloth rope. It looks easily climbable.',
'up::*tower1_up()',
'down::dunsinane.up::tower2',
''
);
function tower1_up()
{
	if(!asleep(porter))
	{
		say('The porter bars your way.\n\
\"Oi! You can\'t go up there, it\'s Health and Safety rules!\"');
		return;
	}
	else
		move('up');
}

pl('tower2',
'Tower attic',
'This is a small, cramped loft at the top of the tower. Some stairs \
lead downwards.',
'',
'stairs::Plain woodens steps. They look safe enough.',
'take.hairspray::*take_hairspray()',
'down::tower1',
''
);
function take_hairspray()
{
	if(personloc(juliet)==tower2)
		say('Juliet stops you. \"That\'s mine! Hands off, thief!\"')
	else
		take(hairspray);
}

