Search in sources :

Example 1 with SoldierToken

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

the class AllianceOfArmsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int xSum = 0;
        xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            if (!Objects.equals(playerId, controller.getId())) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
                }
            }
        }
        if (xSum > 0) {
            for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
                effect.setTargetPointer(new FixedTarget(playerId));
                effect.apply(game, source);
            }
        }
        // prevent undo
        controller.resetStoredBookmark(game);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SoldierToken(mage.game.permanent.token.SoldierToken) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 2 with SoldierToken

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

the class DecreeOfJusticeCycleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || !player.chooseUse(Outcome.Benefit, "Pay {X} to create X tokens?", source, game)) {
        return false;
    }
    int payCount = ManaUtil.playerPaysXGenericMana(true, "Decree of Justice", player, source, game);
    if (payCount > 0) {
        return new SoldierToken().putOntoBattlefield(payCount, game, source, source.getControllerId());
    }
    return false;
}
Also used : SoldierToken(mage.game.permanent.token.SoldierToken) Player(mage.players.Player)

Example 3 with SoldierToken

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

the class ThroneOfEmpiresEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean scepter = false;
    boolean crown = false;
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
        if (permanent.getName().equals("Scepter of Empires")) {
            scepter = true;
        } else if (permanent.getName().equals("Crown of Empires")) {
            crown = true;
        }
        if (scepter && crown)
            break;
    }
    Token soldier = new SoldierToken();
    int count = scepter && crown ? 5 : 1;
    soldier.putOntoBattlefield(count, game, source, source.getControllerId());
    return false;
}
Also used : SoldierToken(mage.game.permanent.token.SoldierToken) Permanent(mage.game.permanent.Permanent) SoldierToken(mage.game.permanent.token.SoldierToken) Token(mage.game.permanent.token.Token)

Example 4 with SoldierToken

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

the class EntrapmentManeuverSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player == null) {
        return false;
    }
    FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
    filter.add(AttackingPredicate.instance);
    int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
    if (realCount > 0) {
        Target target = new TargetControlledPermanent(1, 1, filter, true);
        while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) {
            player.chooseTarget(Outcome.Sacrifice, target, source, game);
        }
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            int amount = permanent.getToughness().getValue();
            permanent.sacrifice(source, game);
            new CreateTokenEffect(new SoldierToken(), amount).apply(game, source);
        } else {
            return false;
        }
    }
    return true;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SoldierToken(mage.game.permanent.token.SoldierToken) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 5 with SoldierToken

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

the class TimelyReinforcementsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        boolean lessCreatures = false;
        boolean lessLife = false;
        FilterPermanent filter = new FilterCreaturePermanent();
        int count = game.getBattlefield().countAll(filter, controller.getId(), game);
        for (UUID uuid : game.getOpponents(controller.getId())) {
            Player opponent = game.getPlayer(uuid);
            if (opponent != null) {
                if (opponent.getLife() > controller.getLife()) {
                    lessLife = true;
                }
                if (game.getBattlefield().countAll(filter, uuid, game) > count) {
                    lessCreatures = true;
                }
            }
            if (lessLife && lessCreatures) {
                // no need to search further
                break;
            }
        }
        if (lessLife) {
            controller.gainLife(6, game, source);
        }
        if (lessCreatures) {
            Effect effect = new CreateTokenEffect(new SoldierToken(), 3);
            effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : SoldierToken(mage.game.permanent.token.SoldierToken) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) UUID(java.util.UUID)

Aggregations

SoldierToken (mage.game.permanent.token.SoldierToken)7 Permanent (mage.game.permanent.Permanent)4 Player (mage.players.Player)4 UUID (java.util.UUID)3 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 Effect (mage.abilities.effects.Effect)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)1 TwoChoiceVote (mage.choices.TwoChoiceVote)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 Token (mage.game.permanent.token.Token)1 Target (mage.target.Target)1 TargetPlayer (mage.target.TargetPlayer)1 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1