-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.java
130 lines (107 loc) · 3.33 KB
/
Entity.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
public class Entity {
private String name = "Nameless";
private PlayerClass clas = setGenericClass();
private Attack[] attacks;
private int hp = 20;
private int mp = 5;
private int str = 5;
private int agi = 2;
private int wis = 1;
private int ini = 1;
private int spi = 2;
private int sta = 3;
private int end = 0;
private int lvl = 1;
public Entity(String name, PlayerClass clas, int str, int agi, int wis, int ini, int spi, int sta, int lvl) {
this.name = name;
this.clas = clas;
this.str = str;
this.agi = agi;
this.wis = wis;
this.ini = ini;
this.spi = spi;
this.sta = sta;
this.hp = getHp(this.sta, this.lvl);
this.mp = getMp(this.wis, this.lvl);
}
public Entity(String name, Attack[] attacks) {
this.name = name;
this.attacks = attacks;
}
public int getHp(int sta, int lvl) {
return (int)(sta * lvl * lvl * 5.3);
}
public int getMp(int wis, int lvl) {
return (int)(wis * lvl * lvl * 4.7);
}
public int getStr() {
return this.str;
}
public double getDps() {
return (int)(this.str * this.str * 0.3 + this.agi * this.agi * 0.08);
}
public double getSdps() {
return (int)(this.ini * this.ini * 0.25 + this.wis * this.wis * 0.05);
}
public String getSummary() {
return "Name: " + this.name + "\nHP: " + this.hp + "\nMP: " + this.mp + "\nLVL: " + this.lvl;
}
public String getName() {
return this.name;
}
public Attack[] getAttacks() {
return this.attacks;
}
public int getAttackDmg(PhysicalAttack atk) {
return (int)(this.getDps() * atk.getDmg());
}
public int getAttackDmg(MagicalAttack atk) {
return (int)(this.getSdps() * atk.getDmg());
}
//Setters Below
public void setStr(int setVal) {
this.str = setVal;
}
public void setAgi(int setVal) {
this.agi = setVal;
}
public void setIni(int setVal) {
this.ini = setVal;
}
public void setWis(int setVal) {
this.wis = setVal;
}
public void setSpi(int setVal) {
this.spi = setVal;
}
public void setSta(int setVal) {
this.sta = setVal;
}
//Only to be used on initial character creation. Code will look to messy if used frequently.
public void setStats(int str, int agi, int ini, int wis, int spi, int sta) {
this.str = str;
this.agi = agi;
this.ini = ini;
this.wis = wis;
this.spi = spi;
this.sta = sta;
}
//Easier to use if setting base values.
public void setStats(int[] statArr) {
this.str = statArr[0];
this.agi = statArr[1];
this.ini = statArr[2];
this.wis = statArr[3];
this.spi = statArr[4];
this.sta = statArr[5];
}
private PlayerClass setGenericClass() {
return new PlayerClass("Commoner", 0, 1, 1, 1, 1, 1, 1, new String[] {"fist"});
}
public void setPlayerClass(PlayerClass pClass) {
this.clas = pClass;
}
public PlayerClass getPlayerClass() {
return this.clas;
}
}