mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
fix ContinuousEffect that access affectedObjectsSet before it is initialized (#12080)
This commit is contained in:
parent
cce7f79d89
commit
017286ed94
47 changed files with 351 additions and 150 deletions
|
|
@ -66,7 +66,7 @@ class BackdraftHellkiteEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (!this.affectedObjectsSet) {
|
if (!getAffectedObjectsSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class BileBlightEffect extends BoostAllEffect {
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
affectedObjectList.clear();
|
affectedObjectList.clear();
|
||||||
if (!this.affectedObjectsSet) {
|
if (!getAffectedObjectsSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.CaseAbility;
|
import mage.abilities.common.CaseAbility;
|
||||||
|
|
@ -17,27 +14,23 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.common.GainLifeEffect;
|
import mage.abilities.effects.common.GainLifeEffect;
|
||||||
import mage.abilities.hint.common.CaseSolvedHint;
|
import mage.abilities.hint.common.CaseSolvedHint;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.ComparisonType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Layer;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubLayer;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.watchers.common.PlayerGainedLifeWatcher;
|
import mage.watchers.common.PlayerGainedLifeWatcher;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author DominionSpy
|
* @author DominionSpy
|
||||||
*/
|
*/
|
||||||
public final class CaseOfTheUneatenFeast extends CardImpl {
|
public final class CaseOfTheUneatenFeast extends CardImpl {
|
||||||
|
|
||||||
private static final Condition condition = new YouGainedLifeCondition(ComparisonType.MORE_THAN, 4){
|
private static final Condition condition = new YouGainedLifeCondition(ComparisonType.MORE_THAN, 4) {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "you've gained 5 or more life this turn";
|
return "you've gained 5 or more life this turn";
|
||||||
|
|
@ -93,7 +86,7 @@ class CaseOfTheUneatenFeastEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (!this.affectedObjectsSet) {
|
if (!getAffectedObjectsSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
|
|
@ -86,7 +86,7 @@ class CommandersPlateEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
if (!affectedObjectsSet) {
|
if (!getAffectedObjectsSetAtInit(source)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
|
|
@ -106,7 +106,7 @@ class CommandersPlateEffect extends ContinuousEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = null;
|
Permanent permanent = null;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -19,8 +17,10 @@ import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Styxo
|
* @author Styxo
|
||||||
*/
|
*/
|
||||||
public final class DarthVader extends CardImpl {
|
public final class DarthVader extends CardImpl {
|
||||||
|
|
@ -75,7 +75,7 @@ class UnboostCreaturesDefendingPlayerEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +84,7 @@ class UnboostCreaturesDefendingPlayerEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
int unboostCount = -1 * new CountersSourceCount(CounterType.P1P1).calculate(game, source, this);
|
int unboostCount = -1 * new CountersSourceCount(CounterType.P1P1).calculate(game, source, this);
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class DireBlunderbussGainAbilityEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
||||||
|
|
@ -88,7 +88,7 @@ class DireBlunderbussGainAbilityEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = null;
|
Permanent permanent = null;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
|
||||||
dependencyTypes.add(DependencyType.BecomeSwamp);
|
dependencyTypes.add(DependencyType.BecomeSwamp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
game.getBattlefield()
|
game.getBattlefield()
|
||||||
.getActivePermanents(
|
.getActivePermanents(
|
||||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND,
|
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND,
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class ErtaisFamiliarReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
affectedObjectList.clear();
|
affectedObjectList.clear();
|
||||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||||
affectedObjectsSet = true;
|
setAffectedObjectsSet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,22 @@
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mage.abilities.Ability;
|
||||||
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.constants.*;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.target.TargetPermanent;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author weirddan455
|
* @author weirddan455
|
||||||
*/
|
*/
|
||||||
public final class GiftOfFangs extends CardImpl {
|
public final class GiftOfFangs extends CardImpl {
|
||||||
|
|
@ -66,7 +65,7 @@ class GiftOfFangsEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSetAtInit(source)) {
|
||||||
// Added boosts of activated or triggered abilities exist independent from the source they are created by
|
// Added boosts of activated or triggered abilities exist independent from the source they are created by
|
||||||
// so a continuous effect for the permanent itself with the attachment is created
|
// so a continuous effect for the permanent itself with the attachment is created
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
|
|
@ -81,7 +80,7 @@ class GiftOfFangsEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = null;
|
Permanent permanent = null;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -21,8 +18,11 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
*/
|
*/
|
||||||
public final class GreatOakGuardian extends CardImpl {
|
public final class GreatOakGuardian extends CardImpl {
|
||||||
|
|
@ -75,7 +75,7 @@ class GreatOakGuardianEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
||||||
for (Permanent creature : creatures) {
|
for (Permanent creature : creatures) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
|
|
@ -85,7 +85,7 @@ class GreatOakGuardianEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.addPower(2);
|
permanent.addPower(2);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class KethisTheHiddenHandEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (!this.affectedObjectsSet) {
|
if (!getAffectedObjectsSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class LegionLoyalistCantBeBlockedByTokensEffect extends RestrictionEffect {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
affectedObjectsSet = true;
|
setAffectedObjectsSet(true);
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (UUID permId : getTargetPointer().getTargets(game, source)) {
|
for (UUID permId : getTargetPointer().getTargets(game, source)) {
|
||||||
affectedObjectList.add(new MageObjectReference(permId, game));
|
affectedObjectList.add(new MageObjectReference(permId, game));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.m;
|
package mage.cards.m;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.condition.LockedInCondition;
|
import mage.abilities.condition.LockedInCondition;
|
||||||
|
|
@ -18,8 +16,10 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public final class MarshCasualties extends CardImpl {
|
public final class MarshCasualties extends CardImpl {
|
||||||
|
|
@ -27,7 +27,7 @@ public final class MarshCasualties extends CardImpl {
|
||||||
private static final String ruleText = "Creatures target player controls get -1/-1 until end of turn. If this spell was kicked, those creatures get -2/-2 until end of turn instead";
|
private static final String ruleText = "Creatures target player controls get -1/-1 until end of turn. If this spell was kicked, those creatures get -2/-2 until end of turn instead";
|
||||||
|
|
||||||
public MarshCasualties(UUID ownerId, CardSetInfo setInfo) {
|
public MarshCasualties(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{B}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}{B}");
|
||||||
|
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getFirstTarget(), game)) {
|
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getFirstTarget(), game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.addPower(power);
|
permanent.addPower(power);
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,24 @@
|
||||||
|
|
||||||
package mage.cards.n;
|
package mage.cards.n;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.SplitCard;
|
import mage.cards.SplitCard;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Layer;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SpellAbilityType;
|
|
||||||
import mage.constants.SubLayer;
|
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class NightDay extends SplitCard {
|
public final class NightDay extends SplitCard {
|
||||||
|
|
@ -72,7 +67,7 @@ class DayEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
||||||
for (Permanent creature : creatures) {
|
for (Permanent creature : creatures) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
|
|
@ -82,7 +77,7 @@ class DayEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.addPower(1);
|
permanent.addPower(1);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class PastInFlamesEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.getGraveyard().stream().map((cardId) -> game.getCard(cardId)).filter(card1 -> card1.isInstantOrSorcery(game)).forEachOrdered((card) -> {
|
player.getGraveyard().stream().map((cardId) -> game.getCard(cardId)).filter(card1 -> card1.isInstantOrSorcery(game)).forEachOrdered((card) -> {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
game.getBattlefield()
|
game.getBattlefield()
|
||||||
.getActivePermanents(
|
.getActivePermanents(
|
||||||
StaticFilters.FILTER_CONTROLLED_CREATURE,
|
StaticFilters.FILTER_CONTROLLED_CREATURE,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
|
@ -16,14 +13,17 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Styxo
|
* @author Styxo
|
||||||
*/
|
*/
|
||||||
public final class ShieldsOfVelisVel extends CardImpl {
|
public final class ShieldsOfVelisVel extends CardImpl {
|
||||||
|
|
||||||
public ShieldsOfVelisVel(UUID ownerId, CardSetInfo setInfo) {
|
public ShieldsOfVelisVel(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.TRIBAL,CardType.INSTANT},"{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.INSTANT}, "{W}");
|
||||||
this.subtype.add(SubType.SHAPESHIFTER);
|
this.subtype.add(SubType.SHAPESHIFTER);
|
||||||
|
|
||||||
// Changeling
|
// Changeling
|
||||||
|
|
@ -65,7 +65,7 @@ class ShieldsOfVelisVelGainEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
||||||
for (Permanent creature : creatures) {
|
for (Permanent creature : creatures) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
|
|
@ -75,7 +75,7 @@ class ShieldsOfVelisVelGainEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.setIsAllCreatureTypes(game, true);
|
permanent.setIsAllCreatureTypes(game, true);
|
||||||
|
|
@ -106,7 +106,7 @@ class ShieldsOfVelisVelBoostEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getFirstTarget(), game);
|
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getFirstTarget(), game);
|
||||||
for (Permanent creature : creatures) {
|
for (Permanent creature : creatures) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
|
|
@ -116,7 +116,7 @@ class ShieldsOfVelisVelBoostEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.addToughness(1);
|
permanent.addToughness(1);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -18,8 +16,10 @@ import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class SilumgarTheDriftingDeath extends CardImpl {
|
public final class SilumgarTheDriftingDeath extends CardImpl {
|
||||||
|
|
@ -85,7 +85,7 @@ class UnboostCreaturesTargetPlayerEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ class UnboostCreaturesTargetPlayerEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.addPower(power);
|
permanent.addPower(power);
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class SpatialBindingReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
affectedObjectList.clear();
|
affectedObjectList.clear();
|
||||||
affectedObjectList.add(new MageObjectReference(source.getFirstTarget(), game));
|
affectedObjectList.add(new MageObjectReference(source.getFirstTarget(), game));
|
||||||
affectedObjectsSet = true;
|
setAffectedObjectsSet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -15,13 +13,16 @@ import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Loki
|
* @author Loki
|
||||||
*/
|
*/
|
||||||
public final class TakenoSamuraiGeneral extends CardImpl {
|
public final class TakenoSamuraiGeneral extends CardImpl {
|
||||||
|
|
||||||
public TakenoSamuraiGeneral(UUID ownerId, CardSetInfo setInfo) {
|
public TakenoSamuraiGeneral(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}");
|
||||||
this.supertype.add(SuperType.LEGENDARY);
|
this.supertype.add(SuperType.LEGENDARY);
|
||||||
this.subtype.add(SubType.HUMAN);
|
this.subtype.add(SubType.HUMAN);
|
||||||
this.subtype.add(SubType.SAMURAI);
|
this.subtype.add(SubType.SAMURAI);
|
||||||
|
|
@ -69,8 +70,8 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
if (!perm.getId().equals(source.getSourceId())) {
|
if (!perm.getId().equals(source.getSourceId())) {
|
||||||
for (Ability ability : perm.getAbilities()) {
|
for (Ability ability : perm.getAbilities()) {
|
||||||
if (ability instanceof BushidoAbility) {
|
if (ability instanceof BushidoAbility) {
|
||||||
|
|
@ -84,8 +85,8 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
for (Ability ability : permanent.getAbilities()) {
|
for (Ability ability : permanent.getAbilities()) {
|
||||||
|
|
@ -100,7 +101,7 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
if (!perm.getId().equals(source.getSourceId())) {
|
if (!perm.getId().equals(source.getSourceId())) {
|
||||||
for (Ability ability : perm.getAbilities()) {
|
for (Ability ability : perm.getAbilities()) {
|
||||||
if (ability instanceof BushidoAbility) {
|
if (ability instanceof BushidoAbility) {
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
|
||||||
dependencyTypes.add(DependencyType.BecomeSwamp);
|
dependencyTypes.add(DependencyType.BecomeSwamp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
game.getBattlefield()
|
game.getBattlefield()
|
||||||
.getActivePermanents(
|
.getActivePermanents(
|
||||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND,
|
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND,
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class VisionCharmEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
FilterPermanent filter = new FilterLandPermanent();
|
FilterPermanent filter = new FilterLandPermanent();
|
||||||
filter.add(SubType.byDescription(targetLandType).getPredicate());
|
filter.add(SubType.byDescription(targetLandType).getPredicate());
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
|
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.mage.test.cards.single.dis;
|
||||||
|
|
||||||
|
import mage.abilities.keyword.VigilanceAbility;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Susucr
|
||||||
|
*/
|
||||||
|
public class OccularHaloTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link mage.cards.o.OcularHalo Ocular Halo} {3}{U}
|
||||||
|
* Enchantment — Aura
|
||||||
|
* Enchant creature
|
||||||
|
* Enchanted creature has “{T}: Draw a card.”
|
||||||
|
* {W}: Enchanted creature gains vigilance until end of turn.
|
||||||
|
*/
|
||||||
|
private static final String halo = "Ocular Halo";
|
||||||
|
|
||||||
|
// bug: the activated ability did not give vigilance
|
||||||
|
@Test
|
||||||
|
public void test_Vigilance() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, halo);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Tundra", 5);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, halo, "Elite Vanguard");
|
||||||
|
activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "{W}");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertAbility(playerA, "Elite Vanguard", VigilanceAbility.getInstance(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.mage.test.cards.single.m13;
|
||||||
|
|
||||||
|
import mage.abilities.keyword.HexproofAbility;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Susucr
|
||||||
|
*/
|
||||||
|
public class RingOfEvosIsleTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link mage.cards.r.RingOfEvosIsle Ring of Evos Isle} {2}
|
||||||
|
* Artifact — Equipment
|
||||||
|
* {2}: Equipped creature gains hexproof until end of turn. (It can’t be the target of spells or abilities your opponents control.)
|
||||||
|
* At the beginning of your upkeep, put a +1/+1 counter on equipped creature if it’s blue.
|
||||||
|
* Equip {1} ({1}: Attach to target creature you control. Equip only as a sorcery.)
|
||||||
|
*/
|
||||||
|
private static final String ring = "Ring of Evos Isle";
|
||||||
|
|
||||||
|
// bug: the activated ability did not give hexproof
|
||||||
|
@Test
|
||||||
|
public void test_Hexproof() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Ring of Evos Isle");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Elite Vanguard");
|
||||||
|
activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "{2}");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertAbility(playerA, "Elite Vanguard", HexproofAbility.getInstance(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.mage.test.cards.single.mkm;
|
||||||
|
|
||||||
|
import mage.abilities.keyword.HexproofAbility;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Susucr
|
||||||
|
*/
|
||||||
|
public class AirtightAlibiTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link mage.cards.a.AirtightAlibi Airtight Alibi} {2}{G}
|
||||||
|
* Enchantment — Aura
|
||||||
|
* Flash
|
||||||
|
* Enchant creature
|
||||||
|
* When Airtight Alibi enters the battlefield, untap enchanted creature. It gains hexproof until end of turn. If it’s suspected, it’s no longer suspected.
|
||||||
|
* Enchanted creature gets +2/+2 and can’t become suspected.
|
||||||
|
*/
|
||||||
|
private static final String alibi = "Airtight Alibi";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bug: trigger doesn't give hexproof
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void test_GivesHexproofTemporary() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Memnite");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
||||||
|
addCard(Zone.HAND, playerA, alibi);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, alibi, "Memnite", true);
|
||||||
|
checkPT("Memnite is 3/3", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", 3, 3);
|
||||||
|
checkAbility("Memnite has Hexproof", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", HexproofAbility.class, true);
|
||||||
|
|
||||||
|
checkPT("Memnite is 3/3 turn 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", 3, 3);
|
||||||
|
checkAbility("Memnite doesn't have Hexproof turn 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", HexproofAbility.class, false);
|
||||||
|
|
||||||
|
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, alibi, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.mage.test.cards.single.thb;
|
||||||
|
|
||||||
|
import mage.abilities.keyword.FirstStrikeAbility;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Susucr
|
||||||
|
*/
|
||||||
|
public class AspectOfManticoreTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link mage.cards.a.AspectOfManticore Aspect of Manticore} {2}{R}
|
||||||
|
* Enchantment — Aura
|
||||||
|
* Flash
|
||||||
|
* Enchant creature
|
||||||
|
* When Aspect of Manticore enters the battlefield, enchanted creature gains first strike until end of turn.
|
||||||
|
* Enchanted creature gets +2/+0.
|
||||||
|
*/
|
||||||
|
private static final String aspect = "Aspect of Manticore";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bug: trigger doesn't give first strike
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void test_GivesFirstStrikeTemporary() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Memnite");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||||
|
addCard(Zone.HAND, playerA, aspect);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aspect, "Memnite", true);
|
||||||
|
checkPT("Memnite is 3/1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", 3, 1);
|
||||||
|
checkAbility("Memnite has first strike", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", FirstStrikeAbility.class, true);
|
||||||
|
|
||||||
|
checkPT("Memnite is 3/1 turn 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", 3, 1);
|
||||||
|
checkAbility("Memnite doesn't have first strike turn 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite", FirstStrikeAbility.class, false);
|
||||||
|
|
||||||
|
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, aspect, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,7 +37,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
// If your ability/effect supports multi use cases (one time use, static, target pointers) then affectedObjectsSet can be useful:
|
// If your ability/effect supports multi use cases (one time use, static, target pointers) then affectedObjectsSet can be useful:
|
||||||
// * affectedObjectsSet - true on static objects and false on dynamic objects (see rules from 611.2c)
|
// * affectedObjectsSet - true on static objects and false on dynamic objects (see rules from 611.2c)
|
||||||
// Full implement example: GainAbilityTargetEffect
|
// Full implement example: GainAbilityTargetEffect
|
||||||
protected boolean affectedObjectsSet = false;
|
//
|
||||||
|
// is null before being initialized. Any access attempt computes it.
|
||||||
|
private Boolean affectedObjectsSet = null;
|
||||||
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
|
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
|
||||||
|
|
||||||
protected boolean temporary = false;
|
protected boolean temporary = false;
|
||||||
|
|
@ -62,7 +64,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
private int effectStartingStepNum = 0; // Some continuous are waiting for the next step of a kind.
|
private int effectStartingStepNum = 0; // Some continuous are waiting for the next step of a kind.
|
||||||
// Avoid miscancelling if the start step is of that kind.
|
// Avoid miscancelling if the start step is of that kind.
|
||||||
|
|
||||||
public ContinuousEffectImpl(Duration duration, Outcome outcome) {
|
protected ContinuousEffectImpl(Duration duration, Outcome outcome) {
|
||||||
super(outcome);
|
super(outcome);
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.order = 0;
|
this.order = 0;
|
||||||
|
|
@ -71,7 +73,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
this.dependendToTypes = EnumSet.noneOf(DependencyType.class);
|
this.dependendToTypes = EnumSet.noneOf(DependencyType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContinuousEffectImpl(Duration duration, Layer layer, SubLayer sublayer, Outcome outcome) {
|
protected ContinuousEffectImpl(Duration duration, Layer layer, SubLayer sublayer, Outcome outcome) {
|
||||||
this(duration, outcome);
|
this(duration, outcome);
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
this.sublayer = sublayer;
|
this.sublayer = sublayer;
|
||||||
|
|
@ -166,6 +168,16 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game, UUID activePlayerId) {
|
public void init(Ability source, Game game, UUID activePlayerId) {
|
||||||
getTargetPointer().init(game, source);
|
getTargetPointer().init(game, source);
|
||||||
|
if (this.affectedObjectsSet == null) {
|
||||||
|
initAffectedObjectsSet(source);
|
||||||
|
}
|
||||||
|
setStartingControllerAndTurnNum(game, source.getControllerId(), activePlayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes affectedObjectsSet boolean from the source object.
|
||||||
|
*/
|
||||||
|
private void initAffectedObjectsSet(Ability source) {
|
||||||
// 20210112 - 611.2c
|
// 20210112 - 611.2c
|
||||||
// 611.2c If a continuous effect generated by the resolution of a spell or ability modifies the
|
// 611.2c If a continuous effect generated by the resolution of a spell or ability modifies the
|
||||||
// characteristics or changes the controller of any objects, the set of objects it affects is
|
// characteristics or changes the controller of any objects, the set of objects it affects is
|
||||||
|
|
@ -177,6 +189,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
// effect began.If a single continuous effect has parts that modify the characteristics or
|
// effect began.If a single continuous effect has parts that modify the characteristics or
|
||||||
// changes the controller of any objects and other parts that don’t, the set of objects
|
// changes the controller of any objects and other parts that don’t, the set of objects
|
||||||
// each part applies to is determined independently.
|
// each part applies to is determined independently.
|
||||||
|
this.affectedObjectsSet = false;
|
||||||
if (AbilityType.STATIC != source.getAbilityType()) {
|
if (AbilityType.STATIC != source.getAbilityType()) {
|
||||||
if (layer != null) {
|
if (layer != null) {
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
|
|
@ -199,7 +212,35 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
||||||
this.affectedObjectsSet = true;
|
this.affectedObjectsSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setStartingControllerAndTurnNum(game, source.getControllerId(), activePlayerId);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a workaround when trying to access affectObjectsSet during init, before
|
||||||
|
* ContinuousEffectImpl::init is called.
|
||||||
|
* <p>
|
||||||
|
* TODO: should be investigated how to modify all continuous effects to call super.init()
|
||||||
|
* before doing their own changes. At which point there is no longer need for this
|
||||||
|
* workaround.
|
||||||
|
*/
|
||||||
|
protected boolean getAffectedObjectsSetAtInit(Ability source) {
|
||||||
|
if (this.affectedObjectsSet == null) {
|
||||||
|
initAffectedObjectsSet(source);
|
||||||
|
}
|
||||||
|
return this.affectedObjectsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this getter in other places than overriden calls, most likely the apply method.
|
||||||
|
*/
|
||||||
|
protected boolean getAffectedObjectsSet() {
|
||||||
|
if (this.affectedObjectsSet == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.affectedObjectsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setAffectedObjectsSet(boolean affectedObjectsSet) {
|
||||||
|
this.affectedObjectsSet = affectedObjectsSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
||||||
|
|
@ -59,7 +59,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
return getTargetPointer().getFirst(game, source).equals(permanent.getId());
|
return getTargetPointer().getFirst(game, source).equals(permanent.getId());
|
||||||
}
|
}
|
||||||
return permanent.getAttachments().contains(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class GoadAllEffect extends ContinuousEffectImpl {
|
||||||
public GoadAllEffect(Duration duration, FilterPermanent filter, boolean affectedObjectsSet) {
|
public GoadAllEffect(Duration duration, FilterPermanent filter, boolean affectedObjectsSet) {
|
||||||
super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment);
|
super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.affectedObjectsSet = affectedObjectsSet;
|
this.setAffectedObjectsSet(affectedObjectsSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GoadAllEffect(final GoadAllEffect effect) {
|
private GoadAllEffect(final GoadAllEffect effect) {
|
||||||
|
|
@ -46,7 +46,7 @@ public class GoadAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
game.getBattlefield()
|
game.getBattlefield()
|
||||||
.getActivePermanents(
|
.getActivePermanents(
|
||||||
filter, source.getControllerId(), source, game
|
filter, source.getControllerId(), source, game
|
||||||
|
|
@ -58,7 +58,7 @@ public class GoadAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
this.affectedObjectList.removeIf(mor -> !mor.zoneCounterIsCurrent(game)
|
this.affectedObjectList.removeIf(mor -> !mor.zoneCounterIsCurrent(game)
|
||||||
|| mor.getPermanent(game) == null);
|
|| mor.getPermanent(game) == null);
|
||||||
if (affectedObjectList.isEmpty()) {
|
if (affectedObjectList.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(
|
for (Permanent perm : game.getBattlefield().getActivePermanents(
|
||||||
filter, source.getControllerId(), source, game)) {
|
filter, source.getControllerId(), source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
|
|
@ -72,7 +72,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
Set<Permanent> affectedPermanents = new HashSet<>();
|
Set<Permanent> affectedPermanents = new HashSet<>();
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (MageObjectReference ref : affectedObjectList) {
|
for (MageObjectReference ref : affectedObjectList) {
|
||||||
affectedPermanents.add(ref.getPermanent(game));
|
affectedPermanents.add(ref.getPermanent(game));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
Permanent permanent;
|
Permanent permanent;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = affectedObjectList.get(0).getPermanent(game);
|
permanent = affectedObjectList.get(0).getPermanent(game);
|
||||||
} else {
|
} else {
|
||||||
permanent = game.getPermanent(source.getSourceId());
|
permanent = game.getPermanent(source.getSourceId());
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Layer;
|
import mage.constants.Layer;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubLayer;
|
import mage.constants.SubLayer;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
|
|
@ -103,7 +102,7 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
setRuntimeData(source, game);
|
setRuntimeData(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
|
|
@ -116,7 +115,7 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (perm.isControlledBy(source.getControllerId())
|
if (perm.isControlledBy(source.getControllerId())
|
||||||
&& !(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
&& !(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||||
|
|
@ -90,7 +90,7 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class BoostEnchantedEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
// Added boosts of activated or triggered abilities exist independent from the source they are created by
|
// Added boosts of activated or triggered abilities exist independent from the source they are created by
|
||||||
// so a continuous effect for the permanent itself with the attachment is created
|
// so a continuous effect for the permanent itself with the attachment is created
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
|
|
@ -68,7 +68,7 @@ public class BoostEnchantedEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = null;
|
Permanent permanent = null;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (opponents.contains(perm.getControllerId())) {
|
if (opponents.contains(perm.getControllerId())) {
|
||||||
|
|
@ -62,7 +62,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent perm = it.next().getPermanent(game);
|
Permanent perm = it.next().getPermanent(game);
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class BoostSourceEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
try {
|
try {
|
||||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
|
|
@ -68,7 +68,7 @@ public class BoostSourceEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent target;
|
Permanent target;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
target = affectedObjectList.get(0).getPermanent(game);
|
target = affectedObjectList.get(0).getPermanent(game);
|
||||||
} else {
|
} else {
|
||||||
target = game.getPermanent(source.getSourceId());
|
target = game.getPermanent(source.getSourceId());
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
power = StaticValue.get(power.calculate(game, source, this));
|
power = StaticValue.get(power.calculate(game, source, this));
|
||||||
toughness = StaticValue.get(toughness.calculate(game, source, this));
|
toughness = StaticValue.get(toughness.calculate(game, source, this));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
setRuntimeData(source, game);
|
setRuntimeData(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
|
|
@ -77,7 +77,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent permanent = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
Permanent permanent = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSetAtInit(source)) {
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
||||||
|
|
@ -89,7 +89,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent;
|
Permanent permanent;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (perm.isControlledBy(source.getControllerId())
|
if (perm.isControlledBy(source.getControllerId())
|
||||||
&& !(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
&& !(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||||
|
|
@ -82,7 +82,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()) + 1, game));
|
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()) + 1, game));
|
||||||
|
|
@ -77,7 +77,7 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (onCard) {
|
if (onCard) {
|
||||||
Card card;
|
Card card;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
card = affectedObjectList.get(0).getCard(game);
|
card = affectedObjectList.get(0).getCard(game);
|
||||||
} else {
|
} else {
|
||||||
card = game.getCard(source.getSourceId());
|
card = game.getCard(source.getSourceId());
|
||||||
|
|
@ -89,7 +89,7 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Permanent permanent;
|
Permanent permanent;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = affectedObjectList.get(0).getPermanent(game);
|
permanent = affectedObjectList.get(0).getPermanent(game);
|
||||||
} else {
|
} else {
|
||||||
permanent = game.getPermanent(source.getSourceId());
|
permanent = game.getPermanent(source.getSourceId());
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
|
|
||||||
// must support dynamic targets from static ability and static targets from activated abilities
|
// must support dynamic targets from static ability and static targets from activated abilities
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
// target permanents (by default)
|
// target permanents (by default)
|
||||||
getTargetPointer().getTargets(game, source)
|
getTargetPointer().getTargets(game, source)
|
||||||
.stream()
|
.stream()
|
||||||
|
|
@ -93,7 +93,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int affectedTargets = 0;
|
int affectedTargets = 0;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
// STATIC TARGETS
|
// STATIC TARGETS
|
||||||
List<MageObjectReference> newWaitingPermanents = new ArrayList<>();
|
List<MageObjectReference> newWaitingPermanents = new ArrayList<>();
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSetAtInit(source)) {
|
||||||
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game.getState().getZoneChangeCounter(equipment.getAttachedTo())));
|
||||||
|
|
@ -72,7 +72,7 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = null;
|
Permanent permanent = null;
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
discard();
|
discard();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package mage.abilities.effects.common.continuous;
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.CompoundAbility;
|
import mage.abilities.CompoundAbility;
|
||||||
|
|
@ -15,6 +13,8 @@ import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -61,7 +61,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
|
|
@ -77,7 +77,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (this.affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||||
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class SetBasePowerToughnessAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ public class SetBasePowerToughnessAllEffect extends ContinuousEffectImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int newPower = power.calculate(game, source, this);
|
int newPower = power.calculate(game, source, this);
|
||||||
int newToughness = toughness.calculate(game, source, this);
|
int newToughness = toughness.calculate(game, source, this);
|
||||||
if (affectedObjectsSet) {
|
if (getAffectedObjectsSet()) {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||||
Permanent permanent = it.next().getPermanent(game);
|
Permanent permanent = it.next().getPermanent(game);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,8 @@
|
||||||
|
|
||||||
package mage.abilities.effects.common.continuous;
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Layer;
|
import mage.constants.Layer;
|
||||||
|
|
@ -17,6 +14,8 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,7 +41,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (this.affectedObjectsSet && game.getPlayer(source.getControllerId()) != null) {
|
if (getAffectedObjectsSet() && game.getPlayer(source.getControllerId()) != null) {
|
||||||
for (Permanent perm : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
for (Permanent perm : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +55,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.affectedObjectsSet) {
|
if (!getAffectedObjectsSet()) {
|
||||||
game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).forEach(Permanent::switchPowerToughness);
|
game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).forEach(Permanent::switchPowerToughness);
|
||||||
} else {
|
} else {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still gets boost
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still gets boost
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue