Advertisement
dguidorizzi

Untitled

Aug 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.07 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. import java.lang.*;
  4.  
  5. //legend:    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = where i left off last
  6.  
  7.  
  8.  
  9.  
  10. public class Game {
  11.     public static void main(String args[]) {
  12.         // text game attempt 1
  13.        
  14.        
  15.         Scanner scan = new Scanner(System.in);
  16.         Random rand = new Random();
  17.        
  18.         //health define
  19.        
  20.         int health;
  21.        
  22.         health = 100;
  23.        
  24.         //END health
  25.        
  26.         //damage define
  27.        
  28.         int dmg;
  29.        
  30.         dmg = 10;
  31.        
  32.         //END damage
  33.        
  34.         //shield define
  35.        
  36.         int shield;
  37.        
  38.         shield = 10;
  39.        
  40.         //END shield
  41.        
  42.         //bandos
  43.        
  44.          int bandages = 0;
  45.          
  46.         //end bandos
  47.        
  48.         //ENEMY HEALTH                                                                                                   ENEMY HEALTH
  49.        
  50.          int enemyhealth = 20;
  51.        
  52.         //END ENEMY HEALTH
  53.        
  54.         //ENEMY DAMAGE                                                                                                   ENEMY DAMAGE
  55.        
  56.          int enemydmg = 12;
  57.        
  58.         //END ENEMY DAMAGE
  59.        
  60.         //BASE DAMAGE
  61.        
  62.         int basedmg = 0;
  63.        
  64.         //END BASE DAMAGE
  65.        
  66.         //ENEMY HEALTH MULTIPLYER
  67.        
  68.         int healthmultiplyer = 4;
  69.        
  70.         //END ENEMY HEALTH MULTIPLYER
  71.        
  72.         //ENEMY DAMAGE MULTIPLYER
  73.        
  74.         int damagemultiplyer = 0;
  75.        
  76.         //END ENEMY DAMAGE MULTIPLYER
  77.        
  78.        
  79.        
  80.         // START STORY
  81.        
  82.         System.out.println("Hello, and welcome to the battle arena");
  83.        
  84.         System.out.println("");
  85.        
  86.         System.out.println("What is your name, fighter?");
  87.        
  88.         System.out.println("");
  89.         //name define
  90.         //---->
  91.         String name = scan.nextLine();
  92.        
  93.         System.out.println("");
  94.         System.out.println("Nice to meet you " + name + ", now lets get to work. I'll show you how to fight");
  95.        
  96.         //start tutorial
  97.         //make this into a thing that prints when the player does /help. make a class or something
  98.         System.out.println("");
  99.        
  100.         System.out.println("This game will work in turns, so each time the game prompts you to type, you will have to make a choice.");
  101.        
  102.         System.out.println("");
  103.         System.out.println("--------------------------------------------------");
  104.         System.out.println("");
  105.        
  106.         //START CONTROLS TUTORIAL
  107.        
  108.         System.out.println("You can say \"attack\", to attack the enemy ");
  109.        
  110.         System.out.println("");
  111.        
  112.         System.out.println("You can say \"search\", to search your surroundings for useful materials  ");
  113.        
  114.         System.out.println("");
  115.        
  116.         System.out.println("You can say \"heal\", to use any heals that you have in your inventory (you can not heal past 100 health)");
  117.        
  118.         System.out.println("");
  119.        
  120.         //END CONTROLS TUTORIAL
  121.        
  122.         System.out.println("This game works in turns, so you will make an action and then the enemy will respond. Each match with an enemy is 10 rounds,");
  123.         System.out.println("so you only have 10 moves to defeat your enemy");
  124.        
  125.         System.out.println("");
  126.        
  127.        
  128.         //end tutorial
  129.        
  130.         //SWITCHES
  131.        
  132.        
  133.        
  134.         int search = rand.nextInt(4) + 1;
  135.        
  136.         String searchResult = "";
  137.        
  138.        
  139.        
  140.        
  141.        
  142.         int enemyswitch = rand.nextInt(8) + 1;
  143.        
  144.        
  145.        
  146.         String enemyType = "";
  147.        
  148.         switch(enemyswitch){
  149.            
  150.             case 1: enemyType = "baby dragon";break;
  151.            
  152.             case 2: enemyType = "smelly imp";break;
  153.            
  154.             case 3: enemyType = "skeleton warrior";break;
  155.            
  156.             case 4: enemyType = "spider";break;
  157.            
  158.             case 5: enemyType = "mage";break;
  159.            
  160.             case 6: enemyType = "quick archer";break;
  161.            
  162.             case 7: enemyType = "rouge assasin";break;
  163.            
  164.             case 8: enemyType = "smelly ogre";break;
  165.            
  166.            
  167.         }
  168.        
  169.        
  170.        
  171.        
  172.         //END SWITCHES
  173.        
  174.        
  175.        
  176.        
  177.        
  178.        
  179.        
  180.        
  181.        
  182.        
  183.        
  184.        
  185.        
  186.         //continue story
  187.        
  188.         System.out.println("");
  189.        
  190.         System.out.println("--------------------------------------------------");
  191.        
  192.         System.out.println("Now that you know the basics, lets do our first battle.");
  193.        
  194.         System.out.println("--------------------------------------------------");
  195.        
  196.         int rnd = 1;                                    //                                          DEFINE ROUND
  197.                  
  198.         //end session
  199.        
  200.         int enemykills = 1;
  201.        
  202.     while (rnd < 10) {
  203.            
  204.        
  205.        
  206.        
  207.         System.out.println("");
  208.        
  209.         System.out.println("Round " + Integer.toString(rnd));
  210.         //                          use this ^ for toString
  211.         System.out.println("");
  212.        
  213.         System.out.println("Your enemy is a " + enemyType +", and has " + enemyhealth + "hp, you have the choice to either attack, search, or heal");
  214.        
  215.         String round1;
  216.        
  217.         System.out.println("");
  218.        
  219.         round1 = scan.nextLine();
  220.        
  221.         System.out.println("");
  222.        
  223.          if (round1.equalsIgnoreCase("attack"))
  224.         {
  225.        
  226.         enemyhealth = enemyhealth - dmg;
  227.        
  228.          System.out.println("You did "+ dmg + " damage to the " + enemyType + "! They now have " + enemyhealth + "hp!");
  229.          
  230.          //System.out.println(enemy1);               //enemy1 = enemy's health
  231.          
  232.         }else if (round1.equalsIgnoreCase("search"))
  233.         {
  234.          switch(search){
  235.            
  236.             case 1:searchResult = "You found a rock! + 3 damage to all attacks!";
  237.             dmg = dmg + 3;
  238.             break;
  239.            
  240.             case 2:searchResult = "You found bandages! They can heal you 15";
  241.             bandages = bandages + 1;
  242.             break;
  243.            
  244.             case 3:searchResult = "You found a sheild potion! + 10 shield!";
  245.             shield = shield + 10;
  246.             break;
  247.            
  248.             case 4:searchResult = "You found a stick! + 2 damage to all attacks!";
  249.             dmg = dmg + 2;
  250.             break;
  251.            
  252.            
  253.         }
  254.         //System.out.println(search); prints the number for the case result
  255.            
  256.         System.out.println(searchResult);
  257.          
  258.         search = rand.nextInt(4);
  259.            
  260.            
  261.         }else if (round1.equalsIgnoreCase("heal"))
  262.         {
  263.            
  264.             if (bandages > 0 && health < 100)
  265.             {
  266.                 bandages = bandages - 1;
  267.                 health = health + 15;
  268.                 if (health > 100)
  269.                 {
  270.                     health = 100;
  271.                    
  272.                 }
  273.                 System.out.println("Your bandage healed you 15hp! You now have " + health + "hp!");
  274.                
  275.             } else
  276.             {
  277.                 if (bandages > 0)
  278.                 {
  279.                     System.out.println("Cannot use bandages, your health is already 100!");
  280.                 }else
  281.                 {
  282.                     System.out.println("Sorry, you don't have any bandages");
  283.                 }
  284.                
  285.             }
  286.            
  287.            
  288.            
  289.         }else{
  290.             System.out.println("invalid input. Please input \"attack\", \"search\", or \"heal\" ");
  291.             System.out.println("");
  292.            
  293.         }
  294.         rnd = rnd + 1;
  295.          if (enemyhealth < 1){ // if the enemy is dead
  296.        
  297.             healthmultiplyer = healthmultiplyer + 4;
  298.            
  299.             damagemultiplyer = damagemultiplyer + 3;
  300.            
  301.              System.out.println("");
  302.            
  303.             System.out.println("You killed the enemy! It took you " + (rnd - 1) + " rounds!");
  304.            
  305.             System.out.println("");
  306.            
  307.             rnd = 1;
  308.            
  309.             enemyhealth = 20;
  310.            
  311.             enemydmg = enemydmg + damagemultiplyer;
  312.            
  313.             enemyhealth = enemyhealth + healthmultiplyer;
  314.            
  315.             enemykills = enemykills + 1;
  316.            
  317.              System.out.println("Enemy " + enemykills);
  318.         } else {
  319.            
  320.        
  321.         System.out.println("--------------------------------------------------");
  322.        
  323.         System.out.println("Now the " + enemyType + " will act in response.");
  324.        
  325.         System.out.println("--------------------------------------------------");
  326.        
  327.         System.out.println("");
  328.        
  329.         basedmg = Math.abs(shield - enemydmg);
  330.         //        Math.abs makes the absolute value of something ()
  331.         shield = shield - enemydmg;
  332.        
  333.         if (shield < 1){
  334.             shield = 0;
  335.         }
  336.        
  337.         health = health - basedmg;
  338.        
  339.         System.out.println("The " + enemyType + " attacks! It does " + enemydmg + " damage to you! You now have " + shield + " shield, and " + health + " health.");
  340.        
  341.         if (health < 1) { //if you are dead
  342.        
  343.         System.out.println("");
  344.        
  345.         System.out.println("You died!");
  346.        
  347.         System.out.println("");
  348.        
  349.         System.out.println("You killed " + enemykills + " enemies!" );
  350.        
  351.         System.out.println("");
  352.        
  353.         System.out.println("Thank you for playing!");
  354.        
  355.         System.exit(0);
  356.         }
  357.        
  358.        
  359.         System.out.println("");
  360.        
  361.         System.out.println("This is the end of round " + Integer.toString(rnd) + ".");
  362.        
  363.         }
  364.        
  365.        
  366.        
  367.        
  368.        
  369.        
  370.        
  371.         //ENEMY BEING BUFFED
  372.        
  373.         //enemydmg = enemydmg + 3;
  374.         //enemyhealth = enemyhealth + 4;                                                                        
  375.        
  376.        
  377.        
  378.        
  379.        
  380.     }
  381.    
  382.     System.out.println("");
  383.      
  384.     System.out.println("You ran out of rounds!");
  385.    
  386.     System.out.println("");
  387.    
  388.     System.out.println("Thank you for playing!");
  389.    
  390.     System.exit(0);
  391.     }
  392. }
  393.  
  394. //aug 31, next step is to make it endless, rnd is t
  395. //Sept 17, its endless, now make it so when the enemy dies, something happens.
  396. //oct 12, switch statement now comes out with random output each time, now make it so if the player gets stick twice (+2dmg), it gives him another +2 damage (currently it gives him +2 once) ^^^^^
  397. //next make something happen when the player dies
  398.  
  399.  
  400. //Language Version:  JDK 9.0.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement