use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class NotoriousThrongEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class);
if (controller != null && watcher != null) {
int numTokens = 0;
for (UUID opponentId : game.getOpponents(controller.getId())) {
numTokens += watcher.getAmountOfDamageReceivedThisTurn(opponentId);
}
if (numTokens > 0) {
new CreateTokenEffect(new FaerieRogueToken(), numTokens).apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class RithTheAwakenerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
ChoiceColor choice = new ChoiceColor();
if (controller.choose(outcome, choice, game)) {
game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(choice.getColor()));
int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
if (cardsWithColor > 0) {
new CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class TimelyReinforcementsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean lessCreatures = false;
boolean lessLife = false;
FilterPermanent filter = new FilterCreaturePermanent();
int count = game.getBattlefield().countAll(filter, controller.getId(), game);
for (UUID uuid : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(uuid);
if (opponent != null) {
if (opponent.getLife() > controller.getLife()) {
lessLife = true;
}
if (game.getBattlefield().countAll(filter, uuid, game) > count) {
lessCreatures = true;
}
}
if (lessLife && lessCreatures) {
// no need to search further
break;
}
}
if (lessLife) {
controller.gainLife(6, game, source);
}
if (lessCreatures) {
Effect effect = new CreateTokenEffect(new SoldierToken(), 3);
effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class ElementalMasteryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creatureAttached = game.getPermanent(source.getSourceId());
if (creatureAttached != null) {
int power = creatureAttached.getPower().getValue();
if (power > 0) {
CreateTokenEffect effect = new CreateTokenEffect(new ElementalMasteryElementalToken(), power);
effect.apply(game, source);
effect.exileTokensCreatedAtNextEndStep(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class KirinTouchedOrochiCounterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
UUID targetId = source.getFirstTarget();
Card card = game.getCard(targetId);
if (controller == null || card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
return false;
}
if (!controller.moveCards(card, Zone.EXILED, source, game)) {
return false;
}
ReflexiveTriggeredAbility reflexiveTokenAbility = new ReflexiveTriggeredAbility(new CreateTokenEffect(new SpiritToken()), false);
game.fireReflexiveTriggeredAbility(reflexiveTokenAbility, source);
return true;
}
Aggregations