* Curse of the Swine - Reworked card movement and token creation.
*/
package mage.cards.c;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
+import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.CurseOfTheSwineBoarToken;
+import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
@@ -58,7 +62,7 @@ public class CurseOfTheSwine extends CardImpl {
@Override
public void adjustTargets(Ability ability, Game game) {
- if (ability instanceof SpellAbility) {
+ if (ability instanceof SpellAbility && ability.getAbilityType().equals(AbilityType.SPELL)) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
@@ -92,15 +96,24 @@ class CurseOfTheSwineEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
+ Player controller = game.getPlayer(source.getControllerId());
+ if (controller != null) {
+ Map<UUID, Integer> playersWithTargets = new HashMap<>();
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
Permanent creature = game.getPermanent(targetId);
if (creature != null) {
- if (creature.moveToExile(null, null, source.getSourceId(), game) || creature.moveToZone(Zone.COMMAND, source.getSourceId(), game, false)) {
- CurseOfTheSwineBoarToken swineToken = new CurseOfTheSwineBoarToken();
- swineToken.putOntoBattlefield(1, game, source.getSourceId(), creature.getControllerId());
+ if (controller.moveCards(creature, Zone.EXILED, source, game)) {
+ playersWithTargets.put(creature.getControllerId(), playersWithTargets.getOrDefault(creature.getControllerId(), 0) + 1);
+ }
}
}
+ CurseOfTheSwineBoarToken swineToken = new CurseOfTheSwineBoarToken();
+ for (UUID playerId : playersWithTargets.keySet()) {
+ swineToken.putOntoBattlefield(playersWithTargets.get(playerId), game, source.getSourceId(), playerId);
}
return true;
}
+ return false;
+
+ }
}
