! - John McLeod ! - CIS 487 ! - Interactive Fiction Project ! - Fall 2002 ! - Constants ------------------------------------------------------------------------------------- Constant STORY "Kody's Bones"; Constant HEADLINE "^Inform Text Adventure^written by Keith McLeod 10/14/2002^"; Constant TOTAL_BONES 3; Constant MAX_CARRIED 1; Constant MAX_SCORE 23; ! - Global variables ------------------------------------------------------------------------------ Global boneOrbones; Global bonesFound; Global bonesInBed; ! - User defined attributes ----------------------------------------------------------------------- attribute bone1Taken; attribute bone2Taken; attribute bone3Taken; !attribute bone4Taken; !attribute bone5Taken; ! - These are the libraries that are referenced by the compiler. ---------------------------------- Include "parser"; Include "verblib"; Include "grammar"; ! Initialise function ----------------------------------------------------------------------------- [Initialise; !Verbose mode: every time player enters a room, he gets a full description... lookmode=2; ! - Start Kody out in his bed... location = kodys_bed; print "Kody is a 5 month old black Labrador Retriever. He's so cute!^"; print "He just loves to eat his bones but on some occasions he can't eat^"; print "them all so he has to hide them. He's just a puppy so he doesn't ^"; print "always remember where he's hid them. Will you help him find them?^"; print "He's only missing three.^^^"; ]; ! - A class for all the furniture in the house... Class Furniture with before [; Take, Pull, Push, PushDir: print_ret "You can't do that! You're just a puppy!"; ], has static supporter scenery ; ! - A class for all the bones... Class Bone with name 'bone', description "A yummy, tasty bone!", before [; insert: score++; bonesInBed++; take: if(location == bottom_of_stairs) { if ((bottom_of_stairs.has_been_sniffed && bottom_step.has_been_looked_under) || bottom_step.has_been_looked_under) { if(player hasnt bone2Taken) { move bone2 to player; give player bone2Taken; bonesFound++; score++; print_ret "You pick up the bone and are carrying it in your mouth."; } else { print_ret "You've already taken the bone from here!"; } } else { print_ret "You can't take a bone! You don't even know where it is!"; } } if(location == jamies_room) { if(jamies_entertainment_center.hasBeenLookedUnder) { if(player hasnt bone1Taken) { move bone1 to player; give player bone1Taken; bonesFound++; score++; print_ret "You pick up the bone and are carrying it in your mouth."; } else { print_ret "You've already taken the bone from here!"; } } else { print_ret "You can't take a bone! You don't even know where it is!"; } } if(location == karis_room) { if(pile_of_clothes.hasBeenMoved || pile_of_clothes.hasBeenLookedUnder) { if(player hasnt bone3Taken) { move bone3 to player; give player bone3Taken; bonesFound++; score++; print_ret "You pick up the bone and are carrying it in your mouth."; } else { print_ret "You've already taken the bone from here!"; } } else { print_ret "You can't take a bone! You don't even know where it is!"; } } else { print_ret "Hmmm, There doesn't seem to be any bones here."; } ], each_turn [; if (bonesInBed == TOTAL_BONES) deadflag = 2;], has concealed ; Class Bed with name 'bed' has scenery light ; Class Pillow with name 'pillow', description "A fluffy soft pillow.", has scenery ; !Used to allow the player to "bark" to objects. The parser will recognize the following forms: !"bark" noun !"bark to" noun [BarkSub; "Bark bark bark. (This is puppy talk! No one knows what you are saying!)";]; verb "bark" * "to" noun -> Bark * noun -> Bark ; [BoneCountSub; "You have found ", bonesFound, " out of ", TOTAL_BONES, " bones.";]; verb "bonecount" * -> BoneCount ; [LookBehindSub; "Nothin' goin' on here";]; verb "lookbehind" * noun -> LookBehind ; [DrinkFromSub; "I hope it was flushed!";]; verb "drinkfrom" * noun -> DrinkFrom ; ! * The kitchen of the house ********************************************************************** Object kitchen "Kitchen" has light, with name 'kitchen' 'kit' 'k', description "You are in the kitchen which is located in the back of the house.^ It's a pretty big room. The family computer is in this room. ^ Of course, there is also the family dinning room set which is a table^ and four chairs. It also has the usual kitchen appliances.^^ Most importantly, this is also where Kody sleeps at night. He has a^ very comfortable bed that he sleeps in.^^ Go north into the hallway,^ or southwest into the back door landing. The landing leads to the basement of the house.", n_to west_hall, sw_to landing, ; ! - The dining room set - Furniture dining_set "Dining room set" kitchen with name 'dining' 'set' 'table' 'chair' 'chairs', description "A very nice dining room set made of solid oak. There is a table^and four chairs.", has_been_looked_under false, before [; lookunder: if(self.has_been_looked_under == false) { self.has_been_looked_under = true; score++; print_ret "Nothin' under here!"; } else { print_ret "Nothin' under here!"; } smell: print_ret "Smells like wood to me!"; ], has ; ! - The refrigerator in the kitchen - Object refrigerator "Refrigerator" kitchen with name 'frige' 'refrigerator', description "A very nice frost free, freezer on the top, refrigerator.", has_been_looked_under false, before [; take: print_ret "You don't really think you can take the refrigerator, now do you?"; Pull, Push, PushDir: print_ret "You can't do that! You're just a puppy!"; lookunder: if(self.has_been_looked_under == false) { self.has_been_looked_under = true; score++; print_ret "Yuck!"; } else { print_ret "Yuck!"; } ], has static scenery ; ! - The stove in the kitchen - Object stove "Stove" kitchen with name 'stove', description "A four burner electrice stove.", has_been_looked_under false, before [; take: print_ret "Take the stove!? I don't think so, Mister!"; Pull, Push, PushDir: print_ret "You can't do that! You're just a puppy!"; lookunder: if(self.has_been_looked_under == false) { self.has_been_looked_under = true; score++; print_ret "Yuck!"; } else { print_ret "Yuck!"; } ], has static scenery ; ! - This is just something that is found if the player looks under the stove - Object frenchFry "french fry" kitchen with name 'french' 'fry', before [; take, eat: print_ret "You don't really want that. It's pretty nasty."; ], has scenery ; ! - Kody's bed - Object kodys_bed "Kody's bed" kitchen with name 'bed' 'dogs' 'kodys' 'dog', description "Kody's bed is very soft and warm. It's a little big for him because he's^ just a puppy and this bed is for grown up dogs. Kody just loves to keep^ his toys and his bones in his bed!", before [; examine: ! I like to use good grammar, so let's make sure we don't say we have ! 1 bones in his bed... if (score == 1) boneOrBones = "bone"; else (boneOrBones) = "bones"; ! If the user examines the bed, tell them what's in the bed... if (score > 0) print_ret "Kody has his chew rope, a ball, an old shoe, and ", score, boneOrBones, " in his bed."; else print_ret "Kody has his chew rope, a ball, an old shoe, and 0 bones in his bed."; ], has container open scenery ; ! * The landing *********************************************************************************** Object landing "The back landing" with name 'landing' 'back' 'the', description "This is the back landing in the kitchen. Go northeast into the kitchen. To the west is the ^ door leading outside to the driveway. To the north is the stairway^ leading down to the basement. There is an area at the bottom of the stairs^ that leads to the basement door. The basement door is closed.", ne_to kitchen, d_to bottom_of_stairs, has light scenery ; ! * The bottom of the stairs ********************************************************************* Object bottom_of_stairs "The area at the bottom of the stairs." with name 'bottom' 'stairs' 'steps', description "This is a small area at the bottom of the steps. There is a door^ leading into the basement but it is closed tight and cannot be opened.^ There is a small area underneath the bottom step. Go up to the back landing.", has_been_sniffed false, before [ sniffedState; !a local variable that tells whether Kody has sniffed this area. smell: if(self.has_been_sniffed == false) { self.has_been_sniffed = true; sniffedState = self.has_been_sniffed; score++; print_ret "Hmmm. I believe there is a hint of doggy bone in the air."; } else { print_ret "Hmmm. I believe there is a hint of doggy bone in the air."; } examine: print_ret "Just a small area at the bottom of the steps. There is a closed^ door on one side and the steps leading to the kitchen on the other. There is a small hidden area under the bottom step.^"; ], u_to landing, has light scenery static supporter ; ! * The door to the basement. ********************************************************************* Object basement_door "Basement door" bottom_of_stairs with name 'door' 'basement', description "This is the door to the basement. It is shut tight and you cannot open it.", has_been_pushed false, tried_to_open false, before[; push: if(self.has_been_pushed == false) { self.has_been_pushed = true; score++; print_ret "You're not allowed in the basement Kody. This door is shut tight!"; } else { print_ret "You're not allowed in the basement Kody. This door is shut tight!"; } open: if(self.tried_to_open == false) { self.tried_to_open = true; score++; print_ret "You're just a puppy Kody! You can't turn a door handle!"; } else { print_ret "You're just a puppy Kody! You can't turn a door handle!"; } ], has scenery ; ! * The bottom step. This is where the bone is hidden. ******************************************** Object bottom_step "The bottom step" bottom_of_stairs with name 'last' 'step', description "This is the bottom step.", has_been_looked_under false, before [; examine: print_ret "This is the last step of the stairs. There is a small area underneath the step."; lookunder: if(self.has_been_looked_under == false) { self.has_been_looked_under = true; score++; if(player hasnt bone2Taken) { print_ret "It's dark and full of spider webs. A bone is hidden in the corner."; } else { print_ret "It's dark and full of spider webs."; } } else { if(player hasnt bone2Taken) { print_ret "It's dark and full of spider webs. A bone is hidden in the corner."; } else { print_ret "It's dark and full of spider webs."; } } ], has scenery ; ! - Bone #2 - Bone bone2 "Bone2" bottom_of_stairs with name 'bone2' '2', ; Object west_hall "The west end of the hall" with name 'west' 'w' 'hall' 'h', description "You are in the west end of the hallway. Not much goin' on here.^ Go south into the kitchen,^ west into the living room,^ east to the middle of the hall,^ or north into Jamie's room.", w_to living_room, e_to middle_hall, s_to kitchen, n_to jamies_room, has light, ; Object living_room "the living room" with name 'living' 'room' 'l' 'r', description "You are in the living room. This is the largest room in the house.", e_to west_hall has light, ; ! * The bathroom ********************************************************************************** Object bathroom "Bathroom" with name 'bathroom', description "This is the bathroom. It's just a normal bathroom with a sink, a tub, and a toilet.^ Go north to the middle hall.", n_to middle_hall, has light ; ! * This is the toilet in the bathroom. I know it's gross, but dogs do drink from the toilet. So, if ! the player thinks of it, let's give them a point for it. Object toilet "Toilet" bathroom with name 'toilet', description "What's to know? It's a toilet!", hasBeenDrankFrom false, before[; taste: if(self.hasBeenDrankFrom == false) { self.hasBeenDrankFrom = true; score++; print_ret "Gross! But I guess we'll give you a point for it!^ I hope you brush your teeth later! :)"; } else { print_ret "One point for drinking out of a toilet is enough!"; } drinkfrom: if(self.hasBeenDrankFrom == false) { self.hasBeenDrankFrom = true; score++; print_ret "Gross! But I guess we'll give you a point for it!^ I hope you brush your teeth later! :)"; } else { print_ret "One point for drinking out of a toilet is enough!"; } smell: print_ret "Sorry, I'm not going to describe the smell of this toilet. Let's just^ say there's no bone here."; ], has scenery ; ! * The middle part of the hallway **************************************************************** Object middle_hall "Middle hall" with name 'middle' 'hall' 'm' 'h', description "This is the middle part of the hall.^Go south into the bathroom,^ east to the east end of the hall,^or west to the west end of the hall.", e_to east_hall, w_to west_hall, s_to bathroom, has light, ; ! * Object definitions for Jamie's room *********************************************************** Object jamies_room "Jamie's room" with name 'jamies' 'room' 'jamie^s', description "You are now in Jamie's room. It is not very big but it is still very nice.^ She has an entertainment center that is sitting ~kitty korner~ in^ one corner of the room. It has a TV and a DVD player on it along with^ Jamie's knick-knacks. Opposite the entertainment center is a desk with^ a computer on it. Behind the door, is her closet where she keeps all^ her clothes.^ Go south to the west hall, up to the top of Jamie's bed.", s_to west_hall, u_to top_of_jamies_bed, has light, ; Object jamies_closet "Jamie's closet" jamies_room with name 'jamies' 'closet' 'jamie^s', description "This is Jamie's closet. She keeps her clothes and shoes in here. It's rather ^ dark and dusty in there!", beenExamined false, before[; examine: if(self.beenExamined == false) { score++; self.beenExamined = true; print_ret "You look into the closet. There's just a bunch of clothes and shoes in there. It's rather ^ dark and dusty! You would never hide one of your delicious bones in there!"; } else { print_ret "You look into the closet. There's just a bunch of clothes and shoes in there. It's rather ^ dark and dusty! You would never hide one of your delicious bones in there!"; } ;], has scenery ; Bed jamies_bed "Jamie's bed" jamies_room with name 'jamies' 'bed' 'jamie^s', description "This is Jamie's bed. It's soft and comfy with two pillows on it.^ Go down to the floor.", hasBeenLookedUnder false, hasBeenLookedBehind false, hasBeenSmelled false, d_to jamies_room, before[; smell: if(self.hasBeenSmelled == false) { self.hasBeenSmelled = true; score++; print_ret "Nothin' up here but pillows and blankets!"; } else { print_ret "Nothin' up here but pillows and blankets!"; } lookunder: if(self.hasBeenLookedUnder == false) { score++; self.hasBeenLookedUnder = true; print_ret "Nothin' under here but some CD's, a brush, and some dust bunnies!"; } else { print_ret "Nothin' under here but some CD's, a brush, and some dust bunnies!"; } ], ; Object top_of_jamies_bed "Top of Jamie's bed" jamies_room with name 'bedtop', description "You are on Jamie's bed. There is just a pillow up here. I really don't think you should be up here!", d_to jamies_room, before[; look: print_ret "You are on Jamie's bed. There is just a pillow up here. I really don't think you should be up here!"; ], has light scenery ; Pillow jamies_pillow "Jamie's pillow" top_of_jamies_bed with name 'jamies' 'pillow', description "This is Jamie's fluffy pillow.", beenMoved false, beenSmelled false, before[; push: if(self.beenMoved == false) { score++; print_ret "There's nothing behind this pillow. You'd better get down now!"; } else { print_ret "There's nothing behind this pillow. You'd better get down now!"; } smell: if(self.beenSmelled == false) { score++; print_ret "Ummmm. Perfumy!"; } else { print_ret "There's nothing behind this pillow. You'd better get down now!"; } ], ; ! The entertainment center in Jamie's room. The player receives a point for ! looking behind it and for looking under it. If the player has already ! looked under or behind it, no points are awarded. Furniture jamies_entertainment_center "entertainment center" jamies_room with name 'entertainment' 'center', description "A very nice entertainment center that sits ~kitty-korner~ in the bedroom.^ There is a TV, DVD player, and various knick-knacks sitting on it.", hasBeenLookedUnder false, hasBeenLookedBehind false, hasBeenSmelled false, before[; smell: if(self.hasBeenSmelled == false) { self.hasBeenSmelled = true; score++; print_ret "You smell something! Could it be one of your bones?!"; } else { if(player hasnt bone1Taken) { print_ret "You smell something! Could it be one of your bones?!"; } else { print_ret "Nope. Nothin' here!"; } } lookunder: if(self.hasBeenLookedUnder == false) { score++; self.hasBeenLookedUnder = true; print_ret "It's dark under here, but you think you see your bone!"; } else { if(player hasnt bone1Taken) { print_ret "It's dark under here, but you think you see your bone!"; } else { print_ret "It's dark under here."; } } lookbehind: if(self.hasBeenLookedBehind == false) { score++; self.hasBeenLookedBehind = true; print_ret "Nothin' back here but dust bunnies and wires!"; } else { print_ret "Nothin' back here but dust bunnies and wires!"; } ], ; Bone bone1 "Bone1" jamies_entertainment_center with name 'bone1' '1', ; Furniture jamies_desk "Jamie's desk" jamies_room with name 'desk' 'jamies', description "A nice desk and chair set. There is a computer monitor sitting on top of the desk.", ; Furniture jamies_tv "TV" jamies_room with name 'tv', description "This is a 27 inch color TV sitting on the entertainment center.", ; Furniture jamies_dvd "DVD Player" jamies_room with name 'dvd' 'player', description "This is a DVD player that Jamie got from a friend for a gift.^ It is not hooked up so it won't work.^", ; Object east_hall "East hall" with name "east hall" "e hall", description "You are in the east end of the hall. To the north is Kari's room.^ To the south is the master bedroom. To the west is the middle hall.", w_to middle_hall, n_to karis_room, has light, ; ! * Object definitions for Kari's room ************************************************************ Object karis_room "Kari's room" with name 'karis' 'room' 'kari^s', description "You are now in Kari's room. It is a very nice room.^ She has an entertainment center along one wall with a TV on it.^ Next to that is her desk with a computer on it. Of course there's a^ bed and a night stand. Her dresser is next to her bed. There is a pile^ of clothes on the floor.^ Go south to the east hall,^ up to the top of Kari's bed.", s_to east_hall, u_to top_of_karis_bed, has light, ; Object karis_closet "Kari's closet" karis_room with name 'karis' 'closet' 'kari^s', description "This is Kari's closet. She keeps her clothes and shoes in here. She has a lot of clothes!", beenExamined false, before[; examine: if(self.beenExamined == false) { score++; self.beenExamined = true; print_ret "You look into the closet. There's just a bunch of clothes and shoes in there."; } else { print_ret "You look into the closet. There's just a bunch of clothes and shoes in there."; } ;], has scenery ; Bed karis_bed "Kari's bed" karis_room with name 'karis' 'bed' 'kari^s', description "This is Kari's bed. It's soft and comfy with a pillow on it.^ Go down to the floor.", hasBeenLookedUnder false, hasBeenLookedBehind false, hasBeenSmelled false, d_to karis_room, before[; smell: if(self.hasBeenSmelled == false) { self.hasBeenSmelled = true; score++; print_ret "Nothin' up here but pillows and blankets!"; } else { print_ret "Nothin' up here but pillows and blankets!"; } lookunder: if(self.hasBeenLookedUnder == false) { score++; self.hasBeenLookedUnder = true; print_ret "Nothin' under here but some CD's, a brush, and some dust bunnies!"; } else { print_ret "Nothin' under here but some CD's, a brush, and some dust bunnies!"; } ], ; Object top_of_karis_bed "Top of Kari's bed" karis_room with name 'bedtop', description "You are on Kari's bed. There is just a pillow up here. I really don't think you should be up here!", d_to karis_room, before[; look: print_ret "You are on Kari's bed. There is just a pillow up here. I really don't think you should be up here!"; ], has light scenery ; Pillow karis_pillow "Kari's pillow" top_of_karis_bed with name 'karis' 'pillow', description "This is Kari's fluffy pillow.", beenMoved false, beenSmelled false, before[; push: if(self.beenMoved == false) { score++; print_ret "There's nothing behind this pillow. You'd better get down now!"; } else { print_ret "There's nothing behind this pillow. You'd better get down now!"; } smell: if(self.beenSmelled == false) { score++; print_ret "Ummmm. Perfumy!"; } else { print_ret "There's nothing behind this pillow. You'd better get down now!"; } ], ; ! The entertainment center in Kari's room. The player receives a point for ! looking behind it and for looking under it. If the player has already ! looked under or behind it, no points are awarded. Furniture karis_entertainment_center "Kari's entertainment center" karis_room with name 'entertainment' 'center', description "A very nice entertainment center that sits along the wall in the bedroom.^ There is a TV and various knick-knacks sitting on it.", hasBeenLookedUnder false, hasBeenLookedBehind false, hasBeenSmelled false, before[; smell: if(self.hasBeenSmelled == false) { self.hasBeenSmelled = true; score++; print_ret "Nothin' under here!"; } else { print_ret "Nope. Nothin' here!"; } lookunder: if(self.hasBeenLookedUnder == false) { score++; self.hasBeenLookedUnder = true; print_ret "It's dark under here! I don't see anything of interest to you."; } else { print_ret "It's dark under here! I don't see anything of interest to you."; } lookbehind: if(self.hasBeenLookedBehind == false) { score++; self.hasBeenLookedBehind = true; print_ret "Nothin' back here but dust bunnies and wires!"; } else { print_ret "Nothin' back here but dust bunnies and wires!"; } ], ; ! * The pile of clothes on Kari's floor. This is where the bone is hidden. ************************ Object pile_of_clothes "Pile of clothes" karis_room with name 'pile' 'of' 'clothes', description "A pile of dirty clothes that is lying on the floor.", hasBeenMoved false, hasBeenSmelled false, hasBeenLookedUnder false, before[; smell: if(self.hasBeenSmelled == false) { self.hasBeenSmelled = true; score++; print_ret "Yikes! Smells like dirty laundry! But there is a hint of something else."; } else { if(player hasnt bone3Taken) { print_ret "Yikes! Smells like dirty laundry! But there is a hint of something else."; } else { print_ret "Yikes! Smells like dirty laundry!"; } } lookunder: if(self.hasBeenLookedUnder == false) { score++; self.hasBeenLookedUnder = true; print_ret "There's that bone! I knew I put one in here!"; } else { if(player hasnt bone3Taken) { print_ret "There's that bone! I knew I put one in here!"; } else { print_ret "Nothin' here."; } } push: if(self.hasBeenMoved == false) { self.hasBeenMoved = true; score++; print_ret "There's that bone! I knew I put one in here!"; } else { if(player hasnt bone3Taken) { print_ret "There's that bone! I knew I put one in here!"; } else { print_ret "Nothin' here."; } } ], has scenery ; Bone bone3 "Bone3" karis_room with name 'bone3' '3', ; Furniture karis_desk "Kari's desk" karis_room with name 'desk' 'karis', description "A nice desk and chair set. There is a computer monitor sitting on top of the desk.", ; Furniture karis_tv "TV" karis_room with name 'tv', description "This is a 27 inch color TV sitting on the entertainment center.", ;