Search in sources :

Example 1 with TreasureToken

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

the class TreasureMapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        player.scry(1, source, game);
        if (permanent != null) {
            permanent.addCounters(CounterType.LANDMARK.createInstance(), source.getControllerId(), source, game);
            int counters = permanent.getCounters(game).getCount(CounterType.LANDMARK);
            if (counters > 2) {
                permanent.removeCounters("landmark", counters, source, game);
                new TransformSourceEffect().apply(game, source);
                new CreateTokenEffect(new TreasureToken(), 3).apply(game, source);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken)

Example 2 with TreasureToken

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

the class BucknardsEverfullPurseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    new TreasureToken().putOntoBattlefield(player.rollDice(outcome, source, game, 4), game, source, source.getControllerId());
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return true;
    }
    UUID playerToRightId = game.getState().getPlayersInRange(source.getControllerId(), game).stream().reduce((u1, u2) -> u2).orElse(null);
    if (playerToRightId == null) {
        return false;
    }
    game.addEffect(new GainControlTargetEffect(Duration.Custom, true, playerToRightId).setTargetPointer(new FixedTarget(permanent, game)), source);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Duration(mage.constants.Duration) Game(mage.game.Game) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) TreasureToken(mage.game.permanent.token.TreasureToken) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 3 with TreasureToken

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

the class CulminationOfStudiesEffect 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(player.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
    player.moveCards(cards, Zone.EXILED, source, game);
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
    int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game);
    int blueCards = cards.count(filterBlue, game);
    int redCards = cards.count(filterRed, game);
    if (landCards > 0) {
        new TreasureToken().putOntoBattlefield(landCards, game, source, source.getControllerId());
    }
    if (blueCards > 0) {
        player.drawCards(blueCards, source, game);
    }
    if (redCards > 0) {
        new DamagePlayersEffect(redCards, TargetController.OPPONENT).apply(game, source);
    }
    return true;
}
Also used : Player(mage.players.Player) TreasureToken(mage.game.permanent.token.TreasureToken) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 4 with TreasureToken

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

the class ExcavationTechniqueEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.destroy(source, game, false);
    new TreasureToken().putOntoBattlefield(2, game, source, permanent.getControllerId());
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) TreasureToken(mage.game.permanent.token.TreasureToken)

Example 5 with TreasureToken

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

the class InstrumentOfTheBardsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller == null || permanent == null) {
        return false;
    }
    int counters = permanent.getCounters(game).getCount(CounterType.HARMONY);
    FilterCreatureCard filter = new FilterCreatureCard("creature card with mana value " + counters);
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, counters));
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    if (controller.searchLibrary(target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.revealCards(permanent.getIdName(), new CardsImpl(card), game);
            controller.moveCards(card, Zone.HAND, source, game);
            if (card.isLegendary()) {
                new TreasureToken().putOntoBattlefield(1, game, source, source.getControllerId());
            }
        }
    }
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) TreasureToken(mage.game.permanent.token.TreasureToken) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Aggregations

TreasureToken (mage.game.permanent.token.TreasureToken)17 Player (mage.players.Player)12 Permanent (mage.game.permanent.Permanent)9 UUID (java.util.UUID)4 Token (mage.game.permanent.token.Token)4 TargetPermanent (mage.target.TargetPermanent)3 HashSet (java.util.HashSet)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 CreateTokenEvent (mage.game.events.CreateTokenEvent)2 FoodToken (mage.game.permanent.token.FoodToken)2 Map (java.util.Map)1 Ability (mage.abilities.Ability)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 Cost (mage.abilities.costs.Cost)1 TapSourceCost (mage.abilities.costs.common.TapSourceCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DamagePlayersEffect (mage.abilities.effects.common.DamagePlayersEffect)1