/*
 *
 * Aunts and Butlers
 *
 * Things
 *
 * code and data dealing with 'things' in the game,
 * which I'm making a point of NOT calling objects.
 *
 */

Thing = new Object;
NUM_THNG = 0;
function th(name,fullname,plural,wearable,firstplace,description,uses,pluses)
{
	Thing[++NUM_THNG] = new Object;
	Thing[NUM_THNG].id = NUM_THNG;
	Thing[NUM_THNG].name = name; // short version of name
	Thing[NUM_THNG].fullname = fullname; // full name
	Thing[NUM_THNG].plural = plural; // true for 'plural' things eg. gloves
	Thing[NUM_THNG].wearable = wearable; // true for clothing
	Thing[NUM_THNG].firstplace = firstplace; // starting place
	Thing[NUM_THNG].description = description;
	Thing[NUM_THNG].uses = uses // general uses
	eval(name + ' = Thing[' + NUM_THNG + '];');
}

// return "do" or "does"
function pldo(th)
{
	if(th.plural)
		return('do')
	else
		return('does');
}

th('nothing',
'nothing',
false,
false,
nowhere,
'It is nothing at all. You shouldn\'t be looking at it!',
'',
''
);

// list things in alphabetical order (or whatever order they are to
// be listed in in the inventory)

// th(name,fullname,plural,wearable,firstplace,description,uses,pluses)
th('bell',
'a bell',
false,
false,
servants_hall,
'A small silver bell in a curving cone shape, with an intricate pattern of \
carvings around the mouth.',
'wave::*ring_bell()', // 'ring' is a synonym of 'wave'
''
);
function ring_bell()
{

	say('Ting-a-ling-a-ling!');

	if(gs(MURDER_TIMER) > 0 && heroloc() == drawing_room)
	{
		// butler's big entrance.
		say('\n\
An impeccably dressed butler sidles into the room.\n\
"Excuse me, officer," he says to Sergeant Plank. "I can attest for Mr. Fodge\'s \
alibi with respect to the crime. Mr. Fodge, at the time, was attending a \
cricket-match. Springshire versus Hemsington, as I recall, with Hemsington requiring \
some 140 runs for a win at close of play."\n\
"I see," says Sergeant Plank sceptically. "And you were at this cricket match \
with him, were you?"\n\
"No," says the butler. "I was at that time murdering Miss Cedilla."\n\
"Er... then you\'re nicked," says Plank. "Looks like you got away with it this time, \
Fodge."\n\
As the Sergeant leads him away in chains, the butler seems to wink at you.');

		sgs(MURDER_TIMER, 0);
		set_personloc(butler, cell);
		set_personloc(plank, police);
		inc_score();

	}
	// bell has no effect while the butler is in prison
	else if(gs(DONE_GAOLBREAK)==1)
	{
		// special case on the roof
		if(heroloc()==roof)
		{
			say('\nAn impeccably dressed butler emerges from the drizzle above you, \
sliding rapidly down the roof on his heels. He has just time to say "May I recommend taking \
hold of some convenient fixture, siiiir..." before he disappears over the edge.');
			set_personloc(butler, servants_hall);
		}
		else
		{
			set_personloc(butler, heroloc());
			say('\nAn impeccably dressed butler sidles up to you from nowhere \
in particular.\n\
"You rang, sir?"');
		}
	}
}


th('suitcase',
'a black leather suitcase',
false,
false,
nowhere,
'A thin black leather suitcase, monogrammed "C. F."',
'open::*open_suitcase()',
''
);
function open_suitcase()
{
	if(gs(OPENED_CASE)!=1)
	{
		say('Opening the suitcase reveals a china urn.');

		if(in_inv(suitcase))
			give_hero(urn)
		else
			set_thingloc(urn, heroloc());

		inc_score();
		sgs(OPENED_CASE, 1);
	}
	else say('There\'s nothing else in the suitcase.');
}

th('urn',
'a china urn',
false,
false,
nowhere,
'A small urn made of fine bone-china. A plaque on the front reads: "GLADSTONE". \
The china is so thin it is translucent, and there seems to be something shaking \
around inside.',
'wave::Yes, there\'s definitely something inside.\
/open::There\'s no obvious way to open it.\
/smell::The urn has a faint canine odour to it.\
/empty::It\'s sealed up.\
/drop::*break_urn();/break::*break_urn();/fight::*break_urn();',
''
);
function break_urn()
{
	take_away(urn);

	say('The urn shatters!\n\
A sad-looking clump of ash rolls out of the wreckage.');
	inc_score();
	
	set_thingloc(ash, heroloc());
}

th('ash',
'a clump of ash',
false,
false,
nowhere,
'A pathetic-looking clump of grey-brown powder, not dissimilar to the contents \
of an ashtray without the cigarette butts.',
'eat::Don\'t be revolting.\
/smell::The ashes have a faint canine odour to them.',
''
);

th('iou',
'an IOU',
false,
false,
bedroom,
'Something you wrote out recently in a last-ditch attempt to thwart His Majesty\'s \
Debt Recovery Service, in response to some unpleasant police summons (so, unfortunately, \
it\'s more of a you-owe-them.) It is addressed to the local police station, and reads: \
"I, Ampersand Fodge, hereby promise to surrender the sum of twelve thousand pounds, \
eight shillings and ninepence three-farthings" - and continues in the tiniest handwriting \
you could manage - "in the year nineteen-eighty."',
'',
''
);

th('will',
'a last will and testament',
false,
false,
aunts_flat,
'It reads: "I, Miss Cedilla Fodge, leave my wastrel of a nephew, the Hon. Ampersand \
Fodge, to the local university medical school, where perhaps he can be put to some use \
in pharmacological testing. My monetary fortune goes to the Cardigans Committee of \
the South Hemsington Knitting Club. Gladstone gets the flat."',
'',
''
);

th('letter',
'[[ gs(RIPPED_LETTER)==1 ? "half " : "" ]]a love-letter',
false,
false,
bedroom,
'[[ describe_letter() ]]',
'break::It has too much sentimental value.',
''
);
function describe_letter()
{
	if(gs(RIPPED_LETTER)!=1)
		return 'The love-letter is dated a couple of years ago, and stained \
with teardrops and brandy. It reads simply: "Ampersand, I\'m leaving you. \
Everything is wrong."'
	else
		return 'The bottom half of the love-letter has been ripped away. It now reads: \
"Ampersand, I\'m leaving you. Everything"';
}

//(name,fullname,plural,wearable,firstplace,description,uses,pluses)
th('haggis',
'a haggis',
false,
false,
thenorth,
'An entire sheep, minced, crammed into its own stomach with some oats and spices, \
boiled for three hours, and deep-fried as an afterthought. You can feel your arteries \
clogging just looking at the thing - it\'s probably extremely unhealthy.',
'eat::*eat_haggis()\
/smell::Quite revolting.\
/fight::No way you\'re fighting that. It might well beat you.',
'');
function eat_haggis()
{
		if(!butlerWarn('I would not advocate consuming that product. \
It contains unwholesome levels of cholesterol, triglycerides, and sheeps\' organs, \
which may disagree with your constitution.', WARNED_HAGGIS, 1))
		{
			die('You take a few bites of the haggis. It has the \
sort of taste that a connoisseur might describe, diplomatically, as "...interesting." \
It\'s greasy, and far too spicy, and yet it does have a certain moreishne- hang on, \
your left arm feels a bit funny - and - argh - your heart -');
		}

}
 

//th(name,fullname,plural,wearable,firstplace,description,uses,pluses)
th('bone',
'a squeaky rubber bone',
false,
false,
aunts_flat,
'A squeezable blue rubber toy in the shape of a child\'s drawing of a dog\'s \
bone. It is well-chewed, pocked by small tooth-marks, and slightly damp.',
'squeeze::*squeeze_bone();\
/eat::There\'s not much meat on it.\
/throw::*throw_bone();',
'');
function squeeze_bone()
{
	say('Squeezing the bone produces a high-pitched squeaking noise.');
	if(personloc(gladstone)==heroloc())
		say('\nGladstone leaps wildly and just fails to snatch the thing \
from your hand.');
}
function throw_bone()
{
	say('You [[in_inv(bone) ? "throw the bone" : "pick up the bone and throw it"]]\
 a short distance.');
	if(personloc(gladstone)==heroloc())
		say('\nGladstone leaps, catches it gratefully, deposits it at \
your feet, and recommences yapping.');

	take_away(bone);
	set_thingloc(bone, heroloc());
}



//th(name,fullname,plural,wearable,firstplace,description,uses,pluses)
th('stovepipe',
'a stovepipe',
false,
true,
nowhere,
'A piece of porceilain piping about a foot long and six inches in diameter, \
At one end there is a sort of flat brim for the bolts to go through, like the bottom \
of a top hat.',
'wear::[[ wear(stovepipe), worn(stovepipe) ? " It makes a rather spiffing topper." : "" ]]',
''
);



th('tailcoat',
'a tailcoat',
false,
true,
servants_quarters,
'A black frock-coat with long, flapping tails, of the kind that \
you regularly see worn by other people\'s more valued servants. It is a couple \
of decades behind the current fashion, and has a few lash-marks on the back, \
but is otherwise in good condition.',
'wear::*wear(tailcoat); get_suitcase();',
''
);

th('teacup',
'a teacup',
false,
false,
drawing_room,
'A white, bone-china teacup with a sickening blue motif illustrating the biography \
of a couple of love-birds. [[ cup_contents() ]]',
'drink::*drink_tea();\
/smell::*smell_tea();\
/empty::*empty_cup();\
/fill::*fill_cup();',
''
)
function fill_cup()
{
	if(heroloc()!=scullery)
	{
		say('There\'s nothing worth filling it with here.');
		return;
	}
	
	var cupConts = gs(CUP_CONTENTS)
	if(cupConts==0)
	{
		sgs(CUP_CONTENTS, 1);
		say('Okay. The teacup is now full of dirty grey rainwater.');
		if(gs(WATER_POINT)!=1)
		{
			sgs(WATER_POINT, 1);
			inc_score();
		}
	}
	else if(cupConts==3)
	{
		sgs(CUP_CONTENTS, 2);
		say('You fill the teacup up with rainwater. The ash dissolves neatly, \
turning the water a pale, greasy brown.');
		inc_score();
		if(gs(WATER_POINT)!=1)
		{
			sgs(WATER_POINT, 1);
			inc_score();
		}
	}
	else
		say('The cup is already full.');
}
function cup_contents()
{
	var c = gs(CUP_CONTENTS)
	if(c==0)
		return 'It is empty.'
	else if(c==1)
		return 'It contains dirty grey rainwater.'
	else if(c==2)
		return 'It contains a pale, greasy, brown liquid.';
	else if(c==3)
		return 'It contains a clump of ash.';
}
function empty_cup()
{
	var c = gs(CUP_CONTENTS)
	if(c==0)
		say('The teacup is already empty.')
	else if(c==1)
	{
		say('Okay. The cup is now empty.'); // never mind where the water went
		sgs(CUP_CONTENTS, 0);
	}
	else if(c==2)
	{
		// use same warning flag as drinking the tea - it's for the same reason
		if(!butlerWarn('I should hesitate before disposing of the concoction \
contained within that vessel. It may prove advantageous in future, for some particularly \
bizarre purpose.', WARNED_TEA))
		{
			// silly
			say('Okay. You pour the liquid out of the cup. It evaporates.');
			sgs(CUP_CONTENTS, 0);
		}
	}
	else if(c==3)
	{
		say('Okay. You tip the ash out of the teacup.');
		sgs(CUP_CONTENTS, 0);
		set_thingloc(ash, heroloc());
	}
		
	
}
function drink_tea()
{
	var c=gs(CUP_CONTENTS)
	if(c==0)
		say('The cup is empty.');
	else if(c==1)
	{
		sgs(CUP_CONTENTS, 0);
		say('You down the rainwater in one... ugh. Not nice. Best stick to brandy in \
future.');
	}
	else if(c==2)
	{
		if(!butlerWarn('As appetising as that liquid may appear, you may recall \
synthesising it by dissolving the conflagrated carcass of a poodle amongst some \
runoff rainwater. Such a suspension is not likely to constitute a refreshing \
beverage.', WARNED_TEA))
		{
			sgs(CUP_CONTENTS, 0);
			say('You down the greasy brown liquid in one... ugh. Foul. Best stick to \
brandy in future.')
		}
	}
}
function smell_tea()
{
	say('The teacup doesn\'t smell very \
[[ gs(CUP_CONTENTS)==0 ? "interesting" : "nice"]]\
[[ gs(CUP_CONTENTS)==2 ? " at all" : "" ]].');
}

//th(name,fullname,plural,wearable,firstplace,description,uses,pluses)

th('hat',
'an ugly hat',
false,
true,
nowhere,
'An astonishingly ugly piece of headgear, presumably tailor-made for some \
bygone Ascot. It has a narrow brim, several pink ribbons, and a stuffed \
pheasant on top.',
'wear::*wearHat();/remove::*removeHat();',
'');
HAT_TIMER_MAX = 3;
function wearHat()
{
	if(!butlerWarn('That hat does not befit you handsomely. It \
is quite unsuited to your colour.', WARNED_HAT))
	{
		wear(hat);
		if(gs(VIRG_ARRIVED)==1 && personloc(virgule)==nowhere)
			sgs(HAT_TIMER, HAT_TIMER_MAX);
	}
}
function removeHat()
{
	sgs(HAT_TIMER, 0);
	unwear(hat);
}

th('bottle',
'a vinaigrette bottle',
false,
false,
nowhere, // gets given to player in intro
'A conical bottle for superior-grade balsamic vinaigrette. It is empty.',
'drink::You have already done so. The bottle is empty.\
/smell::It smells deliciously acidic.\
/fill::It would be a crime to fill this bottle up with anything but, \
at the very least, cheap cider vinegar.',
'',
''
);

th('tie',
'a woollen tie',
false,
true,
nowhere,
'[[gs(GOT_TIE)==1 ? "A" : "The typist is wearing a"]] neck-tie of thick brown wool. It [[worn(tie) ? "feels" : "looks"]] rather cosy.',
'',
''
);

th('collar',
'a trilatinum-splorex collar',
false,
true,
nowhere,
'[[ gs(GOT_COLLAR)==1? "A" : "In the centre of the stardrive is a"]] thin rectangle of expensive-looking white \
material, about one inch by twelve, bent into a hoop shape, with little wing-like triangles folded \
outwards at either end. It feels hot underneath.',
'',
''
);

th('jerkin',
'a natty jerkin',
false,
true,
nowhere,
'A rather splendid waist-length jerkin in yellow check. It is about your size\
[[ personloc(cowboy)==tavern ? " (but unfortunately the unconscious cowboy is wearing it)" : "" ]].',
'',
'');

th('cufflinks',
'a pair of sapphire cufflinks',
true,
true,
treasure_chamber,
'A pair of bona-fide ancient Egyptian cufflinks, with shining blue sapphires set in.',
'',
'');

th('flower',
'a flower',
false,
true,
nowhere,
'A charming blue flower that would match the eyes of any chap who was wearing it.',
'',
'');

//(name,fullname,plural,wearable,firstplace,description,uses,pluses)
th('lance',
'a lance',
false,
false,
jousting_field,
'A long, heavy, metal stick. Just the thing for knocking a chap off a horse.',
'',
'');


th('handkerchief',
'a handkerchief',
false,
true,
nowhere,
'A fine silk handkerchief. [[worn(handkerchief) ? "It brings out your suit nicely." : \
"It\'d bring out your suit nicely if you wore it." ]]',
'',
'');

th('gloves',
'a pair of gloves',
true,
true,
globe,
'A pair of rather nice black leather gloves.',
'',
'');

th('card',
'a visiting card',
false,
false,
nowhere,
'A visiting-card printed in spidery black letterpress. It reads: "J Epsom Sepulchre, Solicitor."',
'',
'');

// the last 'real' thing, it's funnier when it's last in your inventory
th('corpse',
'Aunt Cedilla\'s corpse',
false,
false,
nowhere,
'Not pretty.',
'eat::You disgusting savage! You don\'t have the right kind of wine!\
/smell::Still quite fresh, fortunately.\
/kiss::I think Miss Manners might have something to say about that.\
/bury::Pointless.\
/take::It\'s too heavy!',
'');

// false things - things that never become 'real' manipulable objects, but the player should think they might
th('shotgun','a shotgun', false, false, nowhere, '', '', '');


