use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class HelmOfKaldraEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (new HelmOfKaldraCondition().apply(game, source)) {
CreateTokenEffect effect = new CreateTokenEffect(new KaldraToken());
effect.apply(game, source);
for (UUID tokenId : effect.getLastAddedTokenIds()) {
Permanent kaldra = game.getPermanent(tokenId);
if (kaldra != null) {
// Attach helm to the token
for (Permanent kaldrasHelm : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterHelm, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasHelm.getId(), source, game);
break;
}
// Attach shield to the token
for (Permanent kaldrasShield : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterShield, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasShield.getId(), source, game);
break;
}
// Attach sword to the token
for (Permanent kaldrasSword : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterSword, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasSword.getId(), source, game);
break;
}
}
return true;
}
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class InvocationOfSaintTraftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
CreateTokenEffect effect = new CreateTokenEffect(new AngelToken(), 1, true, true);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && (effect.apply(game, source))) {
effect.exileTokensCreatedAtEndOfCombat(game, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class TaintedAdversaryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Integer timesPaid = (Integer) getValue("timesPaid");
if (timesPaid == null || timesPaid <= 0) {
return false;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
ability.addEffect(new CreateTokenEffect(new ZombieDecayedToken(), 2 * timesPaid));
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.CreateTokenEffect 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.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class BrudicladTelchorEngineerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
CreateTokenEffect effect = new CreateTokenEffect(new BrudicladTelchorMyrToken(), 1);
if (effect.apply(game, source)) {
TargetControlledPermanent target = new TargetControlledPermanent(0, 1, filter, true);
target.setNotTarget(true);
if (controller.chooseUse(outcome, "Select a token to copy?", source, game) && controller.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
Permanent toCopyFromPermanent = game.getPermanent(target.getFirstTarget());
if (toCopyFromPermanent != null) {
for (Permanent toCopyToPermanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!toCopyToPermanent.equals(toCopyFromPermanent)) {
game.copyPermanent(toCopyFromPermanent, toCopyToPermanent.getId(), source, new EmptyCopyApplier());
}
}
return true;
}
}
}
return false;
}
Aggregations