use of mage.game.stack.Spell in project mage by magefree.
the class CelestialKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
int cmc = spell.getManaValue();
FilterPermanent filter = new FilterPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class ComeuppanceEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
if (preventionData.getPreventedDamage() > 0) {
MageObject damageDealingObject = game.getObject(event.getSourceId());
UUID objectControllerId = null;
if (damageDealingObject instanceof Permanent) {
if (damageDealingObject.isCreature(game)) {
((Permanent) damageDealingObject).damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
} else {
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
}
} else if (damageDealingObject instanceof Ability) {
objectControllerId = ((Ability) damageDealingObject).getControllerId();
} else if (damageDealingObject instanceof Spell) {
objectControllerId = ((Spell) damageDealingObject).getControllerId();
}
if (objectControllerId != null) {
Player objectController = game.getPlayer(objectControllerId);
if (objectController != null) {
objectController.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
}
}
}
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class CommandeerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (controller != null && spell != null) {
spell.setControllerId(controller.getId());
spell.chooseNewTargets(game, controller.getId(), false, false, null);
return true;
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class CommitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
return controller.putCardOnTopXOfLibrary(permanent, game, source, 2, true);
}
Spell spell = game.getStack().getSpell(source.getFirstTarget());
if (spell != null) {
return controller.putCardOnTopXOfLibrary(spell, game, source, 2, true);
}
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class ForkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpell(source.getFirstTarget());
if (spell == null) {
return false;
}
spell.createCopyOnStack(game, source, source.getControllerId(), true, 1, ForkApplier.instance);
return true;
}
Aggregations