package com.hearthsim.card.spellcard.concrete;

import com.hearthsim.card.Deck;
import com.hearthsim.card.minion.Minion;
import com.hearthsim.card.spellcard.SpellCard;
import com.hearthsim.exception.HSException;
import com.hearthsim.model.PlayerSide;
import com.hearthsim.util.tree.HearthTreeNode;

public class HolyNova extends SpellCard {


	/**
	 * Constructor
	 * 
	 * @param hasBeenUsed Whether the card has already been used or not
	 */
	public HolyNova(boolean hasBeenUsed) {
		super((byte)5, hasBeenUsed);
	}

	/**
	 * Constructor
	 * 
	 * Defaults to hasBeenUsed = false
	 */
	public HolyNova() {
		this(false);
	}

	@Override
	public SpellCard deepCopy() {
		return new HolyNova(this.hasBeenUsed);
	}

	/**
	 * 
	 * Use the card on the given target
	 * 
	 * Deal 2 damage to all enemy characters and heal all friendly characters by 2
	 * 
	 *
     *
     * @param side
     * @param boardState The BoardState before this card has performed its action.  It will be manipulated and returned.
     *
     * @return The boardState is manipulated and returned
	 */
	@Override
	protected HearthTreeNode use_core(
			PlayerSide side,
			Minion targetMinion,
			HearthTreeNode boardState,
			Deck deckPlayer0,
			Deck deckPlayer1,
			boolean singleRealizationOnly)
		throws HSException
	{
		if (isCurrentPlayer(side)) {
			return null;
		}
		
		if (isNotHero(targetMinion)) {
			return null;
		}
		
		HearthTreeNode toRet = super.use_core(side, targetMinion, boardState, deckPlayer0, deckPlayer1, singleRealizationOnly);
		if (toRet != null) {
			toRet = toRet.data_.getCurrentPlayerHero().takeHeal((byte)2, PlayerSide.CURRENT_PLAYER, toRet, deckPlayer0, deckPlayer1);
			for (Minion minion : PlayerSide.CURRENT_PLAYER.getPlayer(toRet).getMinions()) {
				toRet = minion.takeHeal((byte)2, PlayerSide.CURRENT_PLAYER, toRet, deckPlayer0, deckPlayer1);
			}
			
			toRet = toRet.data_.getWaitingPlayerHero().takeDamage((byte)2, PlayerSide.CURRENT_PLAYER, PlayerSide.WAITING_PLAYER, toRet, deckPlayer0, deckPlayer1, true, false);
			for (Minion minion : PlayerSide.WAITING_PLAYER.getPlayer(toRet).getMinions()) {
				toRet = minion.takeDamage((byte)2, PlayerSide.CURRENT_PLAYER, PlayerSide.WAITING_PLAYER, toRet, deckPlayer0, deckPlayer1, true, false);
			}
		}
		return toRet;
	}
}

@@ -155,20 +155,25 @@
 rd.Spell
-Card
+DamageAoe
 ;%0Aimport
@@ -336,15 +336,66 @@
 pell
-Card %7B%0A
+DamageAoe %7B%0A%0A%09private static final byte DAMAGE_AMOUNT = 2;
 %0A%0A%09/
@@ -549,28 +549,110 @@
 byte)5, 
-hasBeenUsed)
+DAMAGE_AMOUNT, hasBeenUsed);%0A%09%09this.targetOpponent = true;%0A%09%09this.targetOpponentMinions = true
 ;%0A%09%7D%0A%0A%09/
@@ -666,29 +666,24 @@
 Constructor%0A
-%09 * %0A
 %09 * Defaults
@@ -756,103 +756,11 @@
 %7D%0A%0A%09
-@Override%0A%09public SpellCard deepCopy() %7B%0A%09%09return new HolyNova(this.hasBeenUsed);%0A%09%7D%0A%0A%09/**%0A%09 * 
+/**
 %0A%09 *
@@ -793,21 +793,16 @@
  target%0A
-%09 * %0A
 %09 * Deal
@@ -881,30 +881,16 @@
 %09 * %0A%09 *
-%0A     *%0A     *
  @param 
@@ -894,20 +894,17 @@
 am side%0A
-    
+%09
  * @para
@@ -973,17 +973,16 @@
  action.
- 
  It will
@@ -1015,19 +1015,9 @@
 ed.%0A
-     *%0A    
+%09
  * @
@@ -1117,20 +1117,16 @@
 se_core(
-%0A%09%09%09
 PlayerSi
@@ -1133,20 +1133,17 @@
 de side,
-%0A%09%09%09
+ 
 Minion t
@@ -1154,20 +1154,17 @@
 tMinion,
-%0A%09%09%09
+ 
 HearthTr
@@ -1202,20 +1202,17 @@
 Player0,
-%0A%09%09%09
+ 
 Deck dec
@@ -1220,20 +1220,17 @@
 Player1,
-%0A%09%09%09
+ 
 boolean 
@@ -1251,19 +1251,17 @@
 ionOnly)
-%0A%09%09
+ 
 throws H
@@ -1274,121 +1274,11 @@
 tion
-%0A%09%7B%0A%09%09if (isCurrentPlayer(side)) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09%0A%09%09if (isNotHero(targetMinion)) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09
+ %7B%0A
 %0A%09%09H
@@ -1371,17 +1371,21 @@
 Player1,
- 
+%0A%09%09%09%09
 singleRe
@@ -1404,13 +1404,13 @@
 y);%0A
+%0A
 %09%09if
- 
 (toR
@@ -1525,33 +1525,38 @@
 et, deckPlayer0,
- 
+%0A%09%09%09%09%09
 deckPlayer1);%0A%09%09
@@ -1551,33 +1551,32 @@
 Player1);%0A%09%09%09for
- 
 (Minion minion :
@@ -1742,407 +1742,8 @@
 %09%09%7D%0A
-%09%09%09%0A%09%09%09toRet = toRet.data_.getWaitingPlayerHero().takeDamage((byte)2, PlayerSide.CURRENT_PLAYER, PlayerSide.WAITING_PLAYER, toRet, deckPlayer0, deckPlayer1, true, false);%0A%09%09%09for (Minion minion : PlayerSide.WAITING_PLAYER.getPlayer(toRet).getMinions()) %7B%0A%09%09%09%09toRet = minion.takeDamage((byte)2, PlayerSide.CURRENT_PLAYER, PlayerSide.WAITING_PLAYER, toRet, deckPlayer0, deckPlayer1, true, false);%0A%09%09%09%7D%0A
 %09%09%7D%0A

Convert HolyNova to SpellDamageAoe