use of mage.game.stack.Spell in project mage by magefree.
the class HallOfTheBanditLordWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.MANA_PAID) {
MageObject target = game.getObject(event.getTargetId());
if (event.getSourceId() != null && event.getSourceId().equals(this.getSourceId()) && target != null && target.isCreature(game) && event.getFlag()) {
if (target instanceof Spell) {
this.creatures.add(((Spell) target).getCard().getId());
}
}
}
if (event.getType() == GameEvent.EventType.COUNTERED) {
if (creatures.contains(event.getTargetId())) {
creatures.remove(event.getSourceId());
}
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
if (creatures.contains(event.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
// spell was e.g. exiled and goes again to stack, so previous cast has not resolved.
if (zEvent.getToZone() == Zone.STACK) {
creatures.remove(event.getSourceId());
}
}
}
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
if (creatures.contains(event.getSourceId())) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
game.addEffect(effect, source);
creatures.remove(event.getSourceId());
}
}
}
use of mage.game.stack.Spell in project mage by magefree.
the class InkTreaderNephilimEffect method checkInterveningIfClause.
@Override
public boolean checkInterveningIfClause(Game game) {
Spell spell = (Spell) getEffects().get(0).getValue("triggeringSpell");
if (spell == null) {
return false;
}
boolean flag = false;
for (TargetAddress addr : TargetAddress.walk(spell)) {
Target targetInstance = addr.getTarget(spell);
for (UUID target : targetInstance.getTargets()) {
if (target == null) {
continue;
}
Permanent permanent = game.getPermanent(target);
if (permanent == null || !permanent.getId().equals(getSourceId())) {
return false;
}
if (getSourceObjectZoneChangeCounter() != 0 && getSourceObjectZoneChangeCounter() != permanent.getZoneChangeCounter(game)) {
return false;
}
flag = true;
}
}
return flag;
}
use of mage.game.stack.Spell in project mage by magefree.
the class InsistWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && ready) {
if (uncounterableSpell == null && event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && (spell.isCreature(game))) {
uncounterableSpell = spell.getId();
ready = false;
}
}
}
}
use of mage.game.stack.Spell in project mage by magefree.
the class KindredDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Spell spell = game.getSpell(source.getFirstTarget());
if (player == null || spell == null) {
return false;
}
int manaValue = spell.getManaValue();
spell.counter(source, game);
FilterCard filter = new FilterCard();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, manaValue));
player.seekCard(filter, source, game);
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class LivingBreakthroughEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Spell spell = (Spell) getValue("spellCast");
if (spell != null) {
this.manaValue = spell.getManaValue();
}
}
Aggregations