-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalculateBattle.java
53 lines (46 loc) · 1.08 KB
/
CalculateBattle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Write a description of class CalculateBattle here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CalculateBattle
{
// instance variables - replace the example below with your own
public int x=0;
/**
* Constructor for objects of class CalculateBattle
*/
public CalculateBattle(Player p, int choice, Enemy emy)
{
if(p.attackStr[choice]>0)
emy.health -= p.attackStr[choice];
else
{
p.health+=p.attackStr[choice]*-1;
if(p.health>p.maxHealth)
p.health = p.maxHealth;
}
if(emy.health<=0)
{
//Faint logic here
x=1;
}
}
public CalculateBattle(Enemy emy, int choice, Player p)
{
if(emy.attackStr[choice]>0)
p.health -= emy.attackStr[choice];
else
{
emy.health+=emy.attackStr[choice]*-1;
if(emy.health>emy.maxHealth)
emy.health = emy.maxHealth;
}
if(p.health<=0)
{
//Loss logic here
x=1;
}
}
}