@Override public HashMap<String, Integer> getInfo(GameObjectID id) throws BozorgExceptionBase { HashMap<String, Integer> ret = new HashMap<String, Integer>(); if (objects.get(id.getNumber()).getClass().equals(Fan.class)) { Fan f = (Fan) objects.get(id.getNumber()); ret.put(JudgeAbstract.ROW, f.x); ret.put(JudgeAbstract.COL, f.y); ret.put(JudgeAbstract.OWNER, f.owner.getName()); if (f.isAlive) ret.put(JudgeAbstract.IS_ALIVE, JudgeAbstract.ALIVE); else ret.put(JudgeAbstract.IS_ALIVE, JudgeAbstract.DEAD); } if (objects.get(id.getNumber()).getClass().equals(Player.class)) { Player p = (Player) objects.get(id.getNumber()); ret.put(JudgeAbstract.ROW, p.x); ret.put(JudgeAbstract.COL, p.y); ret.put(JudgeAbstract.SPEED, p.getSpeed()); ret.put(JudgeAbstract.NAME, p.getName()); if (Judge.winner == 4) ret.put(JudgeAbstract.IS_WINNER, JudgeAbstract.NOT_FINISHED); else if (Judge.winner == p.getName()) ret.put(JudgeAbstract.IS_WINNER, JudgeAbstract.WINS); else ret.put(JudgeAbstract.IS_WINNER, JudgeAbstract.LOST); ret.put(JudgeAbstract.POWER, p.getPower()); ret.put(JudgeAbstract.VISION, p.getVision()); ret.put(JudgeAbstract.FANS, p.getFans()); if (p.getHp() > 0) ret.put(JudgeAbstract.IS_ALIVE, JudgeAbstract.ALIVE); else ret.put(JudgeAbstract.IS_ALIVE, JudgeAbstract.DEAD); ret.put(JudgeAbstract.HEALTH, Math.max(p.getHp(), 0)); } return ret; }
@Override public void getGift(GameObjectID player) throws BozorgExceptionBase { Player p = (Player) objects.get(player.getNumber()); if (p.getHp() == 0) throw new BozorgExceptionBase(); if (getMapCellType(p.x, p.y, player) != BONUS_CELL) throw new BozorgExceptionBase(); for (Player x : Judge.players) { if (x.equals(p)) continue; if (x.x == p.x && x.y == p.y) throw new BozorgExceptionBase(); } int t = map.getMap()[p.x][p.y].getType(); if (t == JUMP_CELL) { p.setJump(p.getJump() + 2000); } if (t == SPEEDUP_CELL) { p.setSpeed(p.getSpeed() + 5000); } if (t == STONE_CELL) { p.setStun(p.getStun() + 3000); } if (t == FAN_CELL) { p.setFans(p.getFans() + 3); } if (t == RADAR_CELL) { p.setVision(p.getVision() + 3000); } if (t == HOSPITAL_CELL) { p.setHp(Math.min(p.getHp() + 20, 100)); } map.getMap()[p.x][p.y].setType(0); }
@Override public void attack(GameObjectID attacker, int direction) throws BozorgExceptionBase { Player p = (Player) objects.get(attacker.getNumber()); int w = map.getMap()[p.x][p.y].getWalls(); if (p.getHp() == 0) throw new BozorgExceptionBase(); if (direction < 0 || direction > 4) throw new BozorgExceptionBase(); if ((w >> direction) % 2 == 1) throw new BozorgExceptionBase(); if (p.getAttackTime() > 0) throw new BozorgExceptionBase(); p.setAttackTime(p.getSpeed() + p.getAttackTime()); p.setAttackDir(direction); }