Search in sources :

Example 51 with Token

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

the class HungryForMoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new HungryForMoreVampireToken();
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect().setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).collect(Collectors.toList()), game)).setText("sacrifice that token")), source);
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FixedTargets(mage.target.targetpointer.FixedTargets) HungryForMoreVampireToken(mage.game.permanent.token.HungryForMoreVampireToken) Token(mage.game.permanent.token.Token) HungryForMoreVampireToken(mage.game.permanent.token.HungryForMoreVampireToken) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 52 with Token

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

the class MarathWillOfTheWildRemoveCountersCost method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        int amount = ManacostVariableValue.REGULAR.calculate(game, source, this);
        Token token = new MarathWillOfTheWildElementalToken();
        token.getPower().modifyBaseValue(amount);
        token.getToughness().modifyBaseValue(amount);
        token.putOntoBattlefield(1, game, source, source.getControllerId());
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Token(mage.game.permanent.token.Token) MarathWillOfTheWildElementalToken(mage.game.permanent.token.MarathWillOfTheWildElementalToken) MarathWillOfTheWildElementalToken(mage.game.permanent.token.MarathWillOfTheWildElementalToken)

Example 53 with Token

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

the class OversimplifyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game);
    Map<UUID, Integer> playerMap = permanents.stream().filter(Objects::nonNull).collect(Collectors.toMap(Controllable::getControllerId, p -> p.getPower().getValue(), Integer::sum));
    controller.moveCards(new CardsImpl(permanents), Zone.EXILED, source, game);
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Token token = new FractalToken();
        token.putOntoBattlefield(1, game, source, playerId);
        int counter = playerMap.getOrDefault(playerId, 0);
        for (UUID tokenId : token.getLastAddedTokenIds()) {
            Permanent permanent = game.getPermanent(tokenId);
            if (permanent != null) {
                permanent.addCounters(CounterType.P1P1.createInstance(counter), playerId, source, game);
            }
        }
    }
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) Zone(mage.constants.Zone) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) FractalToken(mage.game.permanent.token.FractalToken) Controllable(mage.game.Controllable) Collectors(java.util.stream.Collectors) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) Game(mage.game.Game) List(java.util.List) Token(mage.game.permanent.token.Token) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) Map(java.util.Map) CardType(mage.constants.CardType) CounterType(mage.counters.CounterType) Ability(mage.abilities.Ability) FractalToken(mage.game.permanent.token.FractalToken) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FractalToken(mage.game.permanent.token.FractalToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl)

Example 54 with Token

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

the class RiseOfTheHobgoblinsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player you = game.getPlayer(source.getControllerId());
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    if (you != null && you.chooseUse(Outcome.Neutral, "Do you want to to pay {X}?", source, game)) {
        int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
        cost.add(new GenericManaCost(costX));
        if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
            Token token = new GoblinSoldierToken();
            return token.putOntoBattlefield(costX, game, source, source.getControllerId());
        }
    }
    return false;
}
Also used : GoblinSoldierToken(mage.game.permanent.token.GoblinSoldierToken) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) GoblinSoldierToken(mage.game.permanent.token.GoblinSoldierToken) Token(mage.game.permanent.token.Token) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 55 with Token

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

the class WarrenWeirdingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player == null) {
        return false;
    }
    FilterControlledPermanent filter = new FilterControlledPermanent("creature");
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ControllerIdPredicate(player.getId()));
    TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
    // had, if thats the case this ability should fizzle.
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            permanent.sacrifice(source, game);
            if (filterGoblin.match(permanent, game)) {
                for (int i = 0; i < 2; i++) {
                    Token token = new GoblinRogueToken();
                    Effect effect = new CreateTokenTargetEffect(token);
                    effect.setTargetPointer(new FixedTarget(player.getId()));
                    if (effect.apply(game, source)) {
                        Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
                        if (tokenPermanent != null) {
                            ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                            hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
                            game.addEffect(hasteEffect, source);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) Token(mage.game.permanent.token.Token) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

Token (mage.game.permanent.token.Token)68 Permanent (mage.game.permanent.Permanent)30 Player (mage.players.Player)29 UUID (java.util.UUID)28 FixedTargets (mage.target.targetpointer.FixedTargets)9 Map (java.util.Map)7 Effect (mage.abilities.effects.Effect)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)6 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)6 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)5 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)5 TargetPermanent (mage.target.TargetPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 FilterPermanent (mage.filter.FilterPermanent)4 CreateTokenEvent (mage.game.events.CreateTokenEvent)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Objects (java.util.Objects)3