use of mage.game.stack.Spell in project mage by magefree.
the class GaleaKindlerOfHopeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId()) || event.getZone() != Zone.LIBRARY || !event.getAdditionalReference().getApprovingMageObjectReference().refersTo(this.getSourceObject(game), game)) {
return false;
}
Spell spell = game.getSpell(event.getTargetId());
if (spell == null || !spell.hasSubtype(SubType.EQUIPMENT, game)) {
return false;
}
this.getEffects().clear();
this.addEffect(new GaleaKindlerOfHopeEffect(spell, game));
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class GaleaKindlerOfHopeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpell(spellRef.getSourceId());
if (spell != null && spell.getZoneChangeCounter(game) == spellRef.getZoneChangeCounter()) {
game.getState().addOtherAbility(spell.getCard(), ability);
return true;
}
Permanent permanent = permRef.getPermanent(game);
if (permanent == null) {
discard();
return false;
}
permanent.addAbility(ability, source.getSourceId(), game);
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class GuileReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Spell counteredSpell = game.getStack().getSpell(event.getTargetId());
StackObject counteringObject = game.getStack().getStackObject(event.getSourceId());
return counteredSpell != null && counteringObject != null && counteringObject.isControlledBy(source.getControllerId());
}
use of mage.game.stack.Spell in project mage by magefree.
the class MonasterySiegeCostIncreaseEffect method applies.
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (!modeDragons.apply(game, source)) {
return false;
}
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));
}
use of mage.game.stack.Spell in project mage by magefree.
the class OpalTitanBecomesCreatureEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
Spell creatureSpellCast = game.getSpell(targetPointer.getFirst(game, source));
if (creatureSpellCast != null && creatureSpellCast.getColor(game).hasColor()) {
game.getState().setValue("opalTitanColor" + source.getSourceId(), creatureSpellCast.getColor(game));
}
}
Aggregations