Search in sources :

Example 6 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class CurseOfDisturbanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new CreateTokenTargetEffect(new ZombieToken());
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 7 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class KalitasTraitorOfGhetEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
            Permanent permanent = ((ZoneChangeEvent) event).getTarget();
            if (permanent != null) {
                controller.moveCards(permanent, Zone.EXILED, source, game);
                new CreateTokenEffect(new ZombieToken()).apply(game, source);
                return true;
            }
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 8 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class SyphonFleshEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<UUID> perms = new ArrayList<>();
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null && !playerId.equals(source.getControllerId())) {
                TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
                target.setNotTarget(true);
                if (target.canChoose(source.getSourceId(), player.getId(), game)) {
                    player.chooseTarget(Outcome.Sacrifice, target, source, game);
                    perms.addAll(target.getTargets());
                }
            }
        }
        for (UUID permID : perms) {
            Permanent permanent = game.getPermanent(permID);
            if (permanent != null) {
                permanent.sacrifice(source, game);
            }
        }
        int sacrificedAmount = perms.isEmpty() ? 0 : perms.size();
        if (sacrificedAmount > 0) {
            ZombieToken token = new ZombieToken();
            token.putOntoBattlefield(sacrificedAmount, game, source, source.getControllerId());
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ArrayList(java.util.ArrayList) UUID(java.util.UUID) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 9 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class AcererakTheArchlichEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int tokens = 0;
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        tokens++;
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        TargetPermanent target = new TargetControlledCreaturePermanent(0, 1);
        target.setNotTarget(true);
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null && permanent.sacrifice(source, game)) {
            tokens--;
        }
    }
    if (tokens > 0) {
        new ZombieToken().putOntoBattlefield(tokens, game, source, source.getControllerId());
    }
    return true;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 10 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class CurseOfShallowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player attacker = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (attacker != null && attacker.chooseUse(outcome, "create a tapped 2/2 black Zombie creature token?", source, game)) {
        Effect effect = new CreateTokenTargetEffect(new ZombieToken(), StaticValue.get(1), true, false);
        effect.setTargetPointer(targetPointer);
        return effect.apply(game, source);
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect)

Aggregations

ZombieToken (mage.game.permanent.token.ZombieToken)11 Player (mage.players.Player)11 UUID (java.util.UUID)5 Permanent (mage.game.permanent.Permanent)5 TargetPlayer (mage.target.TargetPlayer)4 Effect (mage.abilities.effects.Effect)3 OneShotEffect (mage.abilities.effects.OneShotEffect)3 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)3 HashSet (java.util.HashSet)2 AttachEffect (mage.abilities.effects.common.AttachEffect)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)2 Card (mage.cards.Card)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 FilterCard (mage.filter.FilterCard)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1