1 |
|
---|
2 | /*
|
---|
3 | * This class contains most of the information about a player and an instance should exist for every registered player, whether or not he
|
---|
4 | * is online.
|
---|
5 | */
|
---|
6 |
|
---|
7 | public class Player implements Comparable<Player> {
|
---|
8 | /*
|
---|
9 | Dim ID As Integer added
|
---|
10 | Dim GameID As Integer unnecessary
|
---|
11 | Dim Name As String added
|
---|
12 | Dim Password As String added
|
---|
13 | Dim Online As Boolean probably unnecessary
|
---|
14 | Dim State As Integer not added yet
|
---|
15 | Dim currentChannel As Channel added
|
---|
16 | Dim Chat As String not added yet
|
---|
17 | Dim Job As Integer added
|
---|
18 | Dim Level As Integer added
|
---|
19 | Dim Inventory() As Item not added yet
|
---|
20 | Dim ItemAmount As Integer not added yet
|
---|
21 | Dim Spells() As Spell not added yet
|
---|
22 | Dim Location As MapPoint added
|
---|
23 | Dim TargetLocation As MapPoint added
|
---|
24 | Dim TargetEnemy As Integer not added yet
|
---|
25 | Dim TargetItem As Integer not added yet
|
---|
26 | Dim Gender As Integer added
|
---|
27 | Dim Speed As Integer added
|
---|
28 | Dim Damage As String added
|
---|
29 | Dim Cooldown As Integer added
|
---|
30 | Dim LastAttacked As Integer added
|
---|
31 | Dim ExtraPoints As Integer added
|
---|
32 | Dim Strength As Integer added
|
---|
33 | Dim Dexterity As Integer added
|
---|
34 | Dim Constitution As Integer added
|
---|
35 | Dim Charisma As Integer added
|
---|
36 | Dim Wisdom As Integer added
|
---|
37 | Dim Intelligence As Integer added
|
---|
38 | Dim HitPoints As Integer added
|
---|
39 | Dim MaxHitPoints As Integer added
|
---|
40 | Dim ManaPoints As Integer added
|
---|
41 | Dim MaxManaPoints As Integer added
|
---|
42 | Dim Experience As Integer added
|
---|
43 | Dim Gold As Integer added
|
---|
44 | */
|
---|
45 | private int id;
|
---|
46 | private String name;
|
---|
47 | private String pass;
|
---|
48 | private Gender gender;
|
---|
49 | private String channel;
|
---|
50 | private Job job;
|
---|
51 | private int level;
|
---|
52 | private Point loc;
|
---|
53 | private Point target;
|
---|
54 | private int speed;
|
---|
55 | private long lastMoved;
|
---|
56 | private int attackSpeed;
|
---|
57 | private int damage;
|
---|
58 | private long lastAttacked;
|
---|
59 | private int strength;
|
---|
60 | private int dexterity;
|
---|
61 | private int constitution;
|
---|
62 | private int charisma;
|
---|
63 | private int wisdom;
|
---|
64 | private int intelligence;
|
---|
65 | private int hitpoints;
|
---|
66 | private int manapoints;
|
---|
67 | private int maxHitpoints;
|
---|
68 | private int maxManapoints;
|
---|
69 | private int experience;
|
---|
70 | private int gold;
|
---|
71 |
|
---|
72 | public Player() {
|
---|
73 | id = 0;
|
---|
74 | name = "";
|
---|
75 | pass = "";
|
---|
76 | gender = Gender.None;
|
---|
77 | channel = "None";
|
---|
78 | job = Job.None;
|
---|
79 | loc = new Point(0, 0);
|
---|
80 | target = new Point(0, 0);
|
---|
81 | }
|
---|
82 |
|
---|
83 | public Player(int id, String name, String pass) {
|
---|
84 | this.id = id;
|
---|
85 | this.name = name;
|
---|
86 | this.pass = pass;
|
---|
87 | channel = "None";
|
---|
88 | job = Job.None;
|
---|
89 | loc = new Point(0, 0);
|
---|
90 | target = new Point(0, 0);
|
---|
91 | }
|
---|
92 |
|
---|
93 | public Player(int id, String name, String pass, Gender gender) {
|
---|
94 | this.id = id;
|
---|
95 | this.name = name;
|
---|
96 | this.pass = pass;
|
---|
97 | channel = "None";
|
---|
98 | this.gender = gender;
|
---|
99 | job = Job.None;
|
---|
100 | loc = new Point(0, 0);
|
---|
101 | target = new Point(0, 0);
|
---|
102 | }
|
---|
103 |
|
---|
104 | public Player(int id, String name, String pass, Gender gender, Job job) {
|
---|
105 | this.id = id;
|
---|
106 | this.name = name;
|
---|
107 | this.pass = pass;
|
---|
108 | channel = "None";
|
---|
109 | this.gender = gender;
|
---|
110 | this.job = job;
|
---|
111 | loc = new Point(0, 0);
|
---|
112 | target = new Point(0, 0);
|
---|
113 | }
|
---|
114 |
|
---|
115 | public void createJob(Job job) {
|
---|
116 | this.job = job;
|
---|
117 |
|
---|
118 | switch(job) {
|
---|
119 | case Fighter:
|
---|
120 | strength = 12;
|
---|
121 | dexterity = 10;
|
---|
122 | constitution = 10;
|
---|
123 | charisma = 10;
|
---|
124 | wisdom = 10;
|
---|
125 | intelligence = 10;
|
---|
126 | break;
|
---|
127 | case Ranger:
|
---|
128 | strength = 10;
|
---|
129 | dexterity = 12;
|
---|
130 | constitution = 10;
|
---|
131 | charisma = 10;
|
---|
132 | wisdom = 10;
|
---|
133 | intelligence = 10;
|
---|
134 | break;
|
---|
135 | case Barbarian:
|
---|
136 | strength = 10;
|
---|
137 | dexterity = 10;
|
---|
138 | constitution = 12;
|
---|
139 | charisma = 10;
|
---|
140 | wisdom = 10;
|
---|
141 | intelligence = 10;
|
---|
142 | break;
|
---|
143 | case Sorceror:
|
---|
144 | strength = 10;
|
---|
145 | dexterity = 10;
|
---|
146 | constitution = 10;
|
---|
147 | charisma = 12;
|
---|
148 | wisdom = 10;
|
---|
149 | intelligence = 10;
|
---|
150 | break;
|
---|
151 | case Druid:
|
---|
152 | strength = 10;
|
---|
153 | dexterity = 10;
|
---|
154 | constitution = 10;
|
---|
155 | charisma = 10;
|
---|
156 | wisdom = 12;
|
---|
157 | intelligence = 10;
|
---|
158 | break;
|
---|
159 | case Wizard:
|
---|
160 | strength = 10;
|
---|
161 | dexterity = 10;
|
---|
162 | constitution = 10;
|
---|
163 | charisma = 10;
|
---|
164 | wisdom = 10;
|
---|
165 | intelligence = 12;
|
---|
166 | break;
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 | public int getAttackSpeed() {
|
---|
171 | return attackSpeed;
|
---|
172 | }
|
---|
173 |
|
---|
174 | public String getChannel() {
|
---|
175 | return channel;
|
---|
176 | }
|
---|
177 |
|
---|
178 | public int getCharisma() {
|
---|
179 | return charisma;
|
---|
180 | }
|
---|
181 |
|
---|
182 | public int getConstitution() {
|
---|
183 | return constitution;
|
---|
184 | }
|
---|
185 |
|
---|
186 | public int getDamage() {
|
---|
187 | return damage;
|
---|
188 | }
|
---|
189 |
|
---|
190 | public int getDexterity() {
|
---|
191 | return dexterity;
|
---|
192 | }
|
---|
193 |
|
---|
194 | public int getExperience() {
|
---|
195 | return experience;
|
---|
196 | }
|
---|
197 |
|
---|
198 | public Gender getGender() {
|
---|
199 | return gender;
|
---|
200 | }
|
---|
201 |
|
---|
202 | public int getGold() {
|
---|
203 | return gold;
|
---|
204 | }
|
---|
205 |
|
---|
206 | public int getHitpoints() {
|
---|
207 | return hitpoints;
|
---|
208 | }
|
---|
209 |
|
---|
210 | public int getId() {
|
---|
211 | return id;
|
---|
212 | }
|
---|
213 |
|
---|
214 | public int getIntelligence() {
|
---|
215 | return intelligence;
|
---|
216 | }
|
---|
217 |
|
---|
218 | public Job getJob() {
|
---|
219 | return job;
|
---|
220 | }
|
---|
221 |
|
---|
222 | public long getLastAttacked() {
|
---|
223 | return lastAttacked;
|
---|
224 | }
|
---|
225 |
|
---|
226 | public long getLastMoved() {
|
---|
227 | return lastMoved;
|
---|
228 | }
|
---|
229 |
|
---|
230 | public int getLevel() {
|
---|
231 | return level;
|
---|
232 | }
|
---|
233 |
|
---|
234 | public Point getLoc() {
|
---|
235 | return loc;
|
---|
236 | }
|
---|
237 |
|
---|
238 | public int getManapoints() {
|
---|
239 | return manapoints;
|
---|
240 | }
|
---|
241 |
|
---|
242 | public int getMaxHitpoints() {
|
---|
243 | return maxHitpoints;
|
---|
244 | }
|
---|
245 |
|
---|
246 | public int getMaxManapoints() {
|
---|
247 | return maxManapoints;
|
---|
248 | }
|
---|
249 |
|
---|
250 | public String getName() {
|
---|
251 | return name;
|
---|
252 | }
|
---|
253 |
|
---|
254 | public String getPass() {
|
---|
255 | return pass;
|
---|
256 | }
|
---|
257 |
|
---|
258 | public int getSpeed() {
|
---|
259 | return speed;
|
---|
260 | }
|
---|
261 |
|
---|
262 | public int getStrength() {
|
---|
263 | return strength;
|
---|
264 | }
|
---|
265 |
|
---|
266 | public Point getTarget() {
|
---|
267 | return target;
|
---|
268 | }
|
---|
269 |
|
---|
270 | public int getWisdom() {
|
---|
271 | return wisdom;
|
---|
272 | }
|
---|
273 |
|
---|
274 | public void setAttackSpeed(int attackSpeed) {
|
---|
275 | this.attackSpeed = attackSpeed;
|
---|
276 | }
|
---|
277 |
|
---|
278 | public void setChannel(String channel) {
|
---|
279 | this.channel = channel;
|
---|
280 | }
|
---|
281 |
|
---|
282 | public void setCharisma(int charisma) {
|
---|
283 | this.charisma = charisma;
|
---|
284 | }
|
---|
285 |
|
---|
286 | public void setConstitution(int constitution) {
|
---|
287 | this.constitution = constitution;
|
---|
288 | }
|
---|
289 |
|
---|
290 | public void setDamage(int damage) {
|
---|
291 | this.damage = damage;
|
---|
292 | }
|
---|
293 |
|
---|
294 | public void setDexterity(int dexterity) {
|
---|
295 | this.dexterity = dexterity;
|
---|
296 | }
|
---|
297 |
|
---|
298 | public void setExperience(int experience) {
|
---|
299 | this.experience = experience;
|
---|
300 | }
|
---|
301 |
|
---|
302 | public void setGender(Gender gender) {
|
---|
303 | this.gender = gender;
|
---|
304 | }
|
---|
305 |
|
---|
306 | public void setGold(int gold) {
|
---|
307 | this.gold = gold;
|
---|
308 | }
|
---|
309 |
|
---|
310 | public void setHitpoints(int hitpoints) {
|
---|
311 | this.hitpoints = hitpoints;
|
---|
312 | }
|
---|
313 |
|
---|
314 | public void setId(int id) {
|
---|
315 | this.id = id;
|
---|
316 | }
|
---|
317 |
|
---|
318 | public void setIntelligence(int intelligence) {
|
---|
319 | this.intelligence = intelligence;
|
---|
320 | }
|
---|
321 |
|
---|
322 | public void setJob(Job job) {
|
---|
323 | this.job = job;
|
---|
324 | }
|
---|
325 |
|
---|
326 | public void setLastAttacked(long lastAttacked) {
|
---|
327 | this.lastAttacked = lastAttacked;
|
---|
328 | }
|
---|
329 |
|
---|
330 | public void setLastMoved(long lastMoved) {
|
---|
331 | this.lastMoved = lastMoved;
|
---|
332 | }
|
---|
333 |
|
---|
334 | public void setLevel(int level) {
|
---|
335 | this.level = level;
|
---|
336 | }
|
---|
337 |
|
---|
338 | public void setLoc(Point loc) {
|
---|
339 | this.loc = loc;
|
---|
340 | }
|
---|
341 |
|
---|
342 | public void setManapoints(int manapoints) {
|
---|
343 | this.manapoints = manapoints;
|
---|
344 | }
|
---|
345 |
|
---|
346 | public void setMaxHitpoints(int maxHitpoints) {
|
---|
347 | this.maxHitpoints = maxHitpoints;
|
---|
348 | }
|
---|
349 |
|
---|
350 | public void setMaxManapoints(int maxManapoints) {
|
---|
351 | this.maxManapoints = maxManapoints;
|
---|
352 | }
|
---|
353 |
|
---|
354 | public void setName(String name) {
|
---|
355 | this.name = name;
|
---|
356 | }
|
---|
357 |
|
---|
358 | public void setPass(String pass) {
|
---|
359 | this.pass = pass;
|
---|
360 | }
|
---|
361 |
|
---|
362 | public void setSpeed(int speed) {
|
---|
363 | this.speed = speed;
|
---|
364 | }
|
---|
365 |
|
---|
366 | public void setStrength(int strength) {
|
---|
367 | this.strength = strength;
|
---|
368 | }
|
---|
369 |
|
---|
370 | public void setTarget(Point target) {
|
---|
371 | this.target = target;
|
---|
372 | }
|
---|
373 |
|
---|
374 | public void setWisdom(int wisdom) {
|
---|
375 | this.wisdom = wisdom;
|
---|
376 | }
|
---|
377 |
|
---|
378 | public String toString() {
|
---|
379 | return name;
|
---|
380 | }
|
---|
381 |
|
---|
382 | public boolean equals(Object p) {
|
---|
383 | return name.trim().equals(((Player)p).name.trim());
|
---|
384 | }
|
---|
385 |
|
---|
386 | public int compareTo(Player p) {
|
---|
387 | return id - p.id;
|
---|
388 | }
|
---|
389 | }
|
---|