use of mage.game.stack.Spell in project mage by magefree.
the class MindreaverExileEffect method canTarget.
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Spell spell = game.getSpell(id);
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return super.canTarget(id, source, game) && spell != null && exileZone != null && !exileZone.isEmpty() && exileZone.getCards(game).stream().filter(Objects::nonNull).anyMatch(card -> CardUtil.haveSameNames(spell, card));
}
use of mage.game.stack.Spell in project mage by magefree.
the class PyromancersGauntletReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
MageObject object = game.getObject(event.getSourceId());
if (object instanceof Spell) {
if (((Spell) object).isControlledBy(source.getControllerId()) && (object.isInstant(game) || object.isSorcery(game))) {
return true;
}
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null && permanent.isPlaneswalker(game) && source.isControlledBy(permanent.getControllerId());
}
use of mage.game.stack.Spell in project mage by magefree.
the class ReverberationEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null) {
Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
if (targetSpell != null) {
Player targetsController = game.getPlayer(targetSpell.getControllerId());
if (targetsController != null) {
targetsController.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
return true;
}
}
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class SanctumPrelateReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
choiceValue = (Integer) game.getState().getValue(source.getSourceId().toString());
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && !spell.isCreature(game)) {
return spell.getManaValue() == choiceValue;
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class SenatorLottDodSpellsTargetingYouCostModificationEffect method applies.
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (!(abilityToModify instanceof SpellAbility)) {
return false;
}
if (!game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
return false;
}
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
Set<UUID> allTargets;
if (spell != null) {
// real cast
allTargets = CardUtil.getAllSelectedTargets(abilityToModify, game);
} else {
// playable
allTargets = CardUtil.getAllPossibleTargets(abilityToModify, game);
// can target without cost increase
if (allTargets.stream().anyMatch(target -> !isTargetCompatible(target, source, game))) {
return false;
}
;
}
return allTargets.stream().anyMatch(target -> isTargetCompatible(target, source, game));
}
Aggregations