Search in sources :

Example 1 with FractalToken

use of mage.game.permanent.token.FractalToken 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 2 with FractalToken

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

the class EmergentSequenceWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    // put land
    TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A);
    player.searchLibrary(target, source, game);
    Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
    Permanent permanent = null;
    if (card != null) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
        permanent = game.getPermanent(target.getFirstTarget());
    }
    player.shuffleLibrary(source, game);
    if (permanent == null) {
        return true;
    }
    // boost land
    game.addEffect(new BecomesCreatureTargetEffect(new FractalToken(), false, true, Duration.Custom).setTargetPointer(new FixedTarget(permanent, game)), source);
    // rules
    // The last sentence of Emergent Sequence’s ability counts the land it put onto the battlefield.
    // (2021-04-16)
    // no ETB yet, so add +1 manually
    int amount = 1 + EmergentSequenceWatcher.getAmount(source.getControllerId(), game);
    permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FractalToken(mage.game.permanent.token.FractalToken) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Hint(mage.abilities.hint.Hint) Card(mage.cards.Card)

Example 3 with FractalToken

use of mage.game.permanent.token.FractalToken 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)

Aggregations

Permanent (mage.game.permanent.Permanent)3 FractalToken (mage.game.permanent.token.FractalToken)3 UUID (java.util.UUID)2 Token (mage.game.permanent.token.Token)2 Player (mage.players.Player)2 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Ability (mage.abilities.Ability)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 BecomesCreatureTargetEffect (mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect)1 Hint (mage.abilities.hint.Hint)1 Card (mage.cards.Card)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1 CardsImpl (mage.cards.CardsImpl)1 CardType (mage.constants.CardType)1 Outcome (mage.constants.Outcome)1 Zone (mage.constants.Zone)1