commands = { // defined in rooms n,s,e,w,look,getup,gobed,open,close,go,tie, // defined globally i,sleep,take,drop} object stake { } object pillow { } object sheet { state {tied} } room you { state {bitten,sleep0,sleep1,sleep2} } room bed { (you,n) { "You can't go that way."; } (you,e) { "You can't go that way."; } (you,w) { "You can't go that way."; } (you,s) { "You can't go that way."; } (you,go,bed) { "You're already in bed"; } (you,open,window) { "Eh?"; } (you,close,window) { "Eh?"; } (you,go,window) { "Eh?"; } (you,tie,sheet) { "Eh?"; } (you,look) { "You're sitting in large bed."; if (bed contains stake) { "There's a wooden stake here."; } if (bed contains pillow) { "There's a pillow here."; } if (bed contains sheet && sheet.tied) { "The end of a sheet lies here."; } if (bed contains sheet && sheet!.tied) { "There's a sheet here."; } } (you,getup) { move you from bed to bedroom; "You climb out of the bed and stand in the bedroom."; } } room bedroom { state {windowopen} (you,look) { "You're standing in a bedroom."; "Against one wall is a large old bed with thick wooden bedposts."; if (bedroom.windowopen) { "On the opposite side is an open window"; } else { "On the opposite side is a window"; } "The only door in the room is to the south."; if (bedroom contains stake) { "There is a stake here."; } if (bedroom contains pillow) { "There is a pillow here."; } if (bedroom contains sheet) { if (sheet.tied) { "A sheet lies here, one end tied to the bed."; } else { "There is a sheet here."; } } elseif (sheet.tied) { if (bed contains sheet) { "A sheet on the bed has one end tied to a bed post."; } elseif (you contains sheet) { "Your sheet is tied to a bed post."; } } } (you,tie,sheet) { if (you contains sheet || bedroom contains sheet) { if (sheet!.tied) { +sheet.tied; "You tie one end of the sheet to the bed post."; } else { "The sheet is already tied to the bed post."; } } } (you,n) { "You can't go that way."; } (you,e) { "You can't go that way."; } (you,w) { "You can't go that way."; } (you,s) { move you from bedroom to hall; "You step out into a hallway."; if (you contains sheet && sheet.tied) { move sheet from you to bedroom; "Your sheet isn't long enough so you leave it behind."; } } (you,go,bed) { move you from bedroom to bed; "You climb into the bed."; } (you,open,window) { if (bedroom!.windowopen) { +bedroom.windowopen; "The window opens easily. Looks like a long way down to the ground though."; } else { "The window is already open."; } } (you,close,window) { if (bedroom.windowopen) { -bedroom.windowopen; "You shut the window."; } else { "The window is already shut."; } } (you,go,window) { if (bedroom.windowopen) { if (you contains sheet && sheet.tied) { "You climb safely to the ground using the sheet as a makeshift rope."; +game.win; } else { "You step out of the window and plummet to the cobblestones far below."; +game.lose; } } else { "You bang your head on the closed window."; } } } room hall { (you,n) { "You go back into the bedroom."; move you from hall to bedroom; } (you,e) { "You can't go that way."; } (you,w) { "You can't go that way."; } (you,s) { "The door is blocked."; } (you,go,bed) { "Eh?"; } (you,getup) { "Eh?"; } (you,open,window) { "Eh?"; } (you,close,window) { "Eh?"; } (you,go,window) { "Eh?"; } (you,tie,sheet) { "Eh?"; } (you,look) { "You're standing at the north end of a short hallway. The door at the other end looks blocked."; if (hall contains stake) { "There's a wooden stake here."; } if (hall contains pillow) { "There's a pillow here."; } if (hall contains sheet) { "There's a sheet here."; } } } stuff = {pillow,stake,sheet} stuffnotsheet = {pillow,stake} places = {hall,bedroom,bed} notsleepingrooms = {hall,bedroom} (you,sleep) { if (you.sleep0) { -you.sleep0; +you.sleep1; } elseif (you.sleep1) { -you.sleep1; +you.sleep2; } else { "You wake up as a vampire."; +game.lose; } +?you.bitten; "You wake up with 2 holes in your neck"; if (you contains stake) { move stake from you to offscreen; "Hmm. Something seems to be missing..."; } notsleepingrooms $r; if ($r contains you) { move you from $r to bed; } if (sheet.tied && you contains sheet) { -sheet.tied; move sheet from you to bed; } } (you,i) { "You check through your pockets."; forall (stuff $s) { if (you contains $s) { "You have a ${s}."; } } // if (you contains stake) { // "You have a small wooden stake."; // } // if (you contains pillow) { // "You have a fluffy pillow.."; // } if (you contains sheet) { if (sheet.tied) { "You have one end of a sheet tied to the bed."; } else { "You have a bed sheet."; } } if (you.bitten) { "You have 2 holes in your neck."; } } (you,drop,stuff $s) { places $p; if (you contains $s && $p contains you) { move $s from you to $p; "You drop the ${s}."; } else { "You don't have the ${s}."; } } (you,take,stuff $s) { places $p; if ($p contains $s && $p contains you) { move $s from $p to you; "You pick up the ${s}."; } else { "There is no ${s} here."; } } // You begin in the bed, with a stake in your pocket. start { +you.sleep0; move you from offscreen to bed; move stake from offscreen to you; move sheet from offscreen to bed; move pillow from offscreen to bed; "You awake to find yourself dressed, but lying in a large old bed."; "Where am I? How did I get here?"; }