public int getManhattandistance(Point p, Point p2) { int distance = Math.abs((p.x) - (p2.x)) + Math.abs((p.y) - (p2.y)); return distance; } public Champion getcurrentChampion() { return (Champion) turnOrder.remove(); } public Player checkGameOver() { if (firstPlayer.getTeam() == null) { return secondPlayer; } if (secondPlayer.getTeam() == null) { return firstPlayer; } else return null; } public void move(Direction d) { getcurrentChampion().setCurrentActionPoints( getcurrentChampion().getCurrentActionPoints() - 1); if (d == Direction.RIGHT) { Point p = new Point(getcurrentChampion().getLocation().x, getcurrentChampion().getLocation().y + 1); getcurrentChampion().setLocation(p); } if (d == Direction.LEFT) { Point p = new Point(getcurrentChampion().getLocation().x, getcurrentChampion().getLocation().y - 1); getcurrentChampion().setLocation(p); } if (d == Direction.DOWN) { Point p = new Point(getcurrentChampion().getLocation().x + 1, getcurrentChampion().getLocation().y); getcurrentChampion().setLocation(p); } if (d == Direction.UP) { Point p = new Point(getcurrentChampion().getLocation().x - 1, getcurrentChampion().getLocation().y); getcurrentChampion().setLocation(p); } } public String checkType(Damageable x) { if (x instanceof Villain) return "Villain"; if (x instanceof Hero) return "Hero"; if (x instanceof AntiHero) return "AntiHero"; if (x instanceof Cover) return "Cover"; else return null; } // integer to float public void attack(Direction d) { Object x; int attackrange = getcurrentChampion().getAttackRange(); int attackdamage = getcurrentChampion().getAttackDamage(); String currentchampiontype = checkType(getcurrentChampion()); if (getcurrentChampion().getCurrentActionPoints() >= 2) { if (d == Direction.RIGHT) { for (int i = 0; i <= attackrange; i++) { x = board[getcurrentChampion().getLocation().x][getcurrentChampion() .getLocation().y + i]; switch (currentchampiontype) { case "Hero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Hero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "Villain": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "AntiHero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y + i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } } } } if (d == Direction.LEFT) { for (int i = 0; i <= attackrange; i++) { x = board[getcurrentChampion().getLocation().x][getcurrentChampion() .getLocation().y - i]; switch (currentchampiontype) { case "Hero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Hero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "Villain": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "AntiHero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x][getcurrentChampion() .getLocation().y - i]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } } } } if (d == Direction.DOWN) { for (int i = 0; i <= attackrange; i++) { x = board[getcurrentChampion().getLocation().x + i][getcurrentChampion() .getLocation().y]; switch (currentchampiontype) { case "Hero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Hero")) { ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "Villain": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "AntiHero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x + i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } } } } if (d == Direction.UP) { for (int i = 0; i <= attackrange; i++) { x = board[getcurrentChampion().getLocation().x - i][getcurrentChampion() .getLocation().y]; switch (currentchampiontype) { case "Hero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Hero")) { ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "Villain": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } case "AntiHero": if (x instanceof Damageable) if (checkType((Damageable) x).equals("Hero")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x) .getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("Villain")) { attackdamage = (int) (attackdamage * 1.5); ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } if (checkType((Damageable) x).equals("AntiHero")) { ((Champion) board[getcurrentChampion() .getLocation().x - i][getcurrentChampion() .getLocation().y]) .setCurrentHP(((Champion) x).getCurrentHp() - attackdamage); } } } } } //else throw NotEnoughResourcesException("You don't have enough action points"); }