Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This code controls fights, and boss fights
- * @author zachary
- *
- **/
- import java.util.*;
- import java.awt.*;
- public class Fighting {
- public Fighting(){
- Fight();
- }
- public void Fight(){
- Scanner attack = new Scanner(System.in);
- Random rand = new Random();
- Game_Variables varObj = new Game_Variables();
- int max=10;
- int min=1;
- int bossChance = 8;//rand.nextInt(max - min + 1) + min;
- int bossHp=200;//boss health
- int bossGold=rand.nextInt(100-50+1)+50;//boss money drop
- int bossExp=75;
- if(bossChance >= 7){
- //a boss mob has appeared
- System.out.println("A boss appears! Prepare to fight!");
- while(bossHp >= 0){
- //boss is alive
- System.out.printf("Boss HP: %d!\n", bossHp);
- System.out.println("Choose attack!\n1. Fireball (50%)\n2. Melee");
- System.out.print("Attack: ");
- attack.nextLine();
- if(attack.equals("1")){
- int critChance = rand.nextInt(10-1)+1;
- if(critChance >= 9){
- //player gets a critical damage is doubled
- int damage = rand.nextInt(75-31)+30;
- //deal damage to the boss
- bossHp=bossHp - damage - 10; //10 extra for critical
- System.out.printf("You hit the boss for %d!\n", damage-10);
- }else{
- int damage = rand.nextInt(75-31)+30;
- //deal damage to the boss
- bossHp=bossHp - damage;
- System.out.printf("You hit the boss for %d!\n", damage);
- }
- }else{
- int critChance = rand.nextInt(10-1)+1;
- if(critChance >= 7){
- //player gets a critical damage is doubled
- int damage = rand.nextInt(45-21)+20;
- //deal damage to the boss
- bossHp=bossHp - damage - 10; //10 extra for critical
- System.out.printf("You hit the boss for %d!\n", damage-10);
- }else{
- int damage = rand.nextInt(75-31)+30;
- //deal damage to the boss
- bossHp=bossHp - damage;
- System.out.printf("You hit the boss for %d!\n", damage);
- }
- }
- }
- //boss is dead
- System.out.println("You slayed the boss! Congrats!");
- }else{
- //a normal mob has appeared
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement