use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class EntrapmentManeuverSacrificeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(AttackingPredicate.instance);
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
if (realCount > 0) {
Target target = new TargetControlledPermanent(1, 1, filter, true);
while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
int amount = permanent.getToughness().getValue();
permanent.sacrifice(source, game);
new CreateTokenEffect(new SoldierToken(), amount).apply(game, source);
} else {
return false;
}
}
return true;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class FeralLightningEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
CreateTokenEffect effect = new CreateTokenEffect(new ElementalTokenWithHaste(), 3);
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 KalitasTraitorOfGhetEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null) {
controller.moveCards(permanent, Zone.EXILED, source, game);
new CreateTokenEffect(new ZombieToken()).apply(game, source);
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class KrenkoTinStreetKingpinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent == null) {
return false;
}
new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
game.getState().processAction(game);
int xValue = permanent.getPower().getValue();
return new CreateTokenEffect(new GoblinToken(), xValue).apply(game, source);
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class LightningCoilsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent p = game.getPermanent(source.getSourceId());
if (p != null && controller != null) {
int counters = p.getCounters(game).getCount(CounterType.CHARGE);
if (counters >= 5) {
// remove all the counters and create that many tokens
p.removeCounters(CounterType.CHARGE.getName(), p.getCounters(game).getCount(CounterType.CHARGE), source, game);
CreateTokenEffect effect = new CreateTokenEffect(new ElementalTokenWithHaste(), counters);
effect.apply(game, source);
// exile those tokens at next end step
effect.exileTokensCreatedAtNextEndStep(game, source);
return true;
}
}
return false;
}
Aggregations