This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.java
149 lines (120 loc) · 2.95 KB
/
Character.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package po.crawler.web.project;
import java.awt.image.BufferedImage;
public class Character {
private String name;
private String img;
private int pointer = -1; // package private
private int health;
private int force;
private int witchcraft;
private int armor;
private String type;
private BufferedImage image;
Observer observer;
Items item = new Items();
Boots boot = new Boots();
// konstruktor
public Character(){} // pusty
public void warrior() {
this.health = 1000;
this.force = 500;
this.witchcraft = 100;
this.armor=500;
this.type = "WARRIOR";
}
public void mag(){
this.health=1500;
this.force = 100;
this.witchcraft=500;
this.armor = 250;
this.type="MAG";
}
public void tank(){
this.health=1000;
this.armor=1000;
this.witchcraft=0;
this.force =500;
this.type="TANK";
}
public void setter(int number) {
if(number > GetLOL.characters.size()-1 || number < 0){System.out.println("error1");}
else{
this.name=GetLOL.characters.get(number);
}
}
public void changeup() {
if(pointer < GetLOL.characters.size()-1){
pointer+=1;
setter(pointer);
inform(); // metoda uaktualniająca obrazek w GUI
}
else{
pointer= -1;
changeup();
}
}
public void changedown() {
if(pointer > 0){
pointer-=1;
setter(pointer);
inform(); // uaktualnienie oobrazka w GUI
}
else{
pointer=GetLOL.characters.size()-1;
changedown();
}
}
// Observer Pattern
public void inform(){
observer.update();
}
public void subscribe(Observer o){
observer = o;
}
public void unsubscribe(Observer o){
if(o==observer){
observer=null;
}
}
// gettery
public String getName() {
return name;
}
public String getImg() {
return img;
}
public int getHealth() {
return health + item.getAdd1() + boot.getAdd1();
}
public int getForce() {
return force + item.getAdd2() + boot.getAdd2();
}
public int getWitchcraft() {
return witchcraft + item.getAdd3() + boot.getAdd3();
}
public int getArmor() {
return armor + item.getAdd4() + boot.getAdd4();
}
public String getType() {
return type;
}
public void setName(String name) {
this.name = name;
}
public int getPointer() {
return pointer;
}
public BufferedImage getImage() {
return image;
}
// settery
public void reset(){
this.health=0;
this.armor=0;
this.force = 0;
this.witchcraft=0;
this.item.reset();
this.boot.reset();
this.pointer = -1;
}
}