mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Cease-Fire - Fixed possible cast exception.
This commit is contained in:
parent
d5c4d6b784
commit
f9d88cfb24
2 changed files with 15 additions and 23 deletions
|
@ -37,8 +37,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.common.FilterCreatureSpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
@ -74,11 +73,7 @@ public class CeaseFire extends CardImpl {
|
|||
|
||||
class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
private static final FilterSpell filter = new FilterSpell();
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||
}
|
||||
private static final FilterCreatureSpell filter = new FilterCreatureSpell();
|
||||
|
||||
public CeaseFireEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Detriment);
|
||||
|
@ -94,11 +89,6 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
return new CeaseFireEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessage(Ability source, GameEvent event, Game game) {
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
|
@ -115,9 +105,9 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getPlayerId().equals(source.getFirstTarget())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (filter.match((Spell) object, game)) {
|
||||
if (event.getPlayerId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||
if (spell != null && filter.match(spell, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,13 +31,14 @@ import java.util.UUID;
|
|||
|
||||
import mage.constants.*;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureSpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,6 +70,8 @@ public class SteelGolem extends CardImpl {
|
|||
|
||||
class SteelGolemEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
private static final FilterCreatureSpell filter = new FilterCreatureSpell();
|
||||
|
||||
public SteelGolemEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
staticText = "You can't cast creature spells";
|
||||
|
@ -84,15 +87,15 @@ class SteelGolemEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CAST_SPELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object.getCardType().contains(CardType.CREATURE)) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||
if (spell != null && filter.match(spell, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -100,4 +103,3 @@ class SteelGolemEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue