Advertisement
daixso

Fight Class first test

Aug 2nd, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. /**
  2.  * This code controls fights, and boss fights
  3.  * @author zachary
  4.  *
  5.  **/
  6. import java.util.*;
  7. import java.awt.*;
  8. public class Fighting {
  9.     public Fighting(){
  10.         Fight();
  11.     }
  12.     public void Fight(){
  13.         Scanner attack = new Scanner(System.in);
  14.         Random rand = new Random();
  15.         Game_Variables varObj = new Game_Variables();
  16.         int max=10;
  17.         int min=1;
  18.         int bossChance = 8;//rand.nextInt(max - min + 1) + min;
  19.         int bossHp=200;//boss health
  20.         int bossGold=rand.nextInt(100-50+1)+50;//boss money drop
  21.         int bossExp=75;
  22.        
  23.         if(bossChance >= 7){
  24.             //a boss mob has appeared
  25.             System.out.println("A boss appears! Prepare to fight!");
  26.             while(bossHp >= 0){
  27.                 //boss is alive
  28.                 System.out.printf("Boss HP: %d!\n", bossHp);
  29.                 System.out.println("Choose attack!\n1. Fireball (50%)\n2. Melee");
  30.                 System.out.print("Attack: ");
  31.                 attack.nextLine();
  32.                 if(attack.equals("1")){
  33.                     int critChance = rand.nextInt(10-1)+1;
  34.                     if(critChance >= 9){
  35.                         //player gets a critical damage is doubled
  36.                         int damage = rand.nextInt(75-31)+30;
  37.                         //deal damage to the boss
  38.                         bossHp=bossHp - damage - 10; //10 extra for critical
  39.                         System.out.printf("You hit the boss for %d!\n", damage-10);
  40.                     }else{
  41.                         int damage = rand.nextInt(75-31)+30;
  42.                         //deal damage to the boss
  43.                         bossHp=bossHp - damage;
  44.                         System.out.printf("You hit the boss for %d!\n", damage);
  45.                     }
  46.                 }else{
  47.                     int critChance = rand.nextInt(10-1)+1;
  48.                     if(critChance >= 7){
  49.                         //player gets a critical damage is doubled
  50.                         int damage = rand.nextInt(45-21)+20;
  51.                         //deal damage to the boss
  52.                         bossHp=bossHp - damage - 10; //10 extra for critical
  53.                         System.out.printf("You hit the boss for %d!\n", damage-10);
  54.                     }else{
  55.                         int damage = rand.nextInt(75-31)+30;
  56.                         //deal damage to the boss
  57.                         bossHp=bossHp - damage;
  58.                         System.out.printf("You hit the boss for %d!\n", damage);
  59.                     }
  60.                 }
  61.                
  62.             }
  63.                 //boss is dead
  64.                 System.out.println("You slayed the boss! Congrats!");
  65.             }else{
  66.             //a normal mob has appeared
  67.             }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement