mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
* Changed ReplacementEffects for TARGET and COUNTER events to ContinuousRuleModifyingEffects.
This commit is contained in:
parent
e22174b148
commit
f51e7722cc
18 changed files with 112 additions and 127 deletions
|
|
@ -28,7 +28,7 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
@ -40,7 +40,7 @@ import mage.game.permanent.Permanent;
|
|||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class CantActivateAbilitiesAttachedEffect extends ReplacementEffectImpl {
|
||||
public class CantActivateAbilitiesAttachedEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
public CantActivateAbilitiesAttachedEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.UnboostCreature);
|
||||
|
|
@ -62,12 +62,7 @@ public class CantActivateAbilitiesAttachedEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
|
|
@ -44,7 +44,7 @@ import mage.game.stack.Spell;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CantCounterControlledEffect extends ReplacementEffectImpl {
|
||||
public class CantCounterControlledEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
private FilterSpell filterTarget;
|
||||
private FilterObject filterSource;
|
||||
|
|
@ -62,10 +62,12 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl {
|
|||
|
||||
public CantCounterControlledEffect(final CantCounterControlledEffect effect) {
|
||||
super(effect);
|
||||
if (effect.filterTarget != null)
|
||||
if (effect.filterTarget != null) {
|
||||
this.filterTarget = effect.filterTarget.copy();
|
||||
if (effect.filterSource != null)
|
||||
}
|
||||
if (effect.filterSource != null) {
|
||||
this.filterSource = effect.filterSource.copy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -79,19 +81,14 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
|
||||
if (event.getType() == EventType.COUNTER) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getControllerId().equals(source.getControllerId())
|
||||
&& filterTarget.match(spell, game)) {
|
||||
if (filterSource == null)
|
||||
if (filterSource == null) {
|
||||
return true;
|
||||
else {
|
||||
} else {
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package mage.abilities.effects.common;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -42,7 +42,7 @@ import mage.game.events.GameEvent.EventType;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CantCounterSourceEffect extends ReplacementEffectImpl {
|
||||
public class CantCounterSourceEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
public CantCounterSourceEffect() {
|
||||
super(Duration.WhileOnStack, Outcome.Benefit);
|
||||
|
|
@ -64,12 +64,7 @@ public class CantCounterSourceEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
|
||||
if (event.getType() == EventType.COUNTER) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.game.Game;
|
||||
|
|
@ -44,7 +44,7 @@ import mage.game.stack.StackObject;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CantTargetEffect extends ReplacementEffectImpl {
|
||||
public class CantTargetEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
private FilterPermanent filterTarget;
|
||||
private FilterStackObject filterSource;
|
||||
|
|
@ -82,12 +82,7 @@ public class CantTargetEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
|
||||
if (event.getType() == EventType.TARGET) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -42,9 +42,9 @@ import mage.game.stack.StackObject;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CantTargetSourceEffect extends ReplacementEffectImpl {
|
||||
public class CantTargetSourceEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
private FilterStackObject filterSource;
|
||||
private final FilterStackObject filterSource;
|
||||
|
||||
public CantTargetSourceEffect(FilterStackObject filterSource, Duration duration) {
|
||||
super(duration, Outcome.Benefit);
|
||||
|
|
@ -68,12 +68,7 @@ public class CantTargetSourceEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
|
||||
if (event.getType() == EventType.TARGET && event.getTargetId().equals(source.getSourceId())) {
|
||||
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredA
|
|||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
|
|||
|
|
@ -750,9 +750,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
if (hasProtectionFrom(source, game)) {
|
||||
return false;
|
||||
}
|
||||
// needed to get the correct possible targets if target replacement effects are active
|
||||
// needed to get the correct possible targets if target rule modification effects are active
|
||||
// e.g. Fiendslayer Paladin tried to target with Ultimate Price
|
||||
if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, this.getId(), source.getId(), sourceControllerId))) {
|
||||
if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.TARGET, this.getId(), source.getId(), sourceControllerId), game, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.game.stack;
|
|||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -73,18 +74,20 @@ public class SpellStack extends ArrayDeque<StackObject> {
|
|||
|
||||
public boolean counter(UUID objectId, UUID sourceId, Game game) {
|
||||
StackObject stackObject = getStackObject(objectId);
|
||||
if (stackObject != null) {
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
if (stackObject != null && sourceObject != null) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
|
||||
if ( stackObject instanceof Spell ) {
|
||||
game.rememberLKI(objectId, Zone.STACK, (Spell)stackObject);
|
||||
}
|
||||
this.remove(stackObject);
|
||||
stackObject.counter(sourceId, game);
|
||||
game.informPlayers(new StringBuilder(stackObject.getName()).append(" is countered").toString());
|
||||
game.informPlayers(new StringBuilder(stackObject.getName()).append(" is countered by ").append(sourceObject.getLogName()).toString());
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
|
||||
return true;
|
||||
} else {
|
||||
game.informPlayers(new StringBuilder(stackObject.getName()).append(" could not be countered by ").append(sourceObject.getLogName()).toString());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue