Search in sources :

Example 46 with CreateTokenEffect

use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.

the class NotoriousThrongEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class);
    if (controller != null && watcher != null) {
        int numTokens = 0;
        for (UUID opponentId : game.getOpponents(controller.getId())) {
            numTokens += watcher.getAmountOfDamageReceivedThisTurn(opponentId);
        }
        if (numTokens > 0) {
            new CreateTokenEffect(new FaerieRogueToken(), numTokens).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) AmountOfDamageAPlayerReceivedThisTurnWatcher(mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher) FaerieRogueToken(mage.game.permanent.token.FaerieRogueToken) UUID(java.util.UUID) ProwlCostWasPaidHint(mage.abilities.hint.common.ProwlCostWasPaidHint)

Example 47 with CreateTokenEffect

use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.

the class RithTheAwakenerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (controller.choose(outcome, choice, game)) {
        game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
        if (cardsWithColor > 0) {
            new CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) SaprolingToken(mage.game.permanent.token.SaprolingToken) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 48 with CreateTokenEffect

use of mage.abilities.effects.common.CreateTokenEffect 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)

Example 49 with CreateTokenEffect

use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.

the class ElementalMasteryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creatureAttached = game.getPermanent(source.getSourceId());
    if (creatureAttached != null) {
        int power = creatureAttached.getPower().getValue();
        if (power > 0) {
            CreateTokenEffect effect = new CreateTokenEffect(new ElementalMasteryElementalToken(), power);
            effect.apply(game, source);
            effect.exileTokensCreatedAtNextEndStep(game, source);
            return true;
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ElementalMasteryElementalToken(mage.game.permanent.token.ElementalMasteryElementalToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 50 with CreateTokenEffect

use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.

the class KirinTouchedOrochiCounterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    UUID targetId = source.getFirstTarget();
    Card card = game.getCard(targetId);
    if (controller == null || card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
        return false;
    }
    if (!controller.moveCards(card, Zone.EXILED, source, game)) {
        return false;
    }
    ReflexiveTriggeredAbility reflexiveTokenAbility = new ReflexiveTriggeredAbility(new CreateTokenEffect(new SpiritToken()), false);
    game.fireReflexiveTriggeredAbility(reflexiveTokenAbility, source);
    return true;
}
Also used : Player(mage.players.Player) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) SpiritToken(mage.game.permanent.token.SpiritToken) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterNoncreatureCard(mage.filter.common.FilterNoncreatureCard)

Aggregations

CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)68 Player (mage.players.Player)45 Permanent (mage.game.permanent.Permanent)31 UUID (java.util.UUID)25 FixedTarget (mage.target.targetpointer.FixedTarget)11 OneShotEffect (mage.abilities.effects.OneShotEffect)8 Effect (mage.abilities.effects.Effect)7 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)7 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)5 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)4 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)4 Cost (mage.abilities.costs.Cost)4 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)4 HashSet (java.util.HashSet)3 MageObjectReference (mage.MageObjectReference)3 Ability (mage.abilities.Ability)3 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)3