[04e7260] | 1 |
|
---|
[d6c8eb6] | 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 |
|
---|
[04e7260] | 7 | public class Player implements Comparable<Player> {
|
---|
| 8 | private int id;
|
---|
| 9 | private String name;
|
---|
| 10 | private String pass;
|
---|
| 11 | private Gender gender;
|
---|
| 12 | private String channel;
|
---|
| 13 | private Job job;
|
---|
| 14 | private int level;
|
---|
| 15 | private Point loc;
|
---|
| 16 | private Point target;
|
---|
| 17 | private int speed;
|
---|
| 18 | private long lastMoved;
|
---|
| 19 | private int attackSpeed;
|
---|
| 20 | private int damage;
|
---|
| 21 | private long lastAttacked;
|
---|
| 22 | private int strength;
|
---|
| 23 | private int dexterity;
|
---|
| 24 | private int constitution;
|
---|
| 25 | private int charisma;
|
---|
| 26 | private int wisdom;
|
---|
| 27 | private int intelligence;
|
---|
| 28 | private int hitpoints;
|
---|
| 29 | private int manapoints;
|
---|
| 30 | private int maxHitpoints;
|
---|
| 31 | private int maxManapoints;
|
---|
| 32 | private int experience;
|
---|
| 33 | private int gold;
|
---|
| 34 |
|
---|
| 35 | public Player() {
|
---|
| 36 | id = 0;
|
---|
| 37 | name = "";
|
---|
| 38 | pass = "";
|
---|
| 39 | gender = Gender.None;
|
---|
| 40 | channel = "None";
|
---|
| 41 | job = Job.None;
|
---|
| 42 | loc = new Point(0, 0);
|
---|
| 43 | target = new Point(0, 0);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public Player(int id, String name, String pass) {
|
---|
| 47 | this.id = id;
|
---|
| 48 | this.name = name;
|
---|
| 49 | this.pass = pass;
|
---|
| 50 | channel = "None";
|
---|
| 51 | job = Job.None;
|
---|
| 52 | loc = new Point(0, 0);
|
---|
| 53 | target = new Point(0, 0);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public Player(int id, String name, String pass, Gender gender) {
|
---|
| 57 | this.id = id;
|
---|
| 58 | this.name = name;
|
---|
| 59 | this.pass = pass;
|
---|
| 60 | channel = "None";
|
---|
| 61 | this.gender = gender;
|
---|
| 62 | job = Job.None;
|
---|
| 63 | loc = new Point(0, 0);
|
---|
| 64 | target = new Point(0, 0);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | public Player(int id, String name, String pass, Gender gender, Job job) {
|
---|
| 68 | this.id = id;
|
---|
| 69 | this.name = name;
|
---|
| 70 | this.pass = pass;
|
---|
| 71 | channel = "None";
|
---|
| 72 | this.gender = gender;
|
---|
| 73 | this.job = job;
|
---|
| 74 | loc = new Point(0, 0);
|
---|
| 75 | target = new Point(0, 0);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | public void createJob(Job job) {
|
---|
| 79 | this.job = job;
|
---|
| 80 |
|
---|
| 81 | switch(job) {
|
---|
| 82 | case Fighter:
|
---|
| 83 | strength = 12;
|
---|
| 84 | dexterity = 10;
|
---|
| 85 | constitution = 10;
|
---|
| 86 | charisma = 10;
|
---|
| 87 | wisdom = 10;
|
---|
| 88 | intelligence = 10;
|
---|
| 89 | break;
|
---|
| 90 | case Ranger:
|
---|
| 91 | strength = 10;
|
---|
| 92 | dexterity = 12;
|
---|
| 93 | constitution = 10;
|
---|
| 94 | charisma = 10;
|
---|
| 95 | wisdom = 10;
|
---|
| 96 | intelligence = 10;
|
---|
| 97 | break;
|
---|
| 98 | case Barbarian:
|
---|
| 99 | strength = 10;
|
---|
| 100 | dexterity = 10;
|
---|
| 101 | constitution = 12;
|
---|
| 102 | charisma = 10;
|
---|
| 103 | wisdom = 10;
|
---|
| 104 | intelligence = 10;
|
---|
| 105 | break;
|
---|
| 106 | case Sorceror:
|
---|
| 107 | strength = 10;
|
---|
| 108 | dexterity = 10;
|
---|
| 109 | constitution = 10;
|
---|
| 110 | charisma = 12;
|
---|
| 111 | wisdom = 10;
|
---|
| 112 | intelligence = 10;
|
---|
| 113 | break;
|
---|
| 114 | case Druid:
|
---|
| 115 | strength = 10;
|
---|
| 116 | dexterity = 10;
|
---|
| 117 | constitution = 10;
|
---|
| 118 | charisma = 10;
|
---|
| 119 | wisdom = 12;
|
---|
| 120 | intelligence = 10;
|
---|
| 121 | break;
|
---|
| 122 | case Wizard:
|
---|
| 123 | strength = 10;
|
---|
| 124 | dexterity = 10;
|
---|
| 125 | constitution = 10;
|
---|
| 126 | charisma = 10;
|
---|
| 127 | wisdom = 10;
|
---|
| 128 | intelligence = 12;
|
---|
| 129 | break;
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | public int getAttackSpeed() {
|
---|
| 134 | return attackSpeed;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | public String getChannel() {
|
---|
| 138 | return channel;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | public int getCharisma() {
|
---|
| 142 | return charisma;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | public int getConstitution() {
|
---|
| 146 | return constitution;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | public int getDamage() {
|
---|
| 150 | return damage;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | public int getDexterity() {
|
---|
| 154 | return dexterity;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | public int getExperience() {
|
---|
| 158 | return experience;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | public Gender getGender() {
|
---|
| 162 | return gender;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | public int getGold() {
|
---|
| 166 | return gold;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | public int getHitpoints() {
|
---|
| 170 | return hitpoints;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | public int getId() {
|
---|
| 174 | return id;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | public int getIntelligence() {
|
---|
| 178 | return intelligence;
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | public Job getJob() {
|
---|
| 182 | return job;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | public long getLastAttacked() {
|
---|
| 186 | return lastAttacked;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | public long getLastMoved() {
|
---|
| 190 | return lastMoved;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | public int getLevel() {
|
---|
| 194 | return level;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | public Point getLoc() {
|
---|
| 198 | return loc;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | public int getManapoints() {
|
---|
| 202 | return manapoints;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | public int getMaxHitpoints() {
|
---|
| 206 | return maxHitpoints;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | public int getMaxManapoints() {
|
---|
| 210 | return maxManapoints;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | public String getName() {
|
---|
| 214 | return name;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | public String getPass() {
|
---|
| 218 | return pass;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | public int getSpeed() {
|
---|
| 222 | return speed;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | public int getStrength() {
|
---|
| 226 | return strength;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | public Point getTarget() {
|
---|
| 230 | return target;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | public int getWisdom() {
|
---|
| 234 | return wisdom;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | public void setAttackSpeed(int attackSpeed) {
|
---|
| 238 | this.attackSpeed = attackSpeed;
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | public void setChannel(String channel) {
|
---|
| 242 | this.channel = channel;
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | public void setCharisma(int charisma) {
|
---|
| 246 | this.charisma = charisma;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | public void setConstitution(int constitution) {
|
---|
| 250 | this.constitution = constitution;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | public void setDamage(int damage) {
|
---|
| 254 | this.damage = damage;
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | public void setDexterity(int dexterity) {
|
---|
| 258 | this.dexterity = dexterity;
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | public void setExperience(int experience) {
|
---|
| 262 | this.experience = experience;
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | public void setGender(Gender gender) {
|
---|
| 266 | this.gender = gender;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | public void setGold(int gold) {
|
---|
| 270 | this.gold = gold;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | public void setHitpoints(int hitpoints) {
|
---|
| 274 | this.hitpoints = hitpoints;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | public void setId(int id) {
|
---|
| 278 | this.id = id;
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | public void setIntelligence(int intelligence) {
|
---|
| 282 | this.intelligence = intelligence;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | public void setJob(Job job) {
|
---|
| 286 | this.job = job;
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | public void setLastAttacked(long lastAttacked) {
|
---|
| 290 | this.lastAttacked = lastAttacked;
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | public void setLastMoved(long lastMoved) {
|
---|
| 294 | this.lastMoved = lastMoved;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | public void setLevel(int level) {
|
---|
| 298 | this.level = level;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | public void setLoc(Point loc) {
|
---|
[de19622] | 302 | this.loc = new Point(loc.getX(), loc.getY());
|
---|
[04e7260] | 303 | }
|
---|
| 304 |
|
---|
| 305 | public void setManapoints(int manapoints) {
|
---|
| 306 | this.manapoints = manapoints;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | public void setMaxHitpoints(int maxHitpoints) {
|
---|
| 310 | this.maxHitpoints = maxHitpoints;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | public void setMaxManapoints(int maxManapoints) {
|
---|
| 314 | this.maxManapoints = maxManapoints;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | public void setName(String name) {
|
---|
| 318 | this.name = name;
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | public void setPass(String pass) {
|
---|
| 322 | this.pass = pass;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | public void setSpeed(int speed) {
|
---|
| 326 | this.speed = speed;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | public void setStrength(int strength) {
|
---|
| 330 | this.strength = strength;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | public void setTarget(Point target) {
|
---|
| 334 | this.target = target;
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 | public void setWisdom(int wisdom) {
|
---|
| 338 | this.wisdom = wisdom;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | public String toString() {
|
---|
| 342 | return name;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | public boolean equals(Object p) {
|
---|
| 346 | return name.trim().equals(((Player)p).name.trim());
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | public int compareTo(Player p) {
|
---|
| 350 | return id - p.id;
|
---|
| 351 | }
|
---|
| 352 | }
|
---|