* Hushwing Gryff - Fixed a bug that the effect was wrongly implemented as replacement effect with potential to repalce other replacement effects.

This commit is contained in:
LevelX2 2014-08-09 16:40:21 +02:00
parent 609b5af2fe
commit a7fc5b9583
4 changed files with 14 additions and 13 deletions

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -41,6 +41,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -77,9 +78,10 @@ public class HushwingGryff extends CardImpl {
} }
} }
class HushwingGryffEffect extends ReplacementEffectImpl { class HushwingGryffEffect extends ContinuousRuleModifiyingEffectImpl {
HushwingGryffEffect() { HushwingGryffEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment, false); super(Duration.WhileOnBattlefield, Outcome.Detriment, false, false);
staticText = "Creatures entering the battlefield don't cause abilities to trigger"; staticText = "Creatures entering the battlefield don't cause abilities to trigger";
} }
@ -87,16 +89,15 @@ class HushwingGryffEffect extends ReplacementEffectImpl {
super(effect); super(effect);
} }
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
Permanent p = game.getPermanent(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent)event).getTarget();
if (p != null && p.getCardType().contains(CardType.CREATURE)) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
// Because replacement events have to be executed
// call replaceEvent here without calling the triggering event after
game.getContinuousEffects().replaceEvent(event, game);
return true; return true;
} }
} }

View file

@ -636,9 +636,6 @@ public class ContinuousEffects implements Serializable {
} }
public boolean replaceEvent(GameEvent event, Game game) { public boolean replaceEvent(GameEvent event, Game game) {
if (preventedByRuleModification(event, game, false)) {
return true;
}
boolean caught = false; boolean caught = false;
HashMap<UUID, HashSet<UUID>> consumed = new HashMap<>(); HashMap<UUID, HashSet<UUID>> consumed = new HashMap<>();
do { do {

View file

@ -537,6 +537,9 @@ public class GameState implements Serializable, Copyable<GameState> {
} }
public boolean replaceEvent(GameEvent event, Game game) { public boolean replaceEvent(GameEvent event, Game game) {
if (effects.preventedByRuleModification(event, game, false)) {
return true;
}
return effects.replaceEvent(event, game); return effects.replaceEvent(event, game);
} }

View file

@ -39,7 +39,7 @@ import mage.game.permanent.Permanent;
*/ */
public class EntersTheBattlefieldEvent extends GameEvent { public class EntersTheBattlefieldEvent extends GameEvent {
private Zone fromZone; private final Zone fromZone;
private Permanent target; private Permanent target;
public EntersTheBattlefieldEvent(Permanent target, UUID sourceId, UUID playerId, Zone fromZone) { public EntersTheBattlefieldEvent(Permanent target, UUID sourceId, UUID playerId, Zone fromZone) {