View difference between Paste ID: X361Evr6 and RA7LPrFn
SHOW: | | - or go back to the newest paste.
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(85-41)+30;
37
						//10 extra for critical
38-
						bossHp=bossHp - damage - 10; //10 extra for critical 
38+
39
						bossHp=bossHp - damage;
40
						System.out.printf("You hit the boss for %d!\n", damage-10);
41
					}else{
42
						int damage = rand.nextInt(75-31)+30;
43
						//deal damage to the boss
44
						bossHp=bossHp - damage;
45
						System.out.printf("You hit the boss for %d!\n", damage);
46
					}
47
				}else{
48
					int critChance = rand.nextInt(10-1)+1;
49
					if(critChance >= 7){
50-
						int damage = rand.nextInt(45-21)+20;
50+
						int hitChance = rand.nextInt(10-1)+1;
51
						if(hitChance >= 5){
52-
						bossHp=bossHp - damage - 10; //10 extra for critical
52+
							//player gets a critical damage is doubled
53
							int damage = rand.nextInt(45-21)+20;
54
							//deal damage to the boss
55
							bossHp=bossHp - damage;
56
							System.out.printf("You crit the boss for %d!\n", damage);
57
						}else{
58
							System.out.println("You miss the boss!");
59
						}
60
					}else{
61
						int damage = rand.nextInt(75-31)+30;
62
						//deal damage to the boss
63
						bossHp=bossHp - damage;
64
						System.out.printf("You hit the boss for %d!\n", damage);
65
					}
66
				}
67
				
68
			}
69
				//boss is dead
70
				System.out.println("You slayed the boss! Congrats!");
71
			}else{
72
			//a normal mob has appeared
73
			}
74
	}
75
}