Search in sources :

Example 1 with Token

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

the class BaruFistOfKrosaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = game.getBattlefield().countAll(filter, source.getControllerId(), game);
    Token token = new BaruFistOfKrosaToken(xValue);
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    return true;
}
Also used : Token(mage.game.permanent.token.Token) BaruFistOfKrosaToken(mage.game.permanent.token.BaruFistOfKrosaToken) BaruFistOfKrosaToken(mage.game.permanent.token.BaruFistOfKrosaToken)

Example 2 with Token

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

the class ChatterfangSquirrelGeneralReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    if (event instanceof CreateTokenEvent) {
        CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
        SquirrelToken squirrelToken = null;
        int amount = 0;
        Map<Token, Integer> tokens = tokenEvent.getTokens();
        for (Map.Entry<Token, Integer> entry : tokens.entrySet()) {
            amount += entry.getValue();
            if (entry.getKey() instanceof SquirrelToken) {
                squirrelToken = (SquirrelToken) entry.getKey();
            }
        }
        if (squirrelToken == null) {
            squirrelToken = new SquirrelToken();
        }
        tokens.put(squirrelToken, tokens.getOrDefault(squirrelToken, 0) + amount);
    }
    return false;
}
Also used : SquirrelToken(mage.game.permanent.token.SquirrelToken) Token(mage.game.permanent.token.Token) Map(java.util.Map) SquirrelToken(mage.game.permanent.token.SquirrelToken) CreateTokenEvent(mage.game.events.CreateTokenEvent)

Example 3 with Token

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

the class DinOfTheFireherdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean applied;
    Token token = new DinOfTheFireherdToken();
    applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
    int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
    int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetOpponent != null) {
        Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
        Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
        effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect2.apply(game, source);
        applied = true;
    }
    return applied;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) Token(mage.game.permanent.token.Token) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Example 4 with Token

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

the class FractalHarnessDoubleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new FractalToken();
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    int xValue = ManacostVariableValue.ETB.calculate(game, source, this);
    boolean flag = true;
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent permanent = game.getPermanent(tokenId);
        if (permanent == null) {
            continue;
        }
        if (flag && permanent.addAttachment(source.getSourceId(), source, game)) {
            flag = false;
        }
        permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
    }
    return true;
}
Also used : FractalToken(mage.game.permanent.token.FractalToken) Permanent(mage.game.permanent.Permanent) FractalToken(mage.game.permanent.token.FractalToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID)

Example 5 with Token

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

the class LoyalApprenticeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new ThopterColorlessToken();
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList()), game)), source);
    return true;
}
Also used : ThopterColorlessToken(mage.game.permanent.token.ThopterColorlessToken) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Objects(java.util.Objects) Token(mage.game.permanent.token.Token) ThopterColorlessToken(mage.game.permanent.token.ThopterColorlessToken)

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