Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void castDamagingSpell(DamagingSpell s, Direction d) throws IOException {
- useSpell(s);
- Point p = getTargetPoint(d);
- Cell cell = getMap()[p.x][p.y];
- if (cell instanceof ObstacleCell) {
- ObstacleCell obs = ((ObstacleCell) (cell));
- int damage = s.getDamageAmount();
- if (obs.getObstacle().getHp() - damage <= 0) {
- obs.getObstacle().setHp(0);
- getMap()[p.x][p.y] = new EmptyCell();
- } else
- obs.getObstacle().setHp(obs.getObstacle().getHp() - damage);
- }
- if (cell instanceof ChampionCell) {
- ChampionCell chmp = (ChampionCell) cell;
- Wizard wiz = (Wizard) chmp.getChamp();
- if(wiz instanceof HufflepuffWizard){
- wiz.setHp(wiz.getHp() - (s.getDamageAmount()/2));
- if (wiz.getHp() <= 0) {
- getMap()[p.x][p.y] = new EmptyCell();
- this.getChampions().remove(wiz);
- }
- }
- else{
- wiz.setHp(wiz.getHp() - s.getDamageAmount());
- if (wiz.getHp() <= 0) {
- getMap()[p.x][p.y] = new EmptyCell();
- this.getChampions().remove(wiz);
- }
- }
- }
- this.finalizeAction();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement