mirror of
https://github.com/correl/mage.git
synced 2025-04-02 03:18:09 -09:00
* Switched from UUID to MageObjectReference to handle affected objects of continuous effects. Solvng problems with objects that changed (multiple times) zones while the effect lasts.
This commit is contained in:
parent
9ff1f60903
commit
02ba80b719
41 changed files with 407 additions and 342 deletions
Mage.Sets/src/mage/sets
apocalypse
bornofthegods
championsofkamigawa
commander2013
gatecrash
guildpact
iceage
innistrad
khansoftarkir
limitedalpha
magic2010
magic2015
ninthedition
odyssey
ravnika
riseoftheeldrazi
scarsofmirrodin
tenth
timespiral
urzasdestiny
visions
zendikar
Mage.Tests/src/test/java/org/mage/test
Mage/src/mage
MageObjectReference.java
abilities/effects
ContinuousEffect.java
common/continious
BecomesCreatureSourceEffect.javaBecomesFaceDownCreatureAllEffect.javaBoostAllEffect.javaBoostControlledEffect.javaBoostOpponentsEffect.javaBoostSourceEffect.javaGainAbilityAllEffect.javaGainAbilityControlledEffect.javaGainAbilitySourceEffect.javaGainAbilityTargetEffect.javaSetPowerToughnessAllEffect.javaSwitchPowerToughnessAllEffect.java
|
@ -28,8 +28,10 @@
|
|||
|
||||
package mage.sets.apocalypse;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.continious.BoostTargetEffect;
|
||||
|
@ -106,18 +108,20 @@ class DayEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
objects.add(creature.getId());
|
||||
affectedObjectList.add(new MageObjectReference(creature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
if (!this.affectedObjectsSet || objects.contains(creature.getId())) {
|
||||
creature.addPower(1);
|
||||
creature.addToughness(1);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
permanent.addPower(1);
|
||||
permanent.addToughness(1);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.bornofthegods;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.continious.BoostAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -79,17 +80,17 @@ class BileBlightEffect extends BoostAllEffect {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
affectedObjectList.clear();
|
||||
if (this.affectedObjectsSet) {
|
||||
this.objects.clear();
|
||||
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (target != null) {
|
||||
if (target.getName().isEmpty()) { // face down creature
|
||||
this.objects.add(target.getId());
|
||||
affectedObjectList.add(new MageObjectReference(target));
|
||||
} else {
|
||||
String name = target.getLogName();
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
|
||||
if (perm.getLogName().equals(name)) {
|
||||
this.objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,17 +30,18 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.*;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EmptyEffect;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.BoostAllEffect;
|
||||
import mage.abilities.keyword.ChangelingAbility;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
@ -53,7 +54,6 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author LevelX
|
||||
*/
|
||||
|
||||
public class KondasBanner extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent legendaryFilter = new FilterControlledCreaturePermanent("Legendary creatures");
|
||||
|
@ -80,8 +80,8 @@ public class KondasBanner extends CardImpl {
|
|||
// Equip {2}
|
||||
this.addAbility(new EquipAbility(
|
||||
Outcome.AddAbility,
|
||||
new GenericManaCost(2),
|
||||
new TargetControlledCreaturePermanent(1,1, legendaryFilter, false)));
|
||||
new GenericManaCost(2),
|
||||
new TargetControlledCreaturePermanent(1, 1, legendaryFilter, false)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -92,15 +92,15 @@ public class KondasBanner extends CardImpl {
|
|||
@Override
|
||||
public KondasBanner copy() {
|
||||
return new KondasBanner(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KondasBannerTypeBoostEffect extends BoostAllEffect {
|
||||
class KondasBannerTypeBoostEffect extends BoostAllEffect {
|
||||
|
||||
private static final String effectText = "Creatures that share a creature type with equipped creature get +1/+1";
|
||||
|
||||
KondasBannerTypeBoostEffect() {
|
||||
super(1,1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), false);
|
||||
super(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), false);
|
||||
staticText = effectText;
|
||||
}
|
||||
|
||||
|
@ -109,27 +109,24 @@ class KondasBannerTypeBoostEffect extends BoostAllEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// Check if the equipment is attached
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null)
|
||||
{
|
||||
Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo());
|
||||
if (equipedCreature != null) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (CardUtil.shareSubtypes(perm, equipedCreature)) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
perm.addPower(power.calculate(game, source, this));
|
||||
perm.addToughness(toughness.calculate(game, source, this));
|
||||
}
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// Check if the equipment is attached
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo());
|
||||
if (equipedCreature != null) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (CardUtil.shareSubtypes(perm, equipedCreature)) {
|
||||
perm.addPower(power.calculate(game, source, this));
|
||||
perm.addToughness(toughness.calculate(game, source, this));
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KondasBannerTypeBoostEffect copy() {
|
||||
|
@ -138,13 +135,12 @@ class KondasBannerTypeBoostEffect extends BoostAllEffect {
|
|||
|
||||
}
|
||||
|
||||
|
||||
class KondasBannerColorBoostEffect extends BoostAllEffect {
|
||||
class KondasBannerColorBoostEffect extends BoostAllEffect {
|
||||
|
||||
private static final String effectText = "Creatures that share a color with equipped creature get +1/+1.";
|
||||
|
||||
KondasBannerColorBoostEffect() {
|
||||
super(1,1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), false);
|
||||
super(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), false);
|
||||
staticText = effectText;
|
||||
}
|
||||
|
||||
|
@ -153,25 +149,22 @@ class KondasBannerColorBoostEffect extends BoostAllEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// Check if the equipment is attached
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null)
|
||||
{
|
||||
Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo());
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (equipedCreature.getColor().shares(perm.getColor())) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// Check if the equipment is attached
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo());
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (equipedCreature.getColor().shares(perm.getColor())) {
|
||||
perm.addPower(power.calculate(game, source, this));
|
||||
perm.addToughness(toughness.calculate(game, source, this));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KondasBannerColorBoostEffect copy() {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -41,6 +42,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
|
@ -101,7 +103,7 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
|
|||
if (!perm.getId().equals(source.getSourceId())) {
|
||||
for (Ability ability : perm.getAbilities()) {
|
||||
if (ability instanceof BushidoAbility) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +113,23 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (this.affectedObjectsSet) {
|
||||
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);
|
||||
if (permanent != null) {
|
||||
for (Ability ability : permanent.getAbilities()) {
|
||||
if (ability instanceof BushidoAbility) {
|
||||
int value = ((BushidoAbility) ability).getValue(source, game, this);
|
||||
permanent.addPower(value);
|
||||
permanent.addToughness(value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove(); // no longer on the battlefield, remove reference to object
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!perm.getId().equals(source.getSourceId())) {
|
||||
for (Ability ability : perm.getAbilities()) {
|
||||
if (ability instanceof BushidoAbility) {
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
*/
|
||||
package mage.sets.commander2013;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -42,7 +42,6 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
|
@ -112,7 +111,7 @@ class BroodingSaurianControlEffect extends ContinuousEffectImpl {
|
|||
FilterPermanent playerFilter = filter.copy();
|
||||
playerFilter.add(new OwnerIdPredicate(playerId));
|
||||
for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
|
||||
objects.add(permanent.getId());
|
||||
affectedObjectList.add(new MageObjectReference(permanent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,19 +119,17 @@ class BroodingSaurianControlEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> toRemove = new HashSet<UUID>();
|
||||
for (UUID creatureId :objects) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.getControllerId().equals(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game);
|
||||
}
|
||||
} else {
|
||||
toRemove.add(creatureId);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
objects.removeAll(toRemove);
|
||||
if (objects.isEmpty()) {
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
package mage.sets.commander2013;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
|
@ -105,7 +107,7 @@ class HomewardPathControlEffect extends ContinuousEffectImpl {
|
|||
FilterPermanent playerFilter = filter.copy();
|
||||
playerFilter.add(new OwnerIdPredicate(playerId));
|
||||
for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
|
||||
objects.add(permanent.getId());
|
||||
affectedObjectList.add(new MageObjectReference(permanent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,19 +115,17 @@ class HomewardPathControlEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> toRemove = new HashSet<UUID>();
|
||||
for (UUID creatureId :objects) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.getControllerId().equals(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game);
|
||||
}
|
||||
} else {
|
||||
toRemove.add(creatureId);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
objects.removeAll(toRemove);
|
||||
if (objects.isEmpty()) {
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
|
||||
|
@ -99,13 +100,13 @@ class CantBeBlockedByTokenEffect extends RestrictionEffect {
|
|||
public void init(Ability source, Game game) {
|
||||
affectedObjectsSet = true;
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (objects.contains(permanent.getId())) {
|
||||
if (affectedObjectList.contains(new MageObjectReference(permanent))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.sets.guildpact;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -95,32 +97,11 @@ class SetSupertypeAllEffect extends ContinuousEffectImpl {
|
|||
return new SetSupertypeAllEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (affectedObjectsSet) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
objects.add(perm.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (affectedObjectsSet) {
|
||||
for (UUID permanentId :objects) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
if (!permanent.getSupertype().contains("Legendary")) {
|
||||
permanent.getSupertype().add("Legendary");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!permanent.getSupertype().contains("Legendary")) {
|
||||
permanent.getSupertype().add("Legendary");
|
||||
}
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!permanent.getSupertype().contains("Legendary")) {
|
||||
permanent.getSupertype().add("Legendary");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.iceage;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
|
@ -259,12 +260,12 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);;
|
||||
if (permanent != null) {
|
||||
Ability abilityToRemove = null;
|
||||
for (Ability ability: permanent.getAbilities()) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.innistrad;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
|
@ -99,7 +100,7 @@ class PastInFlamesEffect extends ContinuousEffectImpl {
|
|||
for (UUID cardId: player.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY)) {
|
||||
objects.add(cardId);
|
||||
affectedObjectList.add(new MageObjectReference(card));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ class PastInFlamesEffect extends ContinuousEffectImpl {
|
|||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (UUID cardId: player.getGraveyard()) {
|
||||
if (objects.contains(cardId)) {
|
||||
if (affectedObjectList.contains(new MageObjectReference(cardId, game))) {
|
||||
Card card = game.getCard(cardId);
|
||||
FlashbackAbility ability = null;
|
||||
if (card.getCardType().contains(CardType.INSTANT)) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.khansoftarkir;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
|
@ -98,8 +99,6 @@ public class SarkhanTheDragonspeaker extends CardImpl {
|
|||
|
||||
class SarkhanTheDragonspeakerEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected int zoneChangeCounter;
|
||||
|
||||
SarkhanTheDragonspeakerEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.BecomeCreature);
|
||||
staticText = "Until end of turn, {this} becomes a legendary 4/4 red Dragon creature with flying, indestructible, and haste.";
|
||||
|
@ -107,7 +106,6 @@ class SarkhanTheDragonspeakerEffect extends ContinuousEffectImpl {
|
|||
|
||||
SarkhanTheDragonspeakerEffect(final SarkhanTheDragonspeakerEffect effect) {
|
||||
super(effect);
|
||||
this.zoneChangeCounter = effect.zoneChangeCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,17 +116,13 @@ class SarkhanTheDragonspeakerEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
this.getAffectedObjects().add(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
this.zoneChangeCounter = permanent.getZoneChangeCounter();
|
||||
}
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getZoneChangeCounter() == this.zoneChangeCounter) {
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.limitedalpha;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
|
@ -246,12 +247,12 @@ class AnimateDeadChangeAbilityEffect extends ContinuousEffectImpl implements Sou
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
if (permanent != null) {
|
||||
Ability abilityToRemove = null;
|
||||
for (Ability ability: permanent.getAbilities()) {
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
*/
|
||||
package mage.sets.magic2010;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
|
@ -89,24 +91,16 @@ class CoatOfArmsEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
objects.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
if (!this.affectedObjectsSet || objects.contains(permanent.getId())) {
|
||||
int amount = getAmount(permanents, permanent);
|
||||
permanent.addPower(amount);
|
||||
permanent.addToughness(amount);
|
||||
}
|
||||
}
|
||||
int amount = getAmount(permanents, permanent);
|
||||
permanent.addPower(amount);
|
||||
permanent.addToughness(amount);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.sets.magic2015;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -89,26 +91,31 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl {
|
|||
return new PolymorphistsJestEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, getTargetPointer().getFirst(game, source), game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
objects.clear();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, getTargetPointer().getFirst(game, source), game)){
|
||||
if(permanent != null){
|
||||
objects.add(permanent.getId());
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getSubtype().clear();
|
||||
permanent.getSubtype().add("Frog");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ColorChangingEffects_5:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null){
|
||||
|
||||
break;
|
||||
case ColorChangingEffects_5:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getColor().setBlack(false);
|
||||
permanent.getColor().setGreen(false);
|
||||
permanent.getColor().setBlue(false);
|
||||
|
@ -116,27 +123,19 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl {
|
|||
permanent.getColor().setBlack(false);
|
||||
permanent.getColor().setColor(ObjectColor.BLUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null){
|
||||
break;
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if(permanent != null){
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setValue(1);
|
||||
permanent.getToughness().setValue(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -146,10 +145,9 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.PTChangingEffects_7 || layer == Layer.ColorChangingEffects_5 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
|
||||
return layer == Layer.PTChangingEffects_7 || layer == Layer.ColorChangingEffects_5 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,16 +27,19 @@
|
|||
*/
|
||||
package mage.sets.ninthedition;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import static mage.constants.Layer.PTChangingEffects_7;
|
||||
import static mage.constants.Layer.TypeChangingEffects_4;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -90,7 +93,7 @@ class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
|||
super.init(source, game);
|
||||
this.affectedObjectsSet = true;
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game)) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,10 +102,12 @@ class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if(permanent != null){
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,11 +115,13 @@ class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
|||
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if(permanent != null){
|
||||
permanent.getPower().setValue(2);
|
||||
permanent.getToughness().setValue(2);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,4 +140,4 @@ class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
|||
return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.odyssey;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
|
@ -91,7 +91,6 @@ class TestamentOfFaithBecomesCreatureSourceEffect extends ContinuousEffectImpl i
|
|||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
this.type = effect.type;
|
||||
this.zoneChangeCounter = effect.zoneChangeCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,17 +101,13 @@ class TestamentOfFaithBecomesCreatureSourceEffect extends ContinuousEffectImpl i
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
this.getAffectedObjects().add(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
this.zoneChangeCounter = permanent.getZoneChangeCounter();
|
||||
}
|
||||
this.getAffectedObjects().add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getZoneChangeCounter() == this.zoneChangeCounter) {
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
|
@ -151,10 +146,8 @@ class TestamentOfFaithBecomesCreatureSourceEffect extends ContinuousEffectImpl i
|
|||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
MageInt power = new MageInt(source.getManaCosts().getVariableCosts().get(0).getAmount());
|
||||
MageInt toughness = new MageInt(source.getManaCosts().getVariableCosts().get(0).getAmount());
|
||||
if (power != null && toughness != null) {
|
||||
permanent.getPower().setValue(power.getValue());
|
||||
permanent.getToughness().setValue(toughness.getValue());
|
||||
}
|
||||
permanent.getPower().setValue(power.getValue());
|
||||
permanent.getToughness().setValue(toughness.getValue());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -100,11 +100,11 @@ class CrownOfConvergenceColorBoostEffect extends BoostAllEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
Card topCard = you.getLibrary().getFromTop(game);
|
||||
if (you != null && topCard != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (permanent.getColor().shares(topCard.getColor()) && !permanent.getColor().isColorless()) {
|
||||
if (!this.affectedObjectsSet || objects.contains(permanent.getId())) {
|
||||
if (you != null) {
|
||||
Card topCard = you.getLibrary().getFromTop(game);
|
||||
if (topCard != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (permanent.getColor().shares(topCard.getColor()) && !permanent.getColor().isColorless()) {
|
||||
permanent.addPower(power.calculate(game, source, this));
|
||||
permanent.addToughness(toughness.calculate(game, source, this));
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ import mage.watchers.Watcher;
|
|||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
|
@ -64,11 +66,9 @@ public class CastThroughTime extends CardImpl {
|
|||
super(ownerId, 55, "Cast Through Time", Rarity.MYTHIC, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}{U}");
|
||||
this.expansionSetCode = "ROE";
|
||||
|
||||
this.color.setBlue(true);
|
||||
|
||||
// Instant and sorcery spells you control have rebound.
|
||||
// (Exile the spell as it resolves if you cast it from your hand. At the beginning of your next upkeep, you may cast that card from exile without paying its mana cost.)
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainReboundEffect()));
|
||||
|
||||
this.addWatcher(new LeavesBattlefieldWatcher());
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class GainReboundEffect extends ContinuousEffectImpl {
|
|||
|
||||
public GainReboundEffect() {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "Instant and sorcery spells you control have rebound";
|
||||
staticText = "Instant and sorcery spells you control have rebound <i>(Exile the spell as it resolves if you cast it from your hand. At the beginning of your next upkeep, you may cast that card from exile without paying its mana cost.)</i>";
|
||||
}
|
||||
|
||||
public GainReboundEffect(final GainReboundEffect effect) {
|
||||
|
@ -104,27 +104,42 @@ class GainReboundEffect extends ContinuousEffectImpl {
|
|||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
for (Card card : player.getHand().getCards(CastThroughTime.filter, game)) {
|
||||
boolean found = false;
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ReboundAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Ability ability = new AttachedReboundAbility();
|
||||
card.addAbility(ability);
|
||||
ability.setControllerId(source.getControllerId());
|
||||
ability.setSourceId(card.getId());
|
||||
game.getState().addAbility(ability, source.getSourceId(), card);
|
||||
}
|
||||
addReboundAbility(card, source, game);
|
||||
}
|
||||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||
StackObject stackObject = iterator.next();
|
||||
if (stackObject instanceof Spell && stackObject.getControllerId().equals(source.getControllerId())) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
Card card = spell.getCard();
|
||||
if (card != null) {
|
||||
addReboundAbility(card, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addReboundAbility(Card card, Ability source, Game game) {
|
||||
if (CastThroughTime.filter.match(card, game)) {
|
||||
boolean found = false;
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ReboundAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Ability ability = new AttachedReboundAbility();
|
||||
card.addAbility(ability);
|
||||
ability.setControllerId(source.getControllerId());
|
||||
ability.setSourceId(card.getId());
|
||||
game.getState().addAbility(ability, card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AttachedReboundAbility extends ReboundAbility {}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
|
@ -38,6 +39,7 @@ import mage.constants.Rarity;
|
|||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -130,8 +132,8 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
for (UUID permId: objects) {
|
||||
Permanent perm = game.getPermanent(permId);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent perm = it.next().getPermanent(game);
|
||||
if (perm != null) {
|
||||
if (perm.getCounters().getCount(CounterType.AWAKENING) > 0) {
|
||||
switch (layer) {
|
||||
|
@ -154,6 +156,8 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -169,7 +173,7 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
|
|||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
for (UUID permId: targetPointer.getTargets(game, source)) {
|
||||
objects.add(permId);
|
||||
affectedObjectList.add(new MageObjectReference(permId, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.sets.tenth;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
|
||||
import mage.constants.*;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -91,10 +93,10 @@ class MarchOfTheMachinesEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
objects.clear();
|
||||
affectedObjectList.clear();
|
||||
for(Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)){
|
||||
if(permanent != null){
|
||||
objects.add(permanent.getId());
|
||||
affectedObjectList.add(new MageObjectReference(permanent));
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +105,9 @@ class MarchOfTheMachinesEffect extends ContinuousEffectImpl {
|
|||
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if(permanent != null){
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null){
|
||||
int manaCost = permanent.getManaCost().convertedManaCost();
|
||||
permanent.getPower().setValue(manaCost);
|
||||
permanent.getToughness().setValue(manaCost);
|
||||
|
@ -127,4 +129,4 @@ class MarchOfTheMachinesEffect extends ContinuousEffectImpl {
|
|||
return layer == Layer.PTChangingEffects_7 || layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.timespiral;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.SplitSecondAbility;
|
||||
|
@ -96,7 +97,7 @@ class SuddenSpoilingEffect extends ContinuousEffectImpl {
|
|||
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
for (Permanent perm: game.getState().getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,17 +107,17 @@ class SuddenSpoilingEffect extends ContinuousEffectImpl {
|
|||
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) {
|
||||
switch (layer) {
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer.equals(SubLayer.SetPT_7b)) {
|
||||
if(objects.contains(permanent.getId())){
|
||||
permanent.getPower().setValue(0);
|
||||
permanent.getToughness().setValue(2);
|
||||
if (affectedObjectList.contains(new MageObjectReference(permanent))) {
|
||||
switch (layer) {
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer.equals(SubLayer.SetPT_7b)) {
|
||||
permanent.getPower().setValue(0);
|
||||
permanent.getToughness().setValue(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.sets.urzasdestiny;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -99,30 +101,24 @@ class OpalescenceEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
objects.clear();
|
||||
for(Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)){
|
||||
objects.add(permanent.getId());
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
if (!permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
for(UUID uuid : objects){
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if(permanent != null){
|
||||
int manaCost = permanent.getManaCost().convertedManaCost();
|
||||
permanent.getPower().setValue(manaCost);
|
||||
permanent.getToughness().setValue(manaCost);
|
||||
}
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
int manaCost = permanent.getManaCost().convertedManaCost();
|
||||
permanent.getPower().setValue(manaCost);
|
||||
permanent.getToughness().setValue(manaCost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.visions;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
|
@ -313,12 +314,12 @@ class NecromancyChangeAbilityEffect extends ContinuousEffectImpl implements Sour
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);;
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
|
|
|
@ -104,29 +104,14 @@ class ArmamentMasterEffect extends ContinuousEffectImpl {
|
|||
return new ArmamentMasterEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent perm : permanents) {
|
||||
if (!perm.getId().equals(source.getSourceId())) {
|
||||
objects.add(perm.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int count = countEquipment(game, source);
|
||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent perm : permanents) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (!perm.getId().equals(source.getSourceId())) {
|
||||
perm.addPower(2 * count);
|
||||
perm.addToughness(2 * count);
|
||||
}
|
||||
if (!perm.getId().equals(source.getSourceId())) {
|
||||
perm.addPower(2 * count);
|
||||
perm.addToughness(2 * count);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.KickedCondition;
|
||||
import mage.abilities.decorator.ConditionalContinousEffect;
|
||||
|
@ -40,6 +41,7 @@ import mage.target.TargetPlayer;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
|
||||
/**
|
||||
|
@ -80,8 +82,8 @@ public class MarshCasualties extends CardImpl {
|
|||
|
||||
class MarshCasualtiesEffect extends ContinuousEffectImpl {
|
||||
|
||||
private int power;
|
||||
private int toughness;
|
||||
private final int power;
|
||||
private final int toughness;
|
||||
|
||||
public MarshCasualtiesEffect(int power, int toughness) {
|
||||
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
|
@ -104,20 +106,21 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl {
|
|||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
objects.add(creature.getId());
|
||||
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game)) {
|
||||
affectedObjectList.add(new MageObjectReference(creature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
if (!this.affectedObjectsSet || objects.contains(creature.getId())) {
|
||||
creature.addPower(power);
|
||||
creature.addToughness(toughness);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
permanent.addPower(power);
|
||||
permanent.addToughness(toughness);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -17,6 +17,9 @@ public class EvernightShadeTest extends CardTestPlayerBase {
|
|||
public void testBoostWithUndying() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
|
||||
// Evernight Shade Creature - Shade 1/1 {3}{B}
|
||||
// {B}: Evernight Shade gets +1/+1 until end of turn.
|
||||
// Undying (When this creature dies, if it had no +1/+1 counters on it, return it to the battlefield under its owner's control with a +1/+1 counter on it.)
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Evernight Shade");
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt");
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ package org.mage.test.combat;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.permanent.Permanent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
|
|
@ -128,4 +128,12 @@ public class MageObjectReference implements Comparable<MageObjectReference> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Card getCard(Game game) {
|
||||
Card card = game.getPermanent(sourceId);
|
||||
if (card != null && card.getZoneChangeCounter() == zoneChangeCounter) {
|
||||
return card;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,16 +28,14 @@
|
|||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.List;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -57,7 +55,7 @@ public interface ContinuousEffect extends Effect {
|
|||
Layer getLayer();
|
||||
SubLayer getSublayer();
|
||||
void overrideRuleText(String text);
|
||||
List<UUID> getAffectedObjects();
|
||||
List<MageObjectReference> getAffectedObjects();
|
||||
|
||||
@Override
|
||||
void newId();
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
|
@ -49,7 +50,6 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
|
||||
protected Token token;
|
||||
protected String type;
|
||||
protected int zoneChangeCounter;
|
||||
|
||||
public BecomesCreatureSourceEffect(Token token, String type, Duration duration) {
|
||||
super(duration, Outcome.BecomeCreature);
|
||||
|
@ -62,7 +62,6 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
this.type = effect.type;
|
||||
this.zoneChangeCounter = effect.zoneChangeCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,17 +72,20 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
this.getAffectedObjects().add(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
this.zoneChangeCounter = permanent.getZoneChangeCounter();
|
||||
if (affectedObjectsSet) {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getZoneChangeCounter() == this.zoneChangeCounter) {
|
||||
Permanent permanent;
|
||||
if (affectedObjectsSet) {
|
||||
permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
} else {
|
||||
permanent = game.getPermanent(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
|
|
|
@ -61,7 +61,6 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
|
|||
|
||||
protected Map<UUID,Ability> turnFaceUpAbilityMap = new HashMap<>();
|
||||
protected FilterPermanent filter;
|
||||
protected ArrayList<MageObjectReference> objectList = new ArrayList<>();
|
||||
|
||||
public BecomesFaceDownCreatureAllEffect(FilterPermanent filter) {
|
||||
super(Duration.EndOfGame, Outcome.BecomeCreature);
|
||||
|
@ -71,7 +70,6 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
|
|||
|
||||
public BecomesFaceDownCreatureAllEffect(final BecomesFaceDownCreatureAllEffect effect) {
|
||||
super(effect);
|
||||
this.objectList.addAll(effect.objectList);
|
||||
for (Map.Entry<UUID,Ability> entry: effect.turnFaceUpAbilityMap.entrySet()) {
|
||||
this.turnFaceUpAbilityMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -88,7 +86,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
|
|||
super.init(source, game);
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!perm.isFaceDown()) {
|
||||
objectList.add(new MageObjectReference(perm));
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
perm.setFaceDown(true);
|
||||
// check for Morph
|
||||
Card card = game.getCard(perm.getId());
|
||||
|
@ -106,7 +104,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
|
|||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
boolean targetExists = false;
|
||||
for (MageObjectReference mor: objectList) {
|
||||
for (MageObjectReference mor: affectedObjectList) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null && permanent.isFaceDown()) {
|
||||
targetExists = true;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -113,7 +113,7 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,9 +126,8 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Iterator<UUID> it = objects.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||
UUID permanentId = it.next();
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
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);
|
||||
if (permanent != null) {
|
||||
permanent.addPower(power.calculate(game, source, this));
|
||||
permanent.addToughness(toughness.calculate(game, source, this));
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
|
@ -116,7 +116,7 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,9 +129,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Iterator<UUID> it = objects.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||
UUID permanentId = it.next();
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
permanent.addPower(power.calculate(game, source, this));
|
||||
permanent.addToughness(toughness.calculate(game, source, this));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
|
@ -12,6 +13,7 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
|
||||
public class BoostOpponentsEffect extends ContinuousEffectImpl {
|
||||
protected int power;
|
||||
|
@ -49,7 +51,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl {
|
|||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (opponents.contains(perm.getControllerId())) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +60,20 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (this.affectedObjectsSet) {
|
||||
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);
|
||||
if (perm != null) {
|
||||
if (opponents.contains(perm.getControllerId())) {
|
||||
perm.addPower(power);
|
||||
perm.addToughness(toughness);
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (opponents.contains(perm.getControllerId())) {
|
||||
perm.addPower(power);
|
||||
perm.addToughness(toughness);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
|
@ -85,7 +86,9 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
if (affectedObjectsSet) {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
if (lockedIn) {
|
||||
power = new StaticValue(power.calculate(game, source, this));
|
||||
toughness = new StaticValue(toughness.calculate(game, source, this));
|
||||
|
@ -94,7 +97,12 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent target = game.getPermanent(source.getSourceId());
|
||||
Permanent target;
|
||||
if (affectedObjectsSet) {
|
||||
target = affectedObjectList.get(0).getPermanent(game);
|
||||
} else {
|
||||
target = game.getPermanent(source.getSourceId());
|
||||
}
|
||||
if (target != null) {
|
||||
target.addPower(power.calculate(game, source, this));
|
||||
target.addToughness(toughness.calculate(game, source, this));
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -84,7 +86,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +99,17 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (this.affectedObjectsSet) {
|
||||
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);
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
} else {
|
||||
it.remove(); // no longer on the battlefield, remove reference to object
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
perm.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -89,7 +91,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +104,19 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (this.affectedObjectsSet) {
|
||||
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);
|
||||
if (perm != null) {
|
||||
for (Ability abilityToAdd : ability) {
|
||||
perm.addAbility(abilityToAdd, source.getSourceId(), game);
|
||||
}
|
||||
} else {
|
||||
it.remove(); // no longer on the battlefield, remove reference to object
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
for (Ability abilityToAdd : ability) {
|
||||
perm.addAbility(abilityToAdd, source.getSourceId(), game);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
|
@ -90,13 +91,20 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
if (affectedObjectsSet) {
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (onCard) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
Card card;
|
||||
if (affectedObjectsSet) {
|
||||
card = affectedObjectList.get(0).getCard(game);
|
||||
} else {
|
||||
card = game.getCard(source.getSourceId());
|
||||
}
|
||||
if (card != null) {
|
||||
// add ability to card only once
|
||||
card.addAbility(ability);
|
||||
|
@ -104,15 +112,20 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent;
|
||||
if (affectedObjectsSet) {
|
||||
permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
} else {
|
||||
permanent = game.getPermanent(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
if (duration.equals(Duration.Custom)) {
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (duration.equals(Duration.Custom)) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,22 +29,21 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Locale;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -139,8 +138,16 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
} else {
|
||||
for (UUID permanentId : targetPointer.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
boolean shortLivingLKI = false;
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getShortLivingLKI(permanentId, Zone.BATTLEFIELD);
|
||||
shortLivingLKI = true;
|
||||
}
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
if (shortLivingLKI) { // needed for undying because TriggeredAbilities checks if the permanent has still the ability
|
||||
game.rememberLKI(permanentId, Zone.BATTLEFIELD, permanent);
|
||||
}
|
||||
affectedTargets++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
|
||||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
|
@ -89,7 +91,7 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl {
|
|||
super.init(source, game);
|
||||
if (affectedObjectsSet) {
|
||||
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
objects.add(perm.getId());
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
if (lockedInPT) {
|
||||
|
@ -103,11 +105,13 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl {
|
|||
int newPower = power.calculate(game, source, this);
|
||||
int newToughness = toughness.calculate(game, source, this);
|
||||
if (affectedObjectsSet) {
|
||||
for (UUID permanentId :objects) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
permanent.getPower().setValue(newPower);
|
||||
permanent.getToughness().setValue(newToughness);
|
||||
} else {
|
||||
it.remove(); // no longer on the battlefield, remove reference to object
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -71,8 +73,8 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
|
|||
if (this.affectedObjectsSet) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
this.objects.add(creature.getId());
|
||||
for (Permanent perm :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
affectedObjectList.add(new MageObjectReference(perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,18 +85,16 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (this.affectedObjectsSet) {
|
||||
Set<UUID> toDelete = new HashSet<>();
|
||||
for (UUID creatureId: objects) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
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 creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
int power = creature.getPower().getValue();
|
||||
creature.getPower().setValue(creature.getToughness().getValue());
|
||||
creature.getToughness().setValue(power);
|
||||
} else {
|
||||
toDelete.add(creatureId);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
this.objects.removeAll(toDelete);
|
||||
}
|
||||
} else {
|
||||
for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
int power = creature.getPower().getValue();
|
||||
|
|
Loading…
Add table
Reference in a new issue