!% -~S
!% $OMIT_UNUSED_ROUTINES=1
!% $ZCODE_LESS_DICT_DATA=1

Constant Story      "Cheap Scenery Demo";
Constant Headline   "^A sample game which uses PunyInform.^";

Constant STATUSLINE_SCORE; Statusline score;
Constant NO_SCORE = 0;

!Constant DEBUG;
Constant OPTIONAL_NO_DARKNESS;
Constant OPTIONAL_EXTENDED_METAVERBS;
Constant RUNTIME_ERRORS = 2; ! 0, 1 or 2. 0 = smallest file, 2 = most info

Constant INITIAL_LOCATION_VALUE = Library;

Include "globals.h";

! Cheap Scenery Parse Name constants. Use values 100-500.
Constant CSP_LIBRARY 100;

[ SceneryReply word1 word2 id_or_routine;
	! We can check location, if we want different answers in different rooms
	! We can also check action, and there's even an implicit switch on action,
	! so we can do things like: Take: "You're crazy.";
	switch(id_or_routine) {
	201: "Leave them papers or walls alone!";
	PARSE_NAME_AIR:
		! We don't use word2 for anything in this routine. We set it here, to avoid
		! a warning that it's unused
		word2 = 1;
		"You need the air to breathe, that's all.";
	CSP_LIBRARY:
		"The library is super-important. Better not mess with it.";
	}
	if(CSHasNoun('book'))
		"Leave the books to the people who care about them.";
	if(location == Library && word1 == 'shelf')
		"You're not supposed to touch the shelves.";
	"Remember you're in a library. There's no need to touch everything.";
];

Include "ext_cheap_scenery.h";
Include "puny.h";

[ PARSE_NAME_AIR;
	! There is no actual need for a parse_name routine here. It's just here for demonstration purposes
	if(NextWord() == 'air') return 1;
	rfalse;
];

[ WALL_DESC;
	Examine:
		"The walls are ",
			(string) random("all white", "claustrophobia-inducing", "scary",
				"shiny"), " here.";
	default:
		rfalse;
];

Constant BOOKDESC "You're not interested in reading.";

[SCN_ATMOSPHERE;
	Examine:
		"There's a really nice atmosphere to the place.";
	default:
		! Since this is a named routine, it will return true by default. Thus we
		! have to return false for all actions we don't care about
		rfalse;
];


Object Library "Library"
	with
		description "You are in a big lovely library. You can examine or try to
			take the old books, the papers, the library, the air, the atmosphere,
			the pushpull button, 
			the walls and the ceiling. The reading room lies east.",
		before [;
		Push:
			if(noun == CheapScenery && cs_match_id == 203) {
				CSPerformAction(##Examine, 200);
				rtrue;
			}
		Pull:
			if(noun == CheapScenery && cs_match_id == 203) {
				CSPerformAction(##Examine, 201);
				rtrue;
			}
		],
		e_to ReadingRoom,
		s_to Kitchen,
		cheap_scenery
			CS_THEM 14 'old' 'book' 'books//p' 'volume' 'volumes//p' BOOKDESC
			201 'paper' 'papers//p' "The papers are all dusty."
			CSP_LIBRARY CS_PARSE_NAME [ _i _w;
				_w = NextWord();
				if(_w == 'big') { _i++; _w = NextWord();}
				if(_w == 'lovely') { _i++; _w = NextWord();}
				if(_w == 'library') { _i++; return _i;}
				if(_w == 'house') { _i++; return _i;}
				if(_w == 'houses') { parser_action = ##PluralFound; _i++; return _i;}
				return 0;
			] "It's truly glorious."
			CS_MAYBE_ADD_LIST [; if(LightSwitch has on) rtrue; ] Library (switch_scenery)
			CS_ADD_LIST Library (inside_scenery)
			203 'pushpull' 'button' "Just a pretty button.",
		switch_scenery
			200 1 'light' "It's like real sunlight.",
		inside_scenery
			1 'hello' SCN_ATMOSPHERE
			CS_PARSE_NAME PARSE_NAME_AIR "The air is oh so thin here."
			200 1 'atmosphere' SCN_ATMOSPHERE
			201 'wall' 'walls//p' WALL_DESC
			1 'ceiling' [;
				Examine: "The ceiling is quite high up.";
				default: "There's no way you could reach it!";
			]
			'wall' 'ceiling' "It's just a regular wall-ceiling!";

Object -> LightSwitch "switch"
	with name 'switch',
	has static switchable;

Object -> Box "box"
	with
		name 'box',
		description "It's a fine box.",
	has container open openable;

Object ReadingRoom "Reading Room"
	with
		description "This is the reading room. The air feels different here.
			There's a single book sitting on one of the tables.
			You can examine or try to take the tables, the reading room,
			the air, the atmosphere, the walls and the ceiling. The library lies west.",
		w_to Library,
		cheap_scenery
			CS_PARSE_NAME PARSE_NAME_AIR "The air is thicker here than in the library."
			'single' 'book' "It's the classic ~Gone With the Wind~ by Margaret Mitchell."
			'table' 'tables//p' [;
				Examine: "Quite sturdy.";
				Take, Remove, Turn, Pull, Push: "You decide it's better to leave the tables where they are.";
			]
			'reading' 'room' "It's a very peaceful place."
			CS_ADD_LIST Library (inside_scenery);

Object Kitchen "Kitchen"
	with description "It is.",
	n_to Library;

[Initialise;
	print "^^Let's do this...^^";
	lookmode = 2;
];
