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