use of mage.abilities.effects.common.CreateTokenTargetEffect in project mage by magefree.
the class GenerousGiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
permanent.destroy(source, game, false);
if (player == null) {
return false;
}
Effect effect = new CreateTokenTargetEffect(new ElephantToken());
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
use of mage.abilities.effects.common.CreateTokenTargetEffect in project mage by magefree.
the class MoggInfestationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Cards creaturesDied = new CardsImpl();
if (controller != null && getTargetPointer().getFirst(game, source) != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
if (permanent.destroy(source, game, false)) {
if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
// If a commander is replaced to command zone, the creature does not die
creaturesDied.add(permanent);
}
}
}
// Bug #8548
game.getState().processAction(game);
if (creaturesDied.isEmpty()) {
return true;
}
for (Card c : creaturesDied.getCards(game)) {
if (game.getState().getZone(c.getId()) == Zone.GRAVEYARD) {
Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenTargetEffect in project mage by magefree.
the class VarchildBetrayerOfKjeldorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int damage = (int) this.getValue("damage");
if (damage > 0) {
Effect effect = new CreateTokenTargetEffect(new SurvivorToken(), damage);
effect.setTargetPointer(getTargetPointer());
return effect.apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.CreateTokenTargetEffect in project mage by magefree.
the class OpponentCreateSurvivorTokenCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
TargetOpponent target = new TargetOpponent();
if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null) {
Effect effect = new CreateTokenTargetEffect(new SurvivorToken());
effect.setTargetPointer(new FixedTarget(opponent.getId(), game));
paid = effect.apply(game, ability);
}
}
}
return paid;
}
use of mage.abilities.effects.common.CreateTokenTargetEffect in project mage by magefree.
the class GallowsAtWillowHillEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
permanent.destroy(source, game, false);
if (controller != null) {
CreateTokenTargetEffect effect = new CreateTokenTargetEffect(new SpiritWhiteToken());
effect.setTargetPointer(new FixedTarget(controller.getId()));
effect.apply(game, source);
}
return true;
}
return false;
}
Aggregations