Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public void castDamagingSpell(DamagingSpell s, Direction d) throws IOException {
  2. useSpell(s);
  3. Point p = getTargetPoint(d);
  4. Cell cell = getMap()[p.x][p.y];
  5. if (cell instanceof ObstacleCell) {
  6. ObstacleCell obs = ((ObstacleCell) (cell));
  7. int damage = s.getDamageAmount();
  8. if (obs.getObstacle().getHp() - damage <= 0) {
  9. obs.getObstacle().setHp(0);
  10. getMap()[p.x][p.y] = new EmptyCell();
  11. } else
  12. obs.getObstacle().setHp(obs.getObstacle().getHp() - damage);
  13. }
  14. if (cell instanceof ChampionCell) {
  15.  
  16. ChampionCell chmp = (ChampionCell) cell;
  17.  
  18. Wizard wiz = (Wizard) chmp.getChamp();
  19. if(wiz instanceof HufflepuffWizard){
  20. wiz.setHp(wiz.getHp() - (s.getDamageAmount()/2));
  21. if (wiz.getHp() <= 0) {
  22. getMap()[p.x][p.y] = new EmptyCell();
  23. this.getChampions().remove(wiz);
  24. }
  25. }
  26. else{
  27. wiz.setHp(wiz.getHp() - s.getDamageAmount());
  28. if (wiz.getHp() <= 0) {
  29. getMap()[p.x][p.y] = new EmptyCell();
  30. this.getChampions().remove(wiz);
  31. }
  32. }
  33. }
  34. this.finalizeAction();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement