!% -SD

Constant Story "Underground";
Constant Headline "^A one-room zombie sandbox game
		^By Vincent Zeng^
		^(for more info, type 'about')^^";
Release 0; Serial "141001";
Include "Parser";
Include "VerbLib";
Include "Menus";
Include "Grammar";

!== time management
Constant TICKMAX = 5;  !== length of a phase 
Global phaseCount= 0; !== how many times we've ticked over
Global currentTick = 0; !== current tick

!== appendix
Global humanDesc = "You're looking a little ragged around the edges, but at
least your blood is flowing."; 

Global zombieDesc = "There's this body. You've only got a
vague connection to it, but maybe you can order it around.";

Global poss = "the"; !==as a zombie, do not get personal possession

!== info about character
Global isAwake = false; 
Global isShackled = true;

!=======MENUS 

!=======CLASSES 

Class Room 
	with
		cant_go "That's not helping.",
		before [;
			Go: 
				if (isShackled) {
					print_ret "Shackles around ", (string) poss, " ankles pull taut with a heavy clang.";
				}
			Unlock, Disrobe:
				if (isAwake) {
				} else {
					"You order the body around, but it just stands there, unable to comprehend.";
				}
		],
		each_turn [ ;
			currentTick++;

			if (currentTick >= TICKMAX) {  !=== do all the tick stuff
				style bold;
				print "The lights flicker for a moment.^";
				style roman;
				if (isAwake) {
					box "Your body feels leaden, and you"
					"experience the strange sensation of"
					"sliding up out of your own head."
					"The body isn't yours anymore.";
					isAwake = false;
					poss = "the";
					player.description = zombieDesc;
					move body to player;
					give body ~concealed;
					body.description = "A body. It might even be yours.";
					!new_body = Body.create();
					!move new_body to player;
				} else {
					box "You get the sudden feeling of being"
					"sucked right into the body you've been"
					"trying to steer. Your pulse races"
					"briefly. When you open your eyes,"
					"your body feels like your own."; 
					isAwake = true;
					poss = "your";
					move body to location;
					give body concealed;
					body.description = "Your body. You feel pretty attached to it.";
					player.description = humanDesc;
				}
				
				phaseCount++;
				currentTick = 0;
			}

			if (location == stairwell) { !=== endgame state
				deadflag = 3;
				print "You walk away from all of this.";
			}

		];

Class Prop
	with
		before [;
			Examine:
				return false;
			default:
				print_ret "That's not really useful.";
		],
	has	scenery;

Class Wall
	with	description
		"Peeling paint and flaking plaster.",
		name 'wall' 'walls' 'plaster',
		damage 0,
		before [;
			Attack:
				if (self.damage < 3) {
					self.damage++;
					if (isAwake) {
						"You smash at the wall, damaging it a little. It stings.";
					} else {
						self.damage++;
						"On your command, the body thrashes at the wall, doing considerable damage.";
					}
				} else {
					remove self;
					print_ret "The wall crumbles away under ", (string) poss, " abuse.";
				}
			Examine:
				switch(self.damage) {
					0: 
						"Peeling paint and flaking plaster.";
					1:
						"Damaged paint and crumbled plaster.";
					2:
						"It's falling apart.";
				}
		],
	has	scenery;

!=======ROOMS

Room basement "The Basement"
	with	description 
		"The basement is full of junk. Stairs lead up.",
		u_to stairwell,
	has 	light;

Wall n_wall "northern wall" basement
	with	description "The northern wall.",
		name 'northern wall' 'north wall',
	has	;

Room stairwell "Basement Exit"
	with	description
		"The way out.",
		s_to basement,
	has 	light;

!=======OBJECTS
Prop stairs "stairs" basement
	with 	description
		"Stairs that lead out of the basement.",
		name 'stairs' 'steps' 'stair' 'step',
	has	;	

Prop lights "lights" basement
	with	description
		"A naked bulb dangling from above.",
		name 'lights' 'light' 'lamp' 'bulb',
	has	;

Object shackles "pair of shackles" 
	with 	description
		"A pair of heavy iron shackles, bolted to the wall.",
		name 'shackles' 'shackle' 'chains' 'manacles',
		with_key shackle_key,
		before [;
		!	Examine:
		!		if (self.worn) {
		!			if (isAwake) {
		!				print_ret "Iron shackles bound tightly around your ankles.";
		!			} else {
		!				print_ret "Iron shackles bound tightly around the ankles.";
		!			}
		!		} else {
		!		}
			Disrobe:
				if (self has locked ) {
					print_ret "It's not possible to remove locked shackles.";
				} else {
					if (isAwake) {
						isShackled = false;
						give self ~worn;
						print_ret "You reach down and open the shackles. They drop to the ground with a heavy clang.";
					} else {
						print_ret "You order the body to remove the shackles, but it just stands there, unable to comprehend.";
					}
				}
			Wear:
				if (isAwake) {
					isShackled = true;
					give self worn;
					print_ret "It's too dangerous to let the body move around on its own; you shackle your ankles.";
				} else {
					print_ret "You order the body to put on the shackles, but it just stands there, unable to comprehend.";
				}
			Take:
				"They're bolted in place.";
			Remove:
				<<Disrobe self>>;
		],
	has	static lockable clothing;

Object shackle_chain "shackle chain" basement
	with	description
		"A heavy chain securing the shackles to the wall.",
		name 'chain',
	has	static scenery;

Object shackle_bolt "shackle bolts" basement 
	with	description
		"Four heavy machine bolts securing the shackles to the wall.",
		name 'bolt' 'bolts' 'machine' 'screw' 'screws',
	has	static scenery;

Object shackle_key "shackle key" basement
	with	description
		"butts",
		name "key" "shackle key",
	has;

Object junk "pile of junk" basement
	with	description
		"A television, a toolbox, a wooden bookshelf, a metal locker...",
		name 'junk' 'pile' 'trash' 'clutter',
	has	transparent container open scenery;

Object tv "television" junk 
	with	description
		"A dusty old television.",
		name 'tv' 'telly' 'television' 'tube',
	has	supporter switchable;

Object toolbox "toolbox" junk 
	with	description
		"An old red metal toolbox.",
		name 'toolbox',
	has	container openable ~open;

Object wooden_bookshelf "wooden bookshelf" junk 
	with	description
		"A rickety wooden bookshelf full of books.",
		name 'shelf' 'bookshelf' 'rickety' 'wooden',
	has	supporter static;

Object locker "metal locker" junk 
	with	description
		"A rusty metal locker.",
		name 'locker' 'rusty',
	has	container openable static;

Object puppy "puppy" basement
	with	description
		"A puppy.",
		initial [;
		if (isAwake) {
			print_ret "A small puppy sits in the farthest coner from you, regarding you with caution.";
		} else {
			print_ret "A small puppy sits in the farthest corner, quiet with fear.";
		}
		],
		name 'puppy' 'pupy' 'pup' 'dog' 'doggy',
		before [;
			Take:
				print_ret "The pup doesn't budge.";
			Open:
				if (isAwake) {
					print_ret "The puppy whines pitifully at you as you pull on its limbs, then squirms out of your grasp.";
				} else {
					remove self;	
					print_ret "With a desperate clawing, the puppy down gets split the middle. It yelps for only a moment.";
				}
		],
	has	animate;

!Class Body (100)
Object body "body" 
	with	description
		!if (isAwake) {
		!	"Your body. You feel pretty attached to it.",
		!} else {
			"A body. It might even be yours.",
		!}
		name 'body' 'me' 'corpse' 'zombie' 'pc' 'player' 'reader',
		each_turn [;
		!	if (isAwake) {
		!		move self to location;
		!		give self concealed;
		!	} else {
		!		move self to player;
		!		give self ~concealed;
		!	}
		],
		before [;
			Drop, Eat, Attack: 
				"You can't.";
			Think:
				"Yeah, it's definitely your body.";
		],
	has	transparent;

Class Bodypart
	has	;

Bodypart ankles "ankles" body
	with	description 
		"Connects feet to legs.",
		name 'ankles' 'ankle',
	has	;
!=======grammar=============


!=======menus================

Menu about_menu "Underground";
Option -> "Info"
	with description "Underground puts you in the position of a zombie bite victim who has been chained up in the basement and left to die.";
Option -> "Spoilers"
	with description "You change modes from being awake and present in your body, and being an unconscious zombie every so and so number of moves.^
		^The zombie form is a lot stronger than the human form, but cannot perform sophisticated tasks.^
		^Your time as a human is limited. Each move you take costs you time.^
		^There isn't really 'win' state.";
Option -> "Credits"
	with description "";

Verb 'help' 'about' 'menu' 'hints'
	* -> Help;

[ HelpSub;
	about_menu.select();
];

!=======initializing==========

[ Initialise ;
	location = basement;
	lookmode = 2;

	player.description = zombieDesc;
	!new_body = Body.create();
	!move new_body to player;
	move body to player;
	move shackles to player;
	give shackles worn;
	give shackles locked;

	!print "^Everything seems hazy, as if you are not seeing the world through your eyes.^";
	];
