package net.demilich.metastone.game.spells; import java.util.Map; import net.demilich.metastone.game.Attribute; import net.demilich.metastone.game.GameContext; import net.demilich.metastone.game.Player; import net.demilich.metastone.game.entities.Entity; import net.demilich.metastone.game.entities.minions.Minion; import net.demilich.metastone.game.spells.desc.SpellArg; import net.demilich.metastone.game.spells.desc.SpellDesc; import net.demilich.metastone.game.targeting.EntityReference; public class SwapAttackAndHpSpell extends Spell { public static SpellDesc create() { return create(null); } public static SpellDesc create(EntityReference target) { Map<SpellArg, Object> arguments = SpellDesc.build(SwapAttackAndHpSpell.class); arguments.put(SpellArg.TARGET, target); return new SpellDesc(arguments); } @Override protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) { Minion minion = (Minion) target; int attack = minion.getAttack(); int hp = minion.getHp(); minion.removeAttribute(Attribute.TEMPORARY_ATTACK_BONUS); minion.removeAttribute(Attribute.ATTACK_BONUS); minion.removeAttribute(Attribute.HP_BONUS); minion.setAttack(hp); context.getLogic().modifyMaxHp(minion, attack); } }