Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ------------------------------------------------------------------------------------------
  2. // React on a users menu choice
  3. // [Called from a click event set in buildMenu]
  4. // ------------------------------------------------------------------------------------------
  5.  
  6. function doOnMenuChoice(){
  7.  
  8.   // Read the menu choice from the menu choice li-tag html
  9.   var menuChoice = $(this).html();
  10.  
  11.   // Find the corresponding choice in the locations choice property
  12.   var choice = player.location.choices[menuChoice];
  13.  
  14.   // if the choice should only be shown once mark it as hidden from now on
  15.   if(choice["show only once"]){choice.hidden = true;}
  16.  
  17.   // Handle waiting (randomize among things that may happen)
  18.   if(menuChoice == "Wait"){
  19.     choice = waitAround(choice);
  20.   }
  21.  
  22.   // Update contents of bag
  23.   updateBag(choice);
  24.  
  25.   // Update player status (health, money, espresso cups)
  26.   // (returns true if the player died)
  27.   var status = updatePlayerStatus(choice);
  28.  
  29.   // Add importent happenings
  30.   if(choice.happening){
  31.     happenings.push(choice.happening);
  32.   }
  33.  
  34.   // Set a new player location
  35.   updatePlayerLocation(choice);
  36.  
  37.   // Show the location if we are not dead and haven't won yet
  38.   if(status != "dead" && status!="win"){
  39.     showLocation(player.location,choice.description,choice.image);
  40.   }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement