masterderek1

Fighter game V1

Sep 18th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.25 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.         int search = rand.nextInt(4) + 1;
  133.        
  134.         String searchResult = "";
  135.        
  136.         switch(search){
  137.            
  138.             case 1: searchResult = "You found a rock! + 3 damage to all attacks!";
  139.             dmg = dmg + 3;break;
  140.            
  141.             case 2: searchResult = "You found bandages! They can heal you 15";
  142.             bandages = bandages + 1;break;
  143.            
  144.             case 3: searchResult = "You found a sheild potion! + 10 shield!";
  145.             shield = shield + 10;break;
  146.            
  147.             case 4: searchResult = "You found a stick! + 2 damage to all attacks!";
  148.             dmg = dmg + 2;break;
  149.            
  150.            
  151.         }
  152.        
  153.         int enemyswitch = rand.nextInt(8) + 1;
  154.        
  155.         String enemyType = "";
  156.        
  157.         switch(enemyswitch){
  158.            
  159.             case 1: enemyType = "baby dragon";break;
  160.            
  161.             case 2: enemyType = "smelly imp";break;
  162.            
  163.             case 3: enemyType = "skeleton warrior";break;
  164.            
  165.             case 4: enemyType = "spider";break;
  166.            
  167.             case 5: enemyType = "mage";break;
  168.            
  169.             case 6: enemyType = "quick archer";break;
  170.            
  171.             case 7: enemyType = "rouge assasin";break;
  172.            
  173.             case 8: enemyType = "smelly ogre";break;
  174.            
  175.            
  176.         }
  177.        
  178.        
  179.        
  180.        
  181.         //END SWITCHES
  182.        
  183.        
  184.        
  185.        
  186.        
  187.        
  188.        
  189.        
  190.        
  191.        
  192.        
  193.        
  194.        
  195.         //continue story
  196.        
  197.         System.out.println("");
  198.        
  199.         System.out.println("--------------------------------------------------");
  200.        
  201.         System.out.println("Now that you know the basics, lets do our first battle.");
  202.        
  203.         System.out.println("--------------------------------------------------");
  204.        
  205.         int rnd = 1;                                    //                                          DEFINE ROUND
  206.                  
  207.         //end session
  208.        
  209.         int enemykills = 1;
  210.        
  211.     while (rnd < 10) {
  212.            
  213.        
  214.        
  215.        
  216.         System.out.println("");
  217.        
  218.         System.out.println("Round " + Integer.toString(rnd));
  219.         //                          use this ^ for toString
  220.         System.out.println("");
  221.        
  222.         System.out.println("Your enemy is a " + enemyType +", and has " + enemyhealth + "hp, you have the choice to either attack, search, or heal");
  223.        
  224.         String round1;
  225.        
  226.         System.out.println("");
  227.        
  228.         round1 = scan.nextLine();
  229.        
  230.         System.out.println("");
  231.        
  232.          if (round1.equalsIgnoreCase("attack"))
  233.         {
  234.        
  235.         enemyhealth = enemyhealth - dmg;
  236.        
  237.          System.out.println("You did "+ dmg + " damage to the " + enemyType + "! They now have " + enemyhealth + "hp!");
  238.          
  239.          //System.out.println(enemy1);               //enemy1 = enemy's health
  240.          
  241.         }else if (round1.equalsIgnoreCase("search"))
  242.         {
  243.            
  244.         //System.out.println(search); prints the number for the case result
  245.            
  246.         System.out.println(searchResult);
  247.          
  248.            
  249.            
  250.         }else if (round1.equalsIgnoreCase("heal"))
  251.         {
  252.            
  253.             if (bandages > 0 && health < 100)
  254.             {
  255.                 bandages = bandages - 1;
  256.                 health = health + 15;
  257.                 if (health > 100)
  258.                 {
  259.                     health = 100;
  260.                    
  261.                 }
  262.                 System.out.println("Your bandage healed you 15hp! You now have " + health + "hp!");
  263.                
  264.             } else
  265.             {
  266.                 if (bandages > 0)
  267.                 {
  268.                     System.out.println("Cannot use bandages, your health is already 100!");
  269.                 }else
  270.                 {
  271.                     System.out.println("Sorry, you don't have any bandages");
  272.                 }
  273.                
  274.             }
  275.            
  276.            
  277.            
  278.         }
  279.        
  280.         System.out.println("--------------------------------------------------");
  281.        
  282.         System.out.println("Now the " + enemyType + " will act in response.");
  283.        
  284.         System.out.println("--------------------------------------------------");
  285.        
  286.         System.out.println("");
  287.        
  288.         basedmg = Math.abs(shield - enemydmg);
  289.         //        Math.abs makes the absolute value of something ()
  290.         shield = shield - enemydmg;
  291.        
  292.         if (shield < 1){
  293.             shield = 0;
  294.         }
  295.        
  296.         health = health - basedmg;
  297.        
  298.         System.out.println("The " + enemyType + " attacks! It does " + enemydmg + " damage to you! You now have " + shield + " shield, and " + health + " health.");
  299.        
  300.         System.out.println("");
  301.        
  302.         System.out.println("This is the end of round " + Integer.toString(rnd) + ".");
  303.        
  304.         rnd = rnd + 1;
  305.        
  306.         if (enemyhealth < 1){ // if the enemy is dead
  307.        
  308.             healthmultiplyer = healthmultiplyer + 4;
  309.            
  310.             damagemultiplyer = damagemultiplyer + 3;
  311.            
  312.              System.out.println("");
  313.            
  314.             System.out.println("You killed the enemy! It took you " + (rnd - 1) + " rounds!");
  315.            
  316.             System.out.println("");
  317.            
  318.             rnd = 1;
  319.            
  320.             enemyhealth = 20;
  321.            
  322.             enemydmg = enemydmg + damagemultiplyer;
  323.            
  324.             enemyhealth = enemyhealth + healthmultiplyer;
  325.            
  326.             enemykills = enemykills + 1;
  327.            
  328.              System.out.println("Enemy " + enemykills);
  329.         }
  330.        
  331.        
  332.         //ENEMY BEING BUFFED
  333.        
  334.         //enemydmg = enemydmg + 3;
  335.         //enemyhealth = enemyhealth + 4;                                                                        
  336.        
  337.        
  338.        
  339.        
  340.        
  341.     }
  342.        
  343.     }
  344. } // make it so that each round is a method, at the end of the round, the variable rndNumber += 1, and the enemy health is randomized plus 5 % health and damage.
  345. //make a variable called hasweapon, and if you pick up a weapon, add to damage, and set hasweapon = 1. if you are trying to pick up another weapon, if hasweapon = 1, print "you cant take another"
  346.  
  347. //aug 31, next step is to make it endless, rnd is t
  348. //Sept 17, its endless, now make it so when the enemy dies, something happens. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Add Comment
Please, Sign In to add comment