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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations