/* Jeremy Turner #200024742 - FINAL PROJECT - "Wirxli Flimflam's EZ Journey..." FALLBACK PROTOTYPE v. 1.2 (2008) Wirxli Flimflam's blog - http://wirxliflimflam.blogspot.com TO DO IN THE FUTURE...: 1) Create an inventory array list. 2) Find a design strategy to not confuse the text command "N" (north) with "N" (no)...Text parsing more than the one character does not seem to work... 3)Find back-issue of the Avastar and replace the Photo Page with the A-Stars Celebrity page. 4) Create a moving character (Aidan). */ import controlP5.*; //for the text area, I plan to import the P5 Controls //...from this library url: //... http://www.sojamo.de/libraries/controlP5/examples/ControlP5textarea/ControlP5textarea.pde //here is the where I import the text area... Textarea myTextarea; Textfield myTextfield; ControlP5 controlP5; Room currentRoom; Player player; Boolean validAnswer = true; Boolean hasiPhone = false; Boolean hasNewspaper = false; Boolean hasTray = false; int textAreaLeft = 100; int textAreaTop = 600; int textAreaWidth = 600; int textAreaHeight = 90; //---------------------------------------------------// void setup () { size (1082, 767); //the largest image I have uploaded is 1082 x 767... I will extend the size to include the text box... //size (800, 600); controlP5 = new ControlP5(this); myTextfield = controlP5.addTextfield("ENTER YOUR COMMANDS HERE AND PRESS THE ENTER KEY!", 50, 500, 200, 20); // controlP5.controller("myTextfield").setValue(1000); myTextarea = controlP5.addTextarea ( //currentroom.name// - WORK ON THIS NEXT "the name", "a textarea is of type group, not controller.\n"+ "you can set the width and height of a textarea, if there is more text than space available, scrollbars are added. "+ "use ALT + mouseDown to move the textarea.", textAreaLeft,textAreaTop,textAreaWidth,textAreaHeight ); //here are where the room objects are called... Room r1 = new Room("Title Screen","Welcome to my game, here are the available text commands: N, S, E, W, SW, SE, TOUCH, SNORT, GET, READ, DROP, USE, Y/N. NOTE: THE KEYWORD 'N' MAGICALLY TRANSFORMS FROM being 'NO' to 'NORTH' AT A CERTAIN POINT. DO NOT WORRY ABOUT IT - JUST TRUST YOUR INTUITION...OK? LEAVE YOUR CAPS LOCK KEY ON IN ORDER ENTER CORRECT COMMANDS. PRESS THE SPACE BAR AND THEN THE ENTER KEY TO VISIT SECOND LIFE FOR THE FIRST TIME!","aboutthetextadventurebackground.jpg"); //currentroom = r1;// - WORK ON THIS NEXT Room r2 = new Room("Orientation Island","Welcome to Second Life. You have arrived at Orientation Island and have become what the locals call a 'newbie' or a 'nOOb' with a normal male humanoid appearance...YAWN! Do you want to edit your appearance?","OrientationIsland.jpg"); Room r3 = new Room("Congrats on your new appearance!","Congrats! Your appearance looks very trendy and stylish! It was as if you were born to be a star! What awesome hair! In fact, you look so cool that people have already taken notice!! Do not worry about the ugly Graphical-User-Interface (in the picture area, that is!), that will removed immediately... Do you want to go to your new freshly built home on Sugar Mountain? ","Wirxli_Flimflam_appearanceready.jpg"); Room r4 = new Room("Game Over #1","WHOA! You have just made a SERIOUS mistake! Every celebrity knows that to truly become famous, you must at least LOOK cool! What were you thinking? I mean, what kind of mediocre dullard would turn down the ridiculously easy offer to become almost instantaneously famous by simply saying 'yes'? Ooops! I guess it was YOU who turned down the offer...you, and millions of other dupes who accidentally sabotaged their formerly unbridled access to fame and fortune. Well, now you have resigned to a rather boring and pointless existence as a transient nobody...GOOD LUCK AND GAME OVER! PRESS SPACE BAR AND THE ENTER KEY TO PLAY AGAIN...","nOOb_boringending.jpg"); Room r5 = new Room("PR Office","GOOD CHOICE! Within minutes of styling your hair, you have already earned a few friends! Your newest friend is a curator named Sugar Seville. She has built you this new home on Odyssey Island. Consider it as a shrine to your snazzy personality! Other friends that are hanging out with you for a bit of chit-chat are: Olga Wunderlich (Curator from Berlin), Bibbe Oh (from Second Front) as well as Miulew Takahe and Free Noyes from the Avatar Orchestra Metaverse...But, they all realize that you do not have time to speak at length with them for now...time is money when it comes to becoming famous! Where do you want to go now? Oh...wait! Before you go...You seem to have an iPhone lying around on the bench of your office and.....YES!!! You also have a nice tray of **Snuffle!** COCAINE waiting for you! However, not to appear to rude to your guests, you should only pick one or item of the other...ok? So, what do you want to do? Pick up the iPhone or SNORT COCAINE?", "PR_Office.jpg"); Room r6 = new Room("Purple Text","Look, stop playing around and seize the opportunity when you get it, ok? Just because you have had your first taste of glamour after only one successful decision does not make you a star overnight (yet). So, NOW do you want to go to your freshly designed pad on Sugar Mountain?", "purpletext.jpg"); //the rooms below might include persistent items... Room r7 = new Room ("Dance Party", "Wow! All it takes is a little bit of coke and already, you are the LIFE OF THE PARTY! This is definitely the place to see and be seen...but...NOW WHAT? Should you go somewhere? VISIBLE EXITS: SW, SE", "Wirxlibadd.jpg"); Room r8 = new Room ("Kenzo Answers the iphone", "RING! As soon as you pick up the phone, the phone rings and it just happens to be the well known celebrity organizer, In Kenzo who is on the phone...She was hoping to get ahold of Sugar Seville who happens to own the phone but she is more than happy to speak with you for the first time...After a quick compliment about your crazy hair (did we mention that this iPhone has videochat?), Kenzo invites you to the Avastar Party...do you want to go?", "InKenzoImage.jpg"); Room r9 = new Room("Kenzo Answer2","In Kenzo says, 'Ok Wirxli, you are a SLebrity, right? You know this is for SLebrities only...Just show evidence of some media publicity like...ummm...you know, a recent interview you had or something...ok? And ummm...just present this interview to me at the entrance to the party...thanks!'... Since you do not have any evidence of PR in your inventory, I would suggest you get interviewed quickly...Fortunately, in the iPhone's address book, there is a place called the 'SL Enquirer HQ' that you could teleport to...do you want to do this?", "InKenzoFull.jpg"); Room r10 = new Room("Kenzo Answer 3","'Really? You do NOT want to go to the event of the year hosted by the biggest celebrity tabloid in SL, The Avastar? OK...suit yourself! It is no skin off my back, there are many people I can just pass this invite on to...In fact, I think...ummmm..I have a call on the other line....nice to meet you, Wirxli! Bye!' *CLICK!* AVAILABLE COMMANDS: SUICIDE (Commit Suicide), COPE (get a life)", "inkenzofirebackground.jpg"); Room r11 = new Room("Lousy Meandering Corridor 1","Ummm...Have you been in this corridor already? It looks familiar...kinda..but...hmmmm...well, it looks familiar...I guess all generic graphical-text adventures look the same, don't they? VISIBLE EXITS: Like, I am going to tell you what they are when are you supposed to be lost in a maze...That would make the whole gameplay too easy, wouldn't it? The whole point is to be disoriented at the moment.", "lousycorridor1.jpg"); Room r12 = new Room("Kenzo Answer 4B","'Hmmm...Wirxli, have you ever considered killing yourself? That might be the fastest way to become famous if you cannot make the time to attend any of the most important A-list Celeb events and hi-profile interviews'...SHE IS RIGHT! PRESS SPACE BAR TO COMMIT SUICIDE...", "KenzoNMC.bmp"); Room r13 = new Room("Suicide Screen","IN A WAY, YOU STILL ENDED UP WINNING THE GAME! ALL IT TOOK WAS ONE GUNSHOT TO THE HEAD, AND NOW YOU ARE MORE FAMOUS THAN EVER! CONGRATS AND GAME OVER!!! PRESS SPACE BAR AND THE ENTER KEY TO PLAY AGAIN...", "wirxli-dies.jpg"); Room r14 = new Room("Kenzo Answer 4A","You quickly realize the error of your ways and press the re-dial button... 'Hello NMC, In Kenzo here? Oh...Hi again Wirxli...what's up? Is it about the party? Have you changed your mind? The offer still stands...do you want to go to the party?'", "KenzoNMC.bmp"); Room r15 = new Room("Lousy Meandering Corridor 2","Geez, you were in a corridor just like this not too long ago...in fact, is this the same corridor? No wait, there is something slightly different about it.... Oh! It looks upside down!!! Only in Second Life can you get spatial discontinuities like this! Trippy! Never mind that you are temporarily upside down - a more important question to ask is... Are you lost? Is the narrator lost? Are you on mind altering drugs? More to the point, is the narrator on mind altering drugs? You get the picture! LOL! VISIBLE EXITS: Like, I am going to tell you what they are when are you supposed to be lost in a maze...That would make the whole gameplay too easy, wouldn't it? The whole point is to be disoriented at the moment.", "lousycorridor2.jpg"); Room r16 = new Room("Lousy Meandering Corridor 3","WHOA!!! GNARLY!!! What a totally TUBULAR looking corridor! Like, this is so totally PHOTOSHOP style abstraction! Is this retro-chic or what???? It hardly even looks like a corridor anymore! You are so wasted, you are actually not only hallucinating but are harbouring some sort of paranoid delusion that there might actually be someone of importance just around the corner....hmmm..must just be a delusion...must be all the vertigo and delerium from wandering aimlessly in some kind of labyrinth left by a minotaur who Overdosed a millennia ago! VISIBLE EXITS: Like, I am going to tell you what they are when are you supposed to be lost in a maze...That would make the whole gameplay too easy, wouldn't it? The whole point is to be disoriented at the moment.", "lousycorridor3.jpg"); Room r17 = new Room("Party Corridor","You are in a generic party corridor...where do you wan to go? VISIBLE EXITS: Like, I am going to tell you what they are when are you supposed to be lost in a maze...That would make the whole gameplay too easy, wouldn't it? The whole point is to be disoriented at the moment.", "partycorridor.jpg"); Room r18 = new Room("Party Room Angle #3","Does the party ever end? You be the judge....Find an exist fast...like, now or like, totally split the scene in some random direction and leave forever! AVAILABLE EXITS: S, NE...Yes, these are not really random choices...I know...", "Wirxlibadd_2006_SW.jpg"); Room r19 = new Room("ClockLobby Corridor","You are in some totally dull corridor...yawn! Where do you want to go next? VISIBLE EXITS: Like, I am going to tell you what they are when are you supposed to be lost in a maze...That would make the whole gameplay too easy, wouldn't it? The whole point is to be disoriented at the moment.", "partycorridor.jpg"); Room r20 = new Room("ClockLobby","You stumble out of the party and straight into some dull desk chair in the middle of pure virtual purgatory...now where? VISIBLE EXITS: SW, SE, NE", "lobbywait.jpg"); Room r21 = new Room("Party Room Angle #2","WHOA! PARTY TIME! VISIBLE EXITS: SW, SE", "Wirxlibadd.jpg"); Room r22 = new Room("Party Room Angle #3","It must be all the coke and booze...you have only managed to reach a slightly different angle of the dancefloor...now where do you want to go? VISIBLE EXITS: W, NW, SW, SE", "Wirxlibadd_SE.jpg"); Room r23 = new Room("Snorting Coke in Miami","You do not remember what happened but suddenly you are at a party in Miami with Blued Food...You have snorted almost all of it but there is just a little bit left...Available Exit = NW...", "miami10.jpg"); Room r24 = new Room("Cocaine Overdose = GAME OVER","Wow! That coke was awesome! Too bad you Overdosed...had you waited a few more minutes or had chosen to split the scene and head Northwest, you would have had many more fulfilling months of additional coke snorting ahead of you...Geez, you did not even take the time to consider re-hab...you ARE a natural celebrity!!! GAME OVER. PRESS SPACE BAR AND THE ENTER KEY TO PLAY AGAIN...", "cokeOD.jpg"); Room r25 = new Room("Avastar Entrance","You see a ramp that is elevated towards some dome far away in the Northern hemisphere. In the corner of your eye, you also notice what looks like some sort of vending machine that is right behind you. VISIBLE EXITS: N, S, NE", "AvaStarRamp.jpg"); Room r26 = new Room("Vending Machine","You see a tabloid newspaper vending machine...please read the instructions before proceeding with the secret command...VISIBLE EXITS: N (North)", "AvastarVendingMachine.jpg"); Room r27 = new Room("Avastar Office Area","You are now in the lush, yet spare and well designed lobby of the Avastar Newspaper Headquarters. Your party instinct tells you that there is a bar with drinks nearby...VISIBLE EXITS: W, S", "avaofficearea.jpg"); Room r28 = new Room("The AvaBar!","Woohooo! Free drinks at the Avabar...it is a good thing that this text-adventure game was made with minimal programming, otherwise you would actually have to make some effort to type in something like 'GET DRINK'...of course, the game creator was well aware that you would be too loaded and wasted to type anything remotely intelligent so the drink dispenses automatically...how about that for convenience! Ahhhhhhh....VISIBLE EXIT: E", "wirxlibar.jpg"); Room r29 = new Room("Tabloid Cover","Hmmm..the vending machine is a bit stingy...all you get is the front cover of the taboid...go figure!", "newspapersample.jpg"); Room r30 = new Room("Dead End","Ooops! You have just reached a dead end but the game is not over yet, where do you want to go now? VISIBLE EXIT: E", "deadend.bmp"); Room r31 = new Room("Page 11 Celebrity Events Page", "After you read the current events and find out that you have not yet been spotted as a celeb - not even in the measly 'pics of the week' section, press the space bar to continue meandering aimlessly...","Avastar_sl_re-sized.jpg"); Room r32 = new Room("Aidan interviews Wirxli", "Aidan is here to interview you...after a long interview that went something like... 'AIDEN: So you are some sort of weird looking alien, right?', 'WIRXLI: Ummmm....UHHHH....SNORT! Uhhhh...sure...yeah!', 'AIDAN: Wow! I love your personality, Wirxli! You are a natural celebrity! Tass hair, Dude? Or...is it Dudette? Anyways, I know about this party that my newspaper is covering to compete with the other tabloid-style newspaper that is hosting this high profile event...Do you know In Kenzo? Maybe she told you about it? Wanna go? There might be lots of blow there!'... with that token gesture of comaraderie and reverie, you are allowed to proceed to the party...do you want to go?", "AidanInterview.jpg"); Room r33 = new Room("In Kenzo welcomes you at the gate to the VIP Party...", "In Kenzo is waiting for you (and many other freshly discovered celebs) at the AvaStar Entrance...Interview accepted...Press space bar to enter the party...", "KenzoEntrance.jpg"); Room r34 = new Room("YOU WIN AND ARE NOW FAMOUS!", "Wow! Finally, your moment has arrived! You have been seen by the paparazzi at the hippest party of the week! Enjoy your havily publicized fame while it lasts! PRESS THE SPACE BAR AND ENTER KEY TO START AGAIN..." , "Endpic.jpg"); //Item boolean variable setting - affixed to the Player object in the starting room...follows the Player to the next assigned text-parsed room. r5.hasIPhone=true; r5.availableRoomByIPhone=r8; r5.hasTray=true; r5.availableRoomByTray=r7; r31.hasNewspaper=true; r31.availableRoomByNewspaper=r26; //Player is now also an object in order to create a persistent link between moving items and room objects - items affixed to and detached from the player... player=new Player(); //These room commands provide the navigation from room-to-room/event-to-event/textprompt-to-textprompt... r1.setRoomCommand(r2," "); r2.setRoomCommand(r3,"Y"); r2.setRoomCommand(r4,"N"); r3.setRoomCommand(r5,"Y"); r3.setRoomCommand(r6,"N"); //the rooms below include 2 persistent items... r4.setRoomCommand(r1, " "); r5.setRoomCommand(r7,"SNORT COCAINE"); r5.setRoomCommand(r8, "USE iPHONE"); r6.setRoomCommand(r5,"Y"); r7.setRoomCommand(r20,"SW"); r7.setRoomCommand(r21 , "SE"); r8.setRoomCommand(r9, "Y"); r8.setRoomCommand(r10, "N"); r9.setRoomCommand(r11, "Y"); r9.setRoomCommand(r12, "N"); r10.setRoomCommand(r13, "SUICIDE"); r10.setRoomCommand(r14, "COPE"); r11.setRoomCommand(r15, "W"); r11.setRoomCommand(r16, "NW"); r12.setRoomCommand(r13, " "); r13.setRoomCommand(r1, " "); r14.setRoomCommand(r9, "Y"); r14.setRoomCommand(r12,"N"); r15.setRoomCommand(r14, "E"); r15.setRoomCommand(r16, "NE"); r15.setRoomCommand(r19, "NW"); r16.setRoomCommand(r15, "SW"); r16.setRoomCommand(r11, "SE"); r16.setRoomCommand(r17, "N"); r16.setRoomCommand(r32, "NW"); //this is the room with Aidan the Interviewer inside... r17.setRoomCommand(r18, "N"); r17.setRoomCommand(r16, "S"); r18.setRoomCommand(r17, "S"); r18.setRoomCommand(r21, "NE"); r19.setRoomCommand(r20, "NW"); r19.setRoomCommand(r15, "SE"); r20.setRoomCommand(r25, "SW"); r20.setRoomCommand(r19, "SE"); r20.setRoomCommand(r7, "NE"); r21.setRoomCommand(r20, "SW"); r21.setRoomCommand(r22, "SE"); r22.setRoomCommand(r21, "NW"); r22.setRoomCommand(r18, "SW"); r22.setRoomCommand(r23, "SE"); r22.setRoomCommand(r30, "W"); r23.setRoomCommand(r22, "NW"); r23.setRoomCommand(r24, "SNORT COCAINE"); r24.setRoomCommand(r1, " "); r25.setRoomCommand(r27, "N"); r25.setRoomCommand(r20, "NE"); r25.setRoomCommand(r26, "S"); r26.setRoomCommand(r29, "TOUCH"); r26.setRoomCommand(r25, "N"); r27.setRoomCommand(r28, "W"); r27.setRoomCommand(r25, "S"); r28.setRoomCommand(r27, "E"); r29.setRoomCommand(r31, "READ PAGE 11"); r30.setRoomCommand(r22, "E"); r31.setRoomCommand(r25, " "); r32.setRoomCommand(r16, "N"); r32.setRoomCommand(r33, "Y"); r33.setRoomCommand(r34, " "); r34.setRoomCommand(r1, " "); image(r1.roomImage,0,0); //here in the set up method at the start, we set current room to r1 currentRoom=r1; }//--------------------------------------------------------------- //--------------------------------------------------------------- void controlEvent (ControlEvent theEvent) { println("control event....." + myTextfield.getText() ); // These lines of syntax were suggested by Jeffrey Ventrella should I re-write the code one day using item persistence functionality via a different emergent coding paradigm. // if (myTextfield.getText().equals("GET IPHONE")) // { // println("OK - I picked up the iPhone"); // hasiPhone = true; // } // // if (myTextfield.getText().equals("DROP IPHONE")) // { // println("OK - I have put down the iPhone"); // hasiPhone = false; // } // // if (myTextfield.getText().equals("USE IPHONE")) // { // if ( hasiPhone ) // { // println("OK - let's go to room 8"); // // /* // if (r8 !=null) // { // currentRoom.setRoomCommand(r8, myTextfield.getText() ); // } // else // { // println("oops - cannot find room 8"); // } // */ // } // else // { // println("dood you don't have an iPhone"); // } // } if ( theEvent.controller().name().equals(myTextfield.name())) { currentRoom=currentRoom.nextRoom(myTextfield.getText(),player); // if(tempRoom!=null){ // currentRoom=tempRoom; // validAnswer=true; // }else{ // validAnswer=false; // } } }//-------------------------------------------------- void draw () { //println( "drawing" ); fill(0); rect( textAreaLeft, textAreaTop, textAreaWidth, textAreaHeight ); image( currentRoom.roomImage,0,0); myTextarea.setText( currentRoom.displayText ); } //more function calls related to the P5 controlled text area... void changeWidth(int theValue) { textAreaWidth = theValue; fill(0); rect( textAreaLeft, textAreaTop, textAreaWidth, textAreaHeight ); myTextarea.setWidth(theValue); // ((Textarea)controlP5.group("label1")).setWidth(theValue); } void changeHeight(int theValue) { textAreaHeight = theValue; fill(0); rect( textAreaLeft, textAreaTop, textAreaWidth, textAreaHeight ); myTextarea.setHeight(theValue); } Room room1; Room roomCoke; //----------------------------------------------------------------------------- class Room { String name;//name of the room String description;// description which should be shown to the user when he enters the room PImage roomImage;//Image of room (if you want to support different angles of view, please tell me, we should change the code in that case) //Pooya: added this String containing the message we want to show to user String displayText; ArrayList rooms=new ArrayList();//list of the rooms available to go from this room ArrayList commands=new ArrayList();//list of the commands available for the room ArrayList items=new ArrayList();//list of the itms available for this room (we should talk more about this) //ArrayList inventory=new ArrayList(); ... I would like to add an inventory ArrayList one day to increase the object persistence functionality in terms of user design experience. /* Here are some notes based on a discussion with Jeffrey Ventrella about the alternate ways of structuring this code from scratch... CURRENT PROBLEM - Boolean variable "hasiphone" assigned to every room... Since there should be only one iPhone in the game and not room-multiples (to anticipate multiplayer activity), it would be better to JV: ... make the variables "whereisphone" "whereiscocaine" "whereisnewspaper" that correspond to 3-state objects to indicate which room the single iPhone is in (could be in the inventory pocket or in dropped off in a chosen room) Turn it into a string... "In my pocket". Also, "whereisitem" could be an inventory array list. Best to write code as if it is only one player until it works and then take the player code and create a player class. JV: If I started the code from scratch....Inventory items based on a 3-state object (Get/Drop, which room the item is in, whether or not the phone is being used - "magic button". */ boolean hasIPhone=false; Room availableRoomByIPhone; boolean hasNewspaper=false; Room availableRoomByNewspaper; boolean hasTray=false; Room availableRoomByTray; //Constructor Room(String name,String description, String imageFileName) { this.name=name; this.description=description; roomImage=loadImage(imageFileName); displayText=description; }//-- end of constructor --------- void setRoomCommand(Room r, String command) { rooms.add(r); commands.add(command); } //gets a command like "Yes" and returns the appropriate room Room nextRoom(String userCommand, Player player) { Room nextRoomWeShouldGo=this; //The default value is the room we are in //Only the CAPS LOCK is recognized for most text parsing... String command=userCommand.toUpperCase(); if (command.equals("GET IPHONE")){ if(hasIPhone){ hasIPhone=false; player.hasIPhone=true; player.availableRoomByIPhone=availableRoomByIPhone; // availableRoomByIPhone=null; displayText="OK - you picked up the iPhone. I hope you remembered the previous exits...Otherwise, you might have to start all over again...HAHAHAHAHA!"; }else{// there is no phone in room displayText="Dude/Dudette, where is your phone? I think you lost it somewhere...Ooops!"; } }else if(command.equals("DROP IPHONE")){ if(player.hasIPhone){ player.hasIPhone=false; hasIPhone=true; availableRoomByIPhone=player.availableRoomByIPhone; // player.availableRoomByIPhone=null; displayText="OK - you have put down the iPhone."; }else{//There is no phone in the player's hand! displayText="What phone? You will need to find a phone first before you drop it somewhere...Maybe you need to purchase some caller-ID? Heheheheheh!"; } }else if(command.equals("GET TRAY")){ if(hasTray){ hasTray=false; player.hasTray=true; player.availableRoomByTray=availableRoomByTray; // availableRoomByTray=null; displayText="Wooo hoo! A whole tray of cocaine and just for you! If this is not a celebrity initiation, I do not know what is ;-) There are at least a few lines of snow on this tray! Don't snort it all too fast!!!"; }else{ displayText="I know you are anxious for your next fix of coke but at some point, you gotta admit there is neither some lines of coke nor a tray to hold the stuff in this room."; } }else if(command.equals("DROP TRAY")){ if(player.hasTray){ player.hasTray=false; hasTray=true; availableRoomByTray=player.availableRoomByTray; // player.availableRoomByTray=null; displayText="Ooops! You dropped your tray of cocaine on the floor! Was that intentional? How reckless of you to do that! Fortunately, the unique physics of this virtual world has ensured that absolutely no lines of cocaine have drifted off the tray...phew!"; }else{ displayText="Drop what? Some tray full of cocaine? Are you crazy??? You must be out of it because you do not even have any cocaine tray to drop....sigh!"; } }else if(command.equals("GET NEWSPAPER")){ if(hasNewspaper){ hasNewspaper=false; player.hasNewspaper=true; player.availableRoomByNewspaper=availableRoomByNewspaper; // availableRoomByNewspaper=null; displayText="You have picked up the same newspaper you first acquired from that corporate looking vending machine...Do you want to READ the main page again?"; }else{ displayText="You are not so famous yet that you can find a newspaper about yourself just about anywhere you happen to be! There is no newspaper here and even if there was a newspaper, chances are, you are not featured in it yet."; } }else if(command.equals("DROP NEWSPAPER")){ if(player.hasNewspaper){ player.hasNewspaper=false; hasNewspaper=true; availableRoomByNewspaper=player.availableRoomByNewspaper; // player.availableRoomByNewspaper=null; displayText="You have dropped the newspaper onto the floor which is probably a good thing since you were not featured on the main page...as far as you should be concerned, it was a useless rag anyway!"; }else{ displayText="If you had a newspaper to begin with, it is no longer in your inventory...My guess is that you probably filled it full of extra lines of cocaine...heheheheheheh!"; } }else if(command.equals("USE IPHONE")){ if(player.hasIPhone){ nextRoomWeShouldGo=player.availableRoomByIPhone; // availableRoomByIPhone=null; displayText="Ring! Ring! Wow, someone is calling you before you even had the chance to use it...you must be famous! Oh cool! It is a call from In Kenzo...rumour has it that she could be the one to make you famous..."; }else{ displayText="Not to be rude but I think you actually need an iPhone to USE it, Dude!"; } }else if(command.equals("READ NEWSPAPER")){ if(player.hasNewspaper){ nextRoomWeShouldGo=player.availableRoomByNewspaper; // availableRoomByNewspaper=null; displayText="Wow! You are not featured in this newspaper but it gives you some idea of the kind of celebrities they like to cover in this particular tabloid."; }else{ displayText="If you only you actually HAD a newspaper to READ...SIGH!"; } }else if(command.equals("SNORT COCAINE")){ if(player.hasTray){ nextRoomWeShouldGo=player.availableRoomByTray; // availableRoomByTray=null; displayText="SNORT! You Snort a single line...It must have cost you L$100 just or that single snort but it does not matter to you because your bank statement is not part of the gameplay anyway..WHOA! THAT IS SOME STRONG STUFF! You should be an actor/actress as you certainly know your lines already...heheheheh!"; }else{ displayText="SNORT! Oh wait! The only thing that went up your nose that time was thin air!!! Did you snort strictly out of habit? You must be desperate if you are hallucinating an extra line of cocaine..."; } }else{ int index=commands.indexOf(command); if(index==-1){ displayText="Ummmm...what was that command supposed to mean? Maybe it is the drug haze I am coming out of but I do not seem to understand your command...try typing in another command!";//When user enters an invalid command return this; } nextRoomWeShouldGo=(Room) (rooms.get(index));//we can search the commands list, if the command parameter is the second unit of commands list, //our method should return the corresponding room (second unit of rooms list in this example) //if the command is not in the list, this method should return null (no room found) nextRoomWeShouldGo.displayText=nextRoomWeShouldGo.description; } return nextRoomWeShouldGo; } } class Player{ boolean hasIPhone=false; Room availableRoomByIPhone; boolean hasTray=false; Room availableRoomByTray; boolean hasNewspaper=false; Room availableRoomByNewspaper; } /*This was created for the IAT 800 Foundations in Computer Art and Design class at Simon Fraser University (SIAT - SFU SURREY), Nov-Dec 2008. Special thanks to Chris Shaw for the overall instruction. Special thanks to Pooya Amini for helping me understand the specific syntax structures for a finite state machine. Special thanks to Jeffrey Ventrella for providing me with a way to completely re-write the code to transform the "game" from a finite state machine to a simulation based paradigm. Special thanks to Johnny Rogers for helping me understand the P5 Control Widgets. */