mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Ghostly Flicker - Reworked effect code.
This commit is contained in:
parent
9b14795032
commit
d42190e307
1 changed files with 21 additions and 17 deletions
|
@ -27,12 +27,16 @@
|
|||
*/
|
||||
package mage.cards.g;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
|
@ -40,10 +44,9 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
|
@ -59,8 +62,7 @@ public class GhostlyFlicker extends CardImpl {
|
|||
}
|
||||
|
||||
public GhostlyFlicker(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
|
||||
|
||||
// Exile two target artifacts, creatures, and/or lands you control, then return those cards to the battlefield under your control.
|
||||
this.getSpellAbility().addTarget(new TargetControlledPermanent(2, 2, filter, false));
|
||||
|
@ -95,20 +97,22 @@ class GhostlyFlickerEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
UUID exileId = source.getSourceId();
|
||||
for (UUID permanentId : targetPointer.getTargets(game, source)) {
|
||||
Permanent target = game.getPermanent(permanentId);
|
||||
if (target != null) {
|
||||
target.moveToExile(exileId, "Ghostly Flicker", source.getSourceId(), game);
|
||||
Card card = game.getCard(target.getId());
|
||||
if (card != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
UUID exileId = UUID.randomUUID();
|
||||
Set<Card> toExile = new HashSet<>();
|
||||
for (UUID permanentId : targetPointer.getTargets(game, source)) {
|
||||
Permanent target = game.getPermanent(permanentId);
|
||||
if (target != null) {
|
||||
toExile.add(target);
|
||||
}
|
||||
}
|
||||
controller.moveCardsToExile(toExile, source, game, true, exileId, sourceObject.getIdName());
|
||||
game.applyEffects();
|
||||
controller.moveCards(game.getExile().getExileZone(exileId).getCards(game), Zone.BATTLEFIELD, source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue