Search in sources :

Example 11 with TreasureToken

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

the class SmotheringTitheEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player == null) {
        return false;
    }
    Cost cost = ManaUtil.createManaCost(2, false);
    if (!player.chooseUse(Outcome.Detriment, "Pay {2} to prevent this effect?", source, game) || !cost.pay(source, game, source, player.getId(), false)) {
        return new TreasureToken().putOntoBattlefield(1, game, source, source.getControllerId());
    }
    return false;
}
Also used : Player(mage.players.Player) TreasureToken(mage.game.permanent.token.TreasureToken) Cost(mage.abilities.costs.Cost)

Example 12 with TreasureToken

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

the class MalcolmKeenEyedNavigatorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new CreateTokenEffect(new TreasureToken(), opponents.size()));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 13 with TreasureToken

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

the class RecklessEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Integer> results = player.rollDice(outcome, source, game, 12, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && player.chooseUse(outcome, "Choose a number to deal damage to each creature", "The other number will be the amount of treasures you create", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
        permanent.damage(first, source.getSourceId(), source, game);
    }
    new TreasureToken().putOntoBattlefield(second, game, source, source.getControllerId());
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TreasureToken(mage.game.permanent.token.TreasureToken)

Example 14 with TreasureToken

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

the class RuthlessTechnomancerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || !game.getBattlefield().contains(StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, source, game, 1)) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(0, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null || !permanent.sacrifice(source, game)) {
        return false;
    }
    int power = permanent.getPower().getValue();
    return power < 1 || new TreasureToken().putOntoBattlefield(power, game, source);
}
Also used : Player(mage.players.Player) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TreasureToken(mage.game.permanent.token.TreasureToken) TargetPermanent(mage.target.TargetPermanent)

Example 15 with TreasureToken

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

the class IngeniousMasteryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (!AlternativeCostSourceAbility.getActivatedStatus(game, source, this.alternativeCostOriginalID, false)) {
        return player.drawCards(source.getManaCostsToPay().getX(), source, game) > 0;
    }
    player.drawCards(3, source, game);
    TargetOpponent targetOpponent = new TargetOpponent(true);
    if (!player.chooseTarget(Outcome.DrawCard, targetOpponent, source, game)) {
        return false;
    }
    Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
    if (opponent == null) {
        return false;
    }
    new TreasureToken().putOntoBattlefield(2, game, source, opponent.getId());
    opponent.scry(2, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) TreasureToken(mage.game.permanent.token.TreasureToken)

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