Advertisement
anudrul

Text game v.2

Jul 12th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.58 KB | None | 0 0
  1. import acm.util.RandomGenerator;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class textw {
  6.  
  7.        
  8.        
  9.        
  10.         public static boolean sword=false;  
  11.        
  12.         public static boolean armor=false;
  13.        
  14.         public static boolean coin=false;
  15.        
  16.         public static boolean Document=false;
  17.        
  18.         public static boolean BabyHippo=false;
  19.        
  20.        
  21.        
  22.        
  23.        
  24.        
  25.        
  26.         public static void main(String[] args){
  27.             System.out.println("Welcome to Attack of the hippos v1.1 (there is currently only one main story line to follow)");  
  28.             System.out.println("You can not use caps in this game");
  29.             System.out.println("");
  30.             levelone();
  31.        
  32.         }
  33.  
  34.         private static RandomGenerator rgen = RandomGenerator.getInstance();
  35.        
  36.  
  37.          private static String getinput() {
  38.                 Scanner keyboard= new Scanner(System.in);
  39.                 String input= keyboard.nextLine();                      
  40.                 return input;                                  
  41.                
  42.        
  43.                
  44.         }
  45.        
  46.        
  47.         private static void levelzero(){
  48.             System.out.println("Thank you for playing Revenge of the Hippos. ");
  49.             System.out.println("This game has been coded by Alexander Chow with the help of TA Richard");
  50.             System.out.println("To retry the game please type in [Restart]");
  51.             String playerinput=getinput();
  52.            
  53.             if (playerinput.equalsIgnoreCase("Restart")){
  54.                 sword=false;
  55.                 Document=false;
  56.                        
  57.                
  58.                 levelone();
  59.             }
  60.            
  61.             else{
  62.                 System.out.println("");
  63.                 System.out.println("");
  64.                 System.out.println("Thanks for coming, we hope to see you again!");
  65.             }
  66.             }
  67.        
  68.         private static void levelone() {
  69.                 System.out.println("You are in the ruins of your village");
  70.             System.out.println("A village elder explains that Rampaging hipos have destroyed your village, and that he needs you to come talk when ready.");
  71.                 String playerinput=getinput(); // setting our variable, playerinput, of type String, to what the player types in
  72.             System.out.println(playerinput);
  73.             if(playerinput.contains("talk")){
  74.                System.out.println("Village elder: I need you to go Boolean city and ask for aid.");                  
  75.                 leveltwo();
  76.             }
  77.             else if (playerinput.contains("ready")){
  78.                 System.out.println("Village elder: I need you to go to Boolean city and ask for aid.");
  79.                  leveltwo();
  80.         }
  81.            
  82.             else if(playerinput.contains("leveltwentyone")){
  83.             leveltwentyone();
  84.             }
  85.                
  86.            
  87.            
  88.                
  89.                 else{
  90.                         System.out.println("Invalid move, you bumbling buffoon.");
  91.                         levelone();
  92.                 }
  93.         }
  94.  
  95.         private static void leveltwo() {
  96.                 System.out.println("You exit the village entering a grassy field");
  97.                 System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
  98.                 String playerinput=getinput();
  99.                
  100.                 if
  101.                    (playerinput.equalsIgnoreCase("North")){
  102.                         levelthree();
  103.                 }
  104.        
  105.                 else if
  106.                         (playerinput.equalsIgnoreCase("West")){
  107.                     levelfour();
  108.                 }
  109.            
  110.                 else if
  111.                      (playerinput.equalsIgnoreCase("South")){
  112.                          levelsix();
  113.                 }
  114.                
  115.                 else{
  116.                         System.out.println("Invalid move, you bumbling buffoon.");
  117.                       leveleight();
  118.                 }
  119.         }
  120.  
  121.         private static void levelthree() {
  122.                 System.out.println("Heading north you arive at the city of boolean.");
  123.                 String playerinput=getinput();
  124.                 if(playerinput.contains("enter")){
  125.             System.out.println("Guard:Only those with the proper documents may pass.");
  126.             if (Document == true){
  127.                 System.out.println("Guard: Oh you have them, you may pass");
  128.                   leveltwo();
  129.             }
  130.            
  131.             else {
  132.                 System.out.println("Guard: You have no papers, SCRAM!");
  133.                    leveleight();
  134.             }
  135.                        
  136.                 }
  137.                
  138.                
  139.                
  140.                 else if
  141.                      (playerinput.contains("south")){
  142.                            leveleight();
  143.                 }
  144.                
  145.                 else{
  146.                         System.out.println("Invalid move, you bumbling buffoon");
  147.                           levelthree();
  148.                 }
  149.                        
  150.        
  151.         }
  152.  
  153.         private static void levelfour() {
  154.                 System.out.println("You arive in a open plain");
  155.                 System.out.println("Either Explore or leave");
  156.             String playerinput=getinput();
  157.            
  158.             if (playerinput.contains("explore")){
  159.                 System.out.println(" you find a man fighting a ugly looking hippo.");
  160.                 System.out.println("Either aid him or flee");
  161.             }
  162.            
  163.             else if(playerinput.contains("leave")){
  164.                 System.out.println("You leave wondering what you could have found");
  165.                 leveleight();
  166.             }
  167.                  
  168.            
  169.                 else if(playerinput.contains("aid")){
  170.                 System.out.println("You reach the man just as he collapses, you slay the hippo with his sword");
  171.                 System.out.println("You gained: The Sword!");
  172.                 sword=true;
  173.                 levelfive();  
  174.             }
  175.            
  176.             else if
  177.                   (playerinput.contains("flee")){
  178.                   System.out.println("You Escaped!");
  179.                   leveleight();
  180.             }
  181.        
  182.             else{
  183.                 System.out.println("Invalid move, you bumbling buffoon.");
  184.                 levelfour();
  185.             }  
  186.         }
  187.        
  188.         private static void levelfive() {
  189.                 System.out.println("Fallen Man: I tracked the beast after it attacked my village, south of the crossroads.");
  190.                 System.out.println("Fallen Man: Please let them know where I am");
  191.                 System.out.println("");
  192.                 System.out.println("You recieved Quest:Help me");
  193.                 leveleight();
  194.                
  195.                
  196.         }
  197.  
  198.         private static void levelsix() {
  199.                 System.out.println("Heading south you find a rocky canyon entrance that has been blocked by a boulder.");
  200.                 System.out.println("search around for a way around or leave?");
  201.             String playerinput=getinput();
  202.            
  203.             if (playerinput.contains("leave")){
  204.                 leveleight();
  205.             }
  206.        
  207.             else {
  208.                 System.out.println("You find nothing while searching.");
  209.                 levelseven();
  210.          
  211.            
  212.            
  213.            
  214.        
  215.         }
  216. }
  217.  
  218.         private static void levelseven() {
  219.         System.out.println("Keep searching or leave?");
  220.         String playerinput=getinput();
  221.        
  222.         if(playerinput.contains("searching")){
  223.                 System.out.println("You find a small cave entrance and enter it");
  224.                 levelnine();
  225.                 }
  226.        
  227.         else{
  228.                 System.out.println("You give up heading back.");
  229.                 levelnine();
  230.         }
  231.        
  232.        
  233.         }
  234.  
  235.         private static void leveleight() {
  236.                 System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
  237.                 String playerinput=getinput();
  238.                
  239.                 if
  240.                    (playerinput.equalsIgnoreCase("North")){
  241.                         levelthree();
  242.                 }
  243.        
  244.                 else if
  245.                         (playerinput.equalsIgnoreCase("West")){
  246.                     levelfour();
  247.                 }
  248.            
  249.                 else if
  250.                      (playerinput.equalsIgnoreCase("South")){
  251.                          levelsix();
  252.                 }
  253.                
  254.                 else{
  255.                         System.out.println("Invalid move, you bumbling buffoon.");
  256.                       leveleight();
  257.                 }
  258.         }
  259.  
  260.         private static void levelnine() {
  261.                 System.out.println("Entering into the cave you quickly become entangled in the spider webs hanging every where");
  262.            
  263.            
  264.             if (sword==true) {
  265.                 System.out.println("Your sword easily slices through the webs allowing you to free yourself");
  266.                 System.out.println("However the blade snaps as you finish making you sad :(");
  267.                 sword=false;
  268.                 levelten();
  269.                
  270.             }
  271.            
  272.             else {
  273.                 System.out.println("Not being able to free yourself you black out from a lack of oxygen.");
  274.                 System.out.println("Error 404:page not found.");
  275.                 levelzero();
  276.                
  277.             }
  278.         }
  279.  
  280.         private static void levelten() {
  281.                 System.out.println("Having escaped you hurry down the tunnel and burst out onto another adbandoned cross road.");
  282.                 System.out.println("You have three options: Go up,right or left.");
  283.                 String playerinput=getinput();
  284.        
  285.           if (playerinput.contains("up")){
  286.                   System.out.println("Heading up the hill you find and climb into a old,ugly tower.");
  287.                   leveleleven();
  288.                    }
  289.           else if (playerinput.contains("right")){
  290.               System.out.println("Turning right you find a dead end, you turn around dejected.");
  291.               leveltwelve();
  292.           }
  293.          
  294.           else if (playerinput.contains("left")){
  295.                   System.out.println("In your hurry to rush around the cliff, you trip and knock yourself out. ");
  296.              
  297.           }
  298.                
  299.         }
  300.  
  301.         private static void leveleleven() {
  302.             System.out.println("There is nothing in the tower, go away");
  303.             levelthirteen();
  304.                
  305.         }
  306.  
  307.         private static void leveltwelve() {
  308.                 System.out.println("You come back out of the dead end feeling sad.");
  309.                 System.out.println("You have three options: Go up,right or left.");
  310.                 String playerinput=getinput();
  311.        
  312.           if (playerinput.contains("up")){
  313.                   System.out.println("Heading up the hill you find and climb into a old,ugly tower.");
  314.                   leveleleven();
  315.                    }
  316.           else if (playerinput.contains("right")){
  317.               System.out.println("Turning right you find a dead end, you turn around dejected.");
  318.               leveltwelve();
  319.              }
  320.          
  321.           else if (playerinput.contains("left")){
  322.                   System.out.println("In your hurry to rush around the cliff, you trip and knock yourself out. ");
  323.                   levelfourteen();
  324.           }
  325.                
  326.           else {
  327.                   System.out.println("Invalid move, you bumbling buffon");
  328.                   leveltwelve();
  329.           }
  330.        
  331.         }
  332.  
  333.         private static void levelthirteen() {
  334.             System.out.println("You come back out of the tower feeling sad.");
  335.             System.out.println("You have three options: Go up,right or left.");
  336.             String playerinput=getinput();
  337.    
  338.       if (playerinput.contains("up")){
  339.               System.out.println("Heading up the hill you find and climb into a old,ugly tower.");
  340.               leveleleven();
  341.                }
  342.       else if (playerinput.contains("right")){
  343.           System.out.println("Turning right you find a dead end, you turn around dejected.");
  344.           leveltwelve();
  345.          }
  346.      
  347.       else if (playerinput.contains("left")){
  348.               System.out.println("In your hurry to rush around the cliff, you trip and knock yourself out. ");
  349.               levelfourteen();
  350.       }
  351.            
  352.       else {
  353.               System.out.println("Invalid move, you bumbling buffon");
  354.               levelthirteen();
  355.       }
  356.    
  357.     }
  358.  
  359.         private static void levelfourteen(){
  360.             System.out.println("You wake up in the same spot as before with a pounding head.");
  361.             System.out.println("Either go back to sleep or try and get up");
  362.             String playerinput=getinput();    
  363.            
  364.             if (playerinput.contains("up")){
  365.                 System.out.println("You wake up from your dream and glance around, your in a small hut. ");
  366.                 System.out.println("Either leave hut or wait for something to happen");
  367.             }
  368.            
  369.             else if (playerinput.contains("leave")){
  370.                 System.out.println("As you leave the hut a man approachs you warrily. ");
  371.                 levelfifteen();
  372.             }
  373.            
  374.             else if (playerinput.contains("wait")){
  375.                 System.out.println("While waiting you fall back asleep");
  376.                 levelfourteen();
  377.             }
  378.            
  379.             else {
  380.                 System.out.println("Invalid move, you bumbling buffon");
  381.                 levelfourteen();
  382.         }
  383.        
  384.         }
  385.  
  386.         private static void levelfifteen(){
  387.             System.out.println("The man motions you to follow him into a hut");
  388.             System.out.println("Either follow him or make a run for it");
  389.             String playerinput=getinput();
  390.            
  391.             if (playerinput.contains("follow")){
  392.                 System.out.println("Following the man into the hut you notice it's empty.");
  393.                 System.out.println("You feel a sharp pain on the back of your head and you collapse to the ground(You died, game over");
  394.             }
  395.            
  396.             else if(playerinput.contains("run")){
  397.                 System.out.println("As the man turns his back you run for the hills and disappear into the rocks.");
  398.                 levelsixteen();
  399.             }
  400.        
  401.             else {
  402.                 System.out.println("Invalid command, you bumbling buffoon.");
  403.                 levelfifteen();        
  404.             }
  405.         }
  406.  
  407.         private static void levelsixteen(){
  408.             System.out.println("Exhausted you fall slumped against a pile of rocks and glance around you notice that hippo tracks are in the ground!");
  409.             System.out.println("Either follow the tracks or follow the path out of the hills/dessert");
  410.             String playerinput=getinput();
  411.            
  412.             if (playerinput.contains("tracks")){
  413.                 System.out.println("You follow the tracks to a hiddeon oasis when the ground suddenly gives out frome under you!");
  414.                 levelseventeen();
  415.                        }
  416.             else if (playerinput.contains("path")){
  417.                 System.out.println("The path seems to just go on and on, eventualy you notice a small cluster of buildings and stumble towards them");
  418.                 leveltwentyone();                
  419.             }
  420.            
  421.             else {
  422.                 System.out.println("Invalid move, you bumbling buffoon.");
  423.                 levelsixteen();
  424.             }
  425.        
  426.         }
  427.  
  428.         private static void levelseventeen(){
  429.             System.out.println("The rocks above the oaisis your standing on collapse and send you tumbling down the hill into a group of Hippos!");
  430.             System.out.println("");
  431.             System.out.println("The Hippos quickly surround you and demand you to surrender. Either comply or resist ");
  432.             String playerinput=getinput();
  433.            
  434.             if (playerinput.contains("surrender")){
  435.                 System.out.println("Satisfied with your compliance the hippos put you into a cave and block it off with a boulder");
  436.                 levelnineteen();
  437.             }
  438.            
  439.             else if(playerinput.contains("resist")){
  440.                 System.out.println("impressed with your courage the group agrees to take you to their leader");
  441.                 leveltwenty();
  442.             }
  443.            
  444.             else{
  445.                 System.out.println("Invalid move, Do you want to die?");
  446.                 leveleighteen();
  447.             }
  448.            
  449.              
  450.         }
  451.  
  452.         private static void leveleighteen(){
  453.         System.out.println("The hippos await your action");
  454.         System.out.println("either surrender or resist");
  455.         String playerinput=getinput();
  456.        
  457.         if (playerinput.contains("surrender")){
  458.             System.out.println("Satisfied with your compliance the hippos put you into a cave and block it off with a boulder");
  459.             levelnineteen();
  460.         }
  461.        
  462.         else if(playerinput.contains("resist")){
  463.             System.out.println("impressed with your courage the group agrees to take you to their leader");
  464.             leveltwenty();
  465.         }
  466.        
  467.         else{
  468.             System.out.println("Invalid move, Do you want to die?");
  469.             leveleighteen();
  470.         }
  471.        
  472.        
  473.         }
  474.  
  475.         private static void levelnineteen(){
  476.             System.out.println("The hippos keep you alive, but you never escape. The fate of your people is now hidden from you");
  477.             levelzero();
  478.         }
  479.  
  480.         private static void leveltwenty() {
  481.        
  482.         }
  483.  
  484.         private static void leveltwentyone(){
  485.             System.out.println("Inside the village you find a  enchanted stone, pick it up or no?");        
  486.             String playerinput=getinput();          
  487.            
  488.         if (playerinput.equalsIgnoreCase("pick it up")){
  489.             int x = rgen.nextInt(4);    
  490.             //
  491.         if (x==0) {
  492.             System.out.println("The stone glows red and hands you a Document!");
  493.             Document=true;
  494.             leveleight();}
  495.         //
  496.         if (x==1){
  497.             System.out.println("Nothing happens and you are teleported back to the rocks" );
  498.             leveltwentytwo();}      
  499.         //
  500.         if (x==2) {
  501.             System.out.println("The stone glows red and hands you a Document!");
  502.             Document=true;
  503.             leveleight();}
  504.         //
  505.         if (x==3){
  506.             System.out.println("You are teleported");
  507.             levelone();
  508.         }
  509.     }
  510.        
  511.        
  512.        
  513.         else if(playerinput.contains("no")){
  514.         levelsixteen();
  515.         }
  516.        
  517.         else{
  518.             System.out.print("What did you just do??");
  519.             leveltwentyone();        
  520.         }
  521.        
  522.         }
  523. //Copy of level 16 after strange stone event
  524.         private static void leveltwentytwo(){
  525.             System.out.println("Exhausted you fall slumped against a pile of rocks and glance around you notice that hippo tracks are in the ground!");
  526.             System.out.println("You must follow the hiipo tracks");
  527.             String playerinput=getinput();
  528.            
  529.             if (playerinput.contains("tracks")){
  530.                 System.out.println("You follow the tracks to a hiddeon oasis when the ground suddenly gives out frome under you!");
  531.                 levelseventeen();
  532.                        }
  533.                          
  534.            
  535.             else {
  536.                 System.out.println("Invalid move, you bumbling buffoon.");
  537.                 levelsixteen();
  538.             }
  539.        
  540.         }
  541. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement