Search in sources :

Example 1 with Elemental44Token

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

the class MultipleChoiceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    if (xValue == 1 || xValue >= 4) {
        controller.scry(1, source, game);
        controller.drawCards(1, source, game);
    }
    if (xValue == 3 || xValue >= 4) {
        new Elemental44Token().putOntoBattlefield(1, game, source, source.getControllerId());
    }
    if (xValue != 2 && xValue < 4) {
        return true;
    }
    TargetPlayer targetPlayer = new TargetPlayer(0, 1, true);
    controller.choose(Outcome.Detriment, targetPlayer, source.getSourceId(), game);
    Player player = game.getPlayer(targetPlayer.getFirstTarget());
    if (player == null || game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getSourceId(), player.getId(), game) <= 0) {
        return true;
    }
    TargetPermanent targetPermanent = new TargetControlledCreaturePermanent();
    targetPermanent.setNotTarget(true);
    player.choose(Outcome.ReturnToHand, targetPermanent, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget());
    return permanent == null || player.moveCards(permanent, Zone.HAND, source, game);
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) Elemental44Token(mage.game.permanent.token.Elemental44Token) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPlayer(mage.target.TargetPlayer)

Example 2 with Elemental44Token

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

the class WillScholarOfFrostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(targetPointer.getTargets(game, source));
    Map<UUID, Integer> playerMap = cards.getCards(game).stream().filter(Objects::nonNull).map(MageItem::getId).map(game::getControllerId).filter(Objects::nonNull).collect(Collectors.toMap(Function.identity(), x -> 1, Integer::sum));
    player.moveCards(cards, Zone.EXILED, source, game);
    for (Map.Entry<UUID, Integer> entry : playerMap.entrySet()) {
        new Elemental44Token().putOntoBattlefield(entry.getValue(), game, source, entry.getKey());
    }
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) Hint(mage.abilities.hint.Hint) Function(java.util.function.Function) MageItem(mage.MageItem) Player(mage.players.Player) RowanScholarOfSparksEmblem(mage.game.command.emblems.RowanScholarOfSparksEmblem) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Map(java.util.Map) ConditionalOneShotEffect(mage.abilities.decorator.ConditionalOneShotEffect) mage.constants(mage.constants) CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) FilterCard(mage.filter.FilterCard) StaticFilters(mage.filter.StaticFilters) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) Condition(mage.abilities.condition.Condition) Cards(mage.cards.Cards) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Elemental44Token(mage.game.permanent.token.Elemental44Token) Collectors(java.util.stream.Collectors) LoyaltyAbility(mage.abilities.LoyaltyAbility) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) Game(mage.game.Game) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect) SpellsCostReductionControllerEffect(mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect) GetEmblemEffect(mage.abilities.effects.common.GetEmblemEffect) TargetPermanent(mage.target.TargetPermanent) Ability(mage.abilities.Ability) Player(mage.players.Player) Objects(java.util.Objects) UUID(java.util.UUID) Map(java.util.Map) Elemental44Token(mage.game.permanent.token.Elemental44Token) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 3 with Elemental44Token

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

the class ZaffaiThunderConductorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.scry(1, source, game);
    Spell spell = (Spell) getValue(MagecraftAbility.SPELL_KEY);
    if (spell == null || spell.getManaValue() < 5) {
        return true;
    }
    new Elemental44Token().putOntoBattlefield(1, game, source, source.getControllerId());
    if (spell.getManaValue() < 10) {
        return true;
    }
    TargetOpponent target = new TargetOpponent(true);
    target.setRandom(true);
    target.chooseTarget(Outcome.Damage, player.getId(), source, game);
    Player opponent = game.getPlayer(target.getFirstTarget());
    if (opponent != null) {
        opponent.damage(10, source.getSourceId(), source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) Elemental44Token(mage.game.permanent.token.Elemental44Token) Spell(mage.game.stack.Spell)

Example 4 with Elemental44Token

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

the class ResculptEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(permanent.getControllerId());
    player.moveCards(permanent, Zone.EXILED, source, game);
    new Elemental44Token().putOntoBattlefield(1, game, source, player.getId());
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) Elemental44Token(mage.game.permanent.token.Elemental44Token)

Aggregations

Elemental44Token (mage.game.permanent.token.Elemental44Token)4 Player (mage.players.Player)4 TargetPermanent (mage.target.TargetPermanent)3 Permanent (mage.game.permanent.Permanent)2 Map (java.util.Map)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 MageItem (mage.MageItem)1 Ability (mage.abilities.Ability)1 LoyaltyAbility (mage.abilities.LoyaltyAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 Condition (mage.abilities.condition.Condition)1 ConditionalOneShotEffect (mage.abilities.decorator.ConditionalOneShotEffect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DamagePlayersEffect (mage.abilities.effects.common.DamagePlayersEffect)1 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)1 GetEmblemEffect (mage.abilities.effects.common.GetEmblemEffect)1 SetPowerToughnessTargetEffect (mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect)1