Search in sources :

Example 16 with TreasureToken

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

the class VisionsOfRuinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Set<Permanent> permanents = new HashSet<>();
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null || game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, source.getSourceId(), playerId, game) < 1) {
            continue;
        }
        TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT);
        target.setNotTarget(true);
        opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        permanents.add(game.getPermanent(target.getFirstTarget()));
    }
    int sacrificed = 0;
    for (Permanent permanent : permanents) {
        if (permanent != null && permanent.sacrifice(source, game)) {
            sacrificed++;
        }
    }
    if (sacrificed > 0) {
        new TreasureToken().putOntoBattlefield(sacrificed, game, source, source.getControllerId());
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TreasureToken(mage.game.permanent.token.TreasureToken) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 17 with TreasureToken

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

the class AcademyManufactorEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    int amount = 0;
    Map<Token, Integer> tokens = ((CreateTokenEvent) event).getTokens();
    for (Iterator<Map.Entry<Token, Integer>> iter = tokens.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry<Token, Integer> entry = iter.next();
        Token token = entry.getKey();
        if (token.hasSubtype(SubType.CLUE, game) || token.hasSubtype(SubType.FOOD, game) || token.hasSubtype(SubType.TREASURE, game)) {
            amount += entry.getValue();
            iter.remove();
        }
    }
    tokens.put(new ClueArtifactToken(), amount);
    tokens.put(new FoodToken(), amount);
    tokens.put(new TreasureToken(), amount);
    return false;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) TreasureToken(mage.game.permanent.token.TreasureToken) FoodToken(mage.game.permanent.token.FoodToken) ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Token(mage.game.permanent.token.Token) TreasureToken(mage.game.permanent.token.TreasureToken) Map(java.util.Map) CreateTokenEvent(mage.game.events.CreateTokenEvent) FoodToken(mage.game.permanent.token.FoodToken)

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