move zoneChangeCounter to GameState - Card is now immutable

This commit is contained in:
betasteward 2015-03-29 08:30:31 -04:00
parent 45aa5f675c
commit 6405c8d2f0
101 changed files with 899 additions and 257 deletions

View file

@ -108,7 +108,7 @@ class DayEffect extends ContinuousEffectImpl {
if (this.affectedObjectsSet) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
for (Permanent creature : creatures) {
affectedObjectList.add(new MageObjectReference(creature));
affectedObjectList.add(new MageObjectReference(creature, game));
}
}
}

View file

@ -127,7 +127,7 @@ class AggravateRequirementEffect extends RequirementEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
if (watcher != null) {
return watcher.wasDamaged(permanent);
return watcher.wasDamaged(permanent, game);
}
return false;
}

View file

@ -79,7 +79,7 @@ class SecondSpellPredicate implements Predicate<Spell> {
public boolean apply(Spell input, Game game) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
if (watcher.getSpellOrder(input) == 2) {
if (watcher.getSpellOrder(input, game) == 2) {
return true;
}

View file

@ -129,7 +129,7 @@ class KumanosBlessingEffect extends ReplacementEffectImpl {
if (zce.isDiesEvent()) {
DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatchers().get("DamagedByEnchantedWatcher", source.getSourceId());
if (watcher != null) {
return watcher.wasDamaged(zce.getTarget());
return watcher.wasDamaged(zce.getTarget(), game);
}
}
}
@ -177,7 +177,7 @@ class DamagedByEnchantedWatcher extends Watcher {
damagedCreatures.clear();
}
public boolean wasDamaged(Permanent permanent) {
return damagedCreatures.contains(new MageObjectReference(permanent));
public boolean wasDamaged(Permanent permanent, Game game) {
return damagedCreatures.contains(new MageObjectReference(permanent, game));
}
}

View file

@ -85,12 +85,12 @@ class BileBlightEffect extends BoostAllEffect {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
if (target.getName().isEmpty()) { // face down creature
affectedObjectList.add(new MageObjectReference(target));
affectedObjectList.add(new MageObjectReference(target, game));
} else {
String name = target.getLogName();
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (perm.getLogName().equals(name)) {
affectedObjectList.add(new MageObjectReference(perm));
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
}

View file

@ -123,7 +123,7 @@ class GainProtectionFromColorSourceEffect extends GainAbilitySourceEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(permanent).refersTo(source.getSourceObject(game))) {
if (permanent != null && new MageObjectReference(permanent, game).refersTo(source.getSourceObject(game), game)) {
permanent.addAbility(ability, source.getSourceId(), game);
} else {
// the source permanent is no longer on the battlefield, effect can be discarded

View file

@ -103,7 +103,7 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl {
if (!perm.getId().equals(source.getSourceId())) {
for (Ability ability : perm.getAbilities()) {
if (ability instanceof BushidoAbility) {
affectedObjectList.add(new MageObjectReference(perm));
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
}

View file

@ -111,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)) {
affectedObjectList.add(new MageObjectReference(permanent));
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}

View file

@ -107,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)) {
affectedObjectList.add(new MageObjectReference(permanent));
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}

View file

@ -113,7 +113,7 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect {
if (controller != null && sourceCard != null) {
JelevaNephaliasWatcher watcher = (JelevaNephaliasWatcher) game.getState().getWatchers().get("ManaPaidToCastJelevaNephalias", source.getSourceId());
if (watcher != null) {
int xValue = watcher.getManaSpentToCastLastTime(sourceCard.getZoneChangeCounter() - 1);
int xValue = watcher.getManaSpentToCastLastTime(sourceCard.getZoneChangeCounter(game) - 1);
if (xValue > 0) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
@ -195,8 +195,8 @@ class JelevaNephaliasWatcher extends Watcher {
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && ((Spell)stackObject).getSourceId().equals(sourceId)) {
Card card = game.getCard(sourceId);
if (!manaSpendToCast.containsValue(card.getZoneChangeCounter())) {
manaSpendToCast.put(new Integer(card.getZoneChangeCounter()), new Integer(((Spell)stackObject).getSpellAbility().getManaCostsToPay().convertedManaCost()));
if (!manaSpendToCast.containsValue(card.getZoneChangeCounter(game))) {
manaSpendToCast.put(new Integer(card.getZoneChangeCounter(game)), new Integer(((Spell)stackObject).getSpellAbility().getManaCostsToPay().convertedManaCost()));
}
}
}

View file

@ -143,7 +143,7 @@ class LivingLoreSetPowerToughnessSourceEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
MageObject mageObject = source.getSourceObject(game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && mageObject == null && new MageObjectReference(permanent).refersTo(mageObject)) {
if (permanent != null && mageObject == null && new MageObjectReference(permanent, game).refersTo(mageObject, game)) {
discard();
return false;
}
@ -190,7 +190,7 @@ class LivingLoreSacrificeEffect extends OneShotEffect {
if (controller != null) {
MageObject mageObject = source.getSourceObject(game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && mageObject != null && new MageObjectReference(permanent).refersTo(mageObject)) {
if (permanent != null && mageObject != null && new MageObjectReference(permanent, game).refersTo(mageObject, game)) {
if (permanent.sacrifice(source.getSourceId(), game)) {
UUID exileId = CardUtil.getObjectExileZoneId(game, mageObject);
if (exileId != null) {

View file

@ -130,7 +130,7 @@ class MythRealizedSetPTEffect extends ContinuousEffectImpl {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(source.getSourceObject(game)).refersTo(permanent)) {
if (permanent != null && new MageObjectReference(source.getSourceObject(game), game).refersTo(permanent, game)) {
int amount = permanent.getCounters().getCount(CounterType.LORE);
permanent.getPower().setValue(amount);
permanent.getToughness().setValue(amount);

View file

@ -133,7 +133,7 @@ class GainProtectionFromColorSourceEffect extends GainAbilitySourceEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(permanent).refersTo(source.getSourceObject(game))) {
if (permanent != null && new MageObjectReference(permanent, game).refersTo(source.getSourceObject(game), game)) {
permanent.addAbility(ability, source.getSourceId(), game);
} else {
// the source permanent is no longer on the battlefield, effect can be discarded

View file

@ -112,7 +112,7 @@ class GhastlyConscriptionEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(controller.getName())

View file

@ -133,7 +133,7 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(player.getName())

View file

@ -124,7 +124,7 @@ class UnboostCreaturesTargetPlayerEffect extends ContinuousEffectImpl {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), getTargetPointer().getFirst(game, source), game)) {
affectedObjectList.add(new MageObjectReference(creature));
affectedObjectList.add(new MageObjectReference(creature, game));
}
}
}

View file

@ -123,9 +123,9 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (objectReference == null || !objectReference.refersTo(permanent)) {
if (objectReference == null || !objectReference.refersTo(permanent, game)) {
abilitiesToAdd = new HashSet<>();
this.objectReference = new MageObjectReference(permanent);
this.objectReference = new MageObjectReference(permanent, game);
String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game, true);
List<Card> delvedCards = (List<Card>) game.getState().getValue(keyString);
if (delvedCards != null) {

View file

@ -132,9 +132,9 @@ class JuxtaposeEffect extends ContinuousEffectImpl {
return;
}
this.lockedControllers.put(permanent1.getId(), permanent2.getControllerId());
this.zoneChangeCounter.put(permanent1.getId(), permanent1.getZoneChangeCounter());
this.zoneChangeCounter.put(permanent1.getId(), permanent1.getZoneChangeCounter(game));
this.lockedControllers.put(permanent2.getId(), permanent1.getControllerId());
this.zoneChangeCounter.put(permanent2.getId(), permanent2.getZoneChangeCounter());
this.zoneChangeCounter.put(permanent2.getId(), permanent2.getZoneChangeCounter(game));
permanent1.changeControllerId(targetPlayer.getId(), game);
permanent2.changeControllerId(you.getId(), game);
@ -153,7 +153,7 @@ class JuxtaposeEffect extends ContinuousEffectImpl {
Set<UUID> toDelete = new HashSet<>();
for (Map.Entry<UUID, Integer> entry : zoneChangeCounter.entrySet()) {
Permanent permanent = game.getPermanent(entry.getKey());
if (permanent == null || permanent.getZoneChangeCounter() != entry.getValue()) {
if (permanent == null || permanent.getZoneChangeCounter(game) != entry.getValue()) {
// controll effect cease if the same permanent is no longer on the battlefield
toDelete.add(entry.getKey());
continue;

View file

@ -137,7 +137,7 @@ class TheWretchedEffect extends OneShotEffect {
BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher");
if (watcher != null) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
if (watcher.creatureHasBlockedAttacker(theWretched, creature)
if (watcher.creatureHasBlockedAttacker(theWretched, creature, game)
&& !creature.isRemovedFromCombat()) {
ContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, source.getControllerId()), new SourceOnBattlefieldControlUnchangedCondition(), "test");
effect.setTargetPointer(new FixedTarget(creature.getId()));

View file

@ -96,7 +96,7 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl {
watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get("consumeScoutsWarningWatcher", source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (watcher != null && card != null) {
zoneChangeCounter = card.getZoneChangeCounter();
zoneChangeCounter = card.getZoneChangeCounter(game);
watcher.addScoutsWarningSpell(source.getSourceId(), zoneChangeCounter);
}
}

View file

@ -110,32 +110,32 @@ class AureliaAttacksTriggeredAbility extends TriggeredAbilityImpl {
@Override
public void reset(Game game) {
Card sourceCard = game.getCard(getSourceId());
game.getState().setValue(getValueKey(sourceCard), new Integer(0));
game.getState().setValue(getValueKey(sourceCard, game), new Integer(0));
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId()) ) {
Card sourceCard = game.getCard(getSourceId());
Integer amountAttacks = (Integer) game.getState().getValue(getValueKey(sourceCard));
Integer amountAttacks = (Integer) game.getState().getValue(getValueKey(sourceCard, game));
if (amountAttacks == null || amountAttacks.intValue() < 1) {
if (amountAttacks == null) {
amountAttacks = new Integer(1);
} else {
++amountAttacks;
}
game.getState().setValue(getValueKey(sourceCard), amountAttacks);
game.getState().setValue(getValueKey(sourceCard, game), amountAttacks);
return true;
}
}
return false;
}
protected String getValueKey(Card sourceCard) {
protected String getValueKey(Card sourceCard, Game game) {
if (sourceCard == null) {
return "";
}
return new StringBuilder(this.getId().toString()).append(sourceCard.getZoneChangeCounter()).append("amountAttacks").toString();
return new StringBuilder(this.getId().toString()).append(sourceCard.getZoneChangeCounter(game)).append("amountAttacks").toString();
}
@Override

View file

@ -100,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)) {
affectedObjectList.add(new MageObjectReference(perm));
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (affectedObjectList.contains(new MageObjectReference(permanent))) {
if (affectedObjectList.contains(new MageObjectReference(permanent, game))) {
return true;
}
return false;

View file

@ -97,7 +97,7 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl {
quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get("consumeQuickenWatcher", source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (quickenWatcher != null && card != null) {
zoneChangeCounter = card.getZoneChangeCounter();
zoneChangeCounter = card.getZoneChangeCounter(game);
quickenWatcher.addQuickenSpell(source.getSourceId(), zoneChangeCounter);
}
}

View file

@ -100,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)) {
affectedObjectList.add(new MageObjectReference(card));
affectedObjectList.add(new MageObjectReference(card, game));
}
}
}

View file

@ -191,7 +191,7 @@ class GodsendExileEffect extends OneShotEffect {
if (creature != null && controller != null && sourcePermanent != null) {
UUID exileId = CardUtil.getCardExileZoneId(game, source);
controller.moveCardToExileWithInfo(creature, exileId,
new StringBuilder(sourcePermanent.getName()).append(" (").append(sourcePermanent.getZoneChangeCounter()).append(")").toString()
new StringBuilder(sourcePermanent.getName()).append(" (").append(sourcePermanent.getZoneChangeCounter(game)).append(")").toString()
, source.getSourceId(), game, Zone.BATTLEFIELD);
}

View file

@ -110,15 +110,15 @@ class AshlingThePilgrimEffect extends OneShotEffect {
Object object = game.getState().getValue(source.getSourceId() + "ActivationInfo");
if (object instanceof ActivationInfo) {
info = (ActivationInfo) object;
if (info.turn != game.getTurnNum() || sourcePermanent.getZoneChangeCounter() != info.zoneChangeCounter) {
if (info.turn != game.getTurnNum() || sourcePermanent.getZoneChangeCounter(game) != info.zoneChangeCounter) {
info.turn = game.getTurnNum();
info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter();
info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter(game);
info.activations = 0;
}
} else {
info = new ActivationInfo();
info.turn = game.getTurnNum();
info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter();
info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter(game);
game.getState().setValue(source.getSourceId() + "ActivationInfo", info);
}
info.activations++;

View file

@ -115,7 +115,7 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl {
// even if Vengeful Pharaoh is put back into your graveyard before it tries to resolve, as it's a
// different Vengeful Pharaoh than the one that was there before.
MageObjectReference mor = new MageObjectReference(getSourceId(), game);
return mor.refersTo(this.getSourceObject(game));
return mor.refersTo(this.getSourceObject(game), game);
}
@Override

View file

@ -110,7 +110,7 @@ class SavageSummoningAsThoughEffect extends AsThoughEffectImpl {
watcher = (SavageSummoningWatcher) game.getState().getWatchers().get("consumeSavageSummoningWatcher", source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (watcher != null && card != null) {
watcher.setSavageSummoningSpellActive(card);
watcher.setSavageSummoningSpellActive(card, game);
} else {
throw new IllegalArgumentException("Consume Savage watcher could not be found");
}
@ -174,7 +174,7 @@ class SavageSummoningWatcher extends Watcher {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && spell.getCardType().contains(CardType.CREATURE)) {
spellsCastWithSavageSummoning.put(spell.getId(), new HashSet<>(savageSummoningSpells));
String cardKey = new StringBuilder(spell.getCard().getId().toString()).append("_").append(spell.getCard().getZoneChangeCounter()).toString();
String cardKey = new StringBuilder(spell.getCard().getId().toString()).append("_").append(spell.getCard().getZoneChangeCounter(game)).toString();
cardsCastWithSavageSummoning.put(cardKey, new HashSet<>(savageSummoningSpells));
savageSummoningSpells.clear();
}
@ -182,8 +182,8 @@ class SavageSummoningWatcher extends Watcher {
}
}
public void setSavageSummoningSpellActive(Card card) {
String cardKey = new StringBuilder(card.getId().toString()).append("_").append(card.getZoneChangeCounter()).toString();
public void setSavageSummoningSpellActive(Card card, Game game) {
String cardKey = new StringBuilder(card.getId().toString()).append("_").append(card.getZoneChangeCounter(game)).toString();
savageSummoningSpells.add(cardKey);
}
@ -200,8 +200,8 @@ class SavageSummoningWatcher extends Watcher {
return false;
}
public boolean isCardCastWithThisSavageSummoning(Card card, UUID cardId, int zoneChangeCounter) {
String creatureCardKey = new StringBuilder(card.getId().toString()).append("_").append(card.getZoneChangeCounter()-1).toString();
public boolean isCardCastWithThisSavageSummoning(Card card, UUID cardId, int zoneChangeCounter, Game game) {
String creatureCardKey = new StringBuilder(card.getId().toString()).append("_").append(card.getZoneChangeCounter(game)-1).toString();
// add one because card is now gone to battlefield as creature
String cardKey = new StringBuilder(cardId.toString()).append("_").append(zoneChangeCounter).toString();
HashSet<String> savageSpells = (HashSet<String>) cardsCastWithSavageSummoning.get(creatureCardKey);
@ -243,7 +243,7 @@ class SavageSummoningCantCounterEffect extends ContinuousRuleModifyingEffectImpl
if (watcher == null || card == null) {
throw new IllegalArgumentException("Consume Savage watcher or card could not be found");
}
this.zoneChangeCounter = card.getZoneChangeCounter();
this.zoneChangeCounter = card.getZoneChangeCounter(game);
}
@Override
@ -300,7 +300,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl {
if (watcher == null || card == null) {
throw new IllegalArgumentException("Consume Savage watcher or card could not be found");
}
this.zoneChangeCounter = card.getZoneChangeCounter();
this.zoneChangeCounter = card.getZoneChangeCounter(game);
}
@Override
@ -327,7 +327,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD)) {
Card card = game.getCard(event.getTargetId());
if (card != null && watcher.isCardCastWithThisSavageSummoning(card, source.getSourceId(), zoneChangeCounter)) {
if (card != null && watcher.isCardCastWithThisSavageSummoning(card, source.getSourceId(), zoneChangeCounter, game)) {
return true;
}
}

View file

@ -96,7 +96,7 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, getTargetPointer().getFirst(game, source), game)) {
affectedObjectList.add(new MageObjectReference(permanent));
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}

View file

@ -117,7 +117,7 @@ class ScytheOfTheWretchedTriggeredAbility extends TriggeredAbilityImpl {
return false;
}
for (MageObjectReference mor : zoneChange.getTarget().getDealtDamageByThisTurn()) {
if (mor.refersTo(equippedCreature)) {
if (mor.refersTo(equippedCreature, game)) {
setTarget(new FixedTarget(event.getTargetId()));
return true;
}

View file

@ -127,7 +127,7 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND)) {
card.addCounters(CounterType.TIME.createInstance(4), game);
if (!hasSuspend) {
game.addEffect(new JhoiraGainSuspendEffect(new MageObjectReference(card)), source);
game.addEffect(new JhoiraGainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getName() + " suspends 4 - " + card.getName());
return true;
@ -160,7 +160,7 @@ class JhoiraGainSuspendEffect extends ContinuousEffectImpl implements SourceEffe
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(mor.getSourceId());
if (card != null && mor.refersTo(card) && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
if (card != null && mor.refersTo(card, game) && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
SuspendAbility.addSuspendTemporaryToCard(card, source, game);
} else {
discard();

View file

@ -93,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)) {
affectedObjectList.add(new MageObjectReference(perm));
affectedObjectList.add(new MageObjectReference(perm, game));
}
}

View file

@ -123,12 +123,12 @@ class RallyTheRighteousBoostEffect extends ContinuousEffectImpl {
super.init(source, game);
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
affectedObjectList.add(new MageObjectReference(target));
affectedObjectList.add(new MageObjectReference(target, game));
ObjectColor color = target.getColor();
target.addPower(2);
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
if (!permanent.getId().equals(target.getId()) && permanent.getColor().shares(color)) {
affectedObjectList.add(new MageObjectReference(permanent));
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}

View file

@ -108,7 +108,7 @@ class GraveBetrayalTriggeredAbility extends TriggeredAbilityImpl {
if (card != null) {
Effect effect = new GraveBetrayalEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
Integer zoneChanges = card.getZoneChangeCounter();
Integer zoneChanges = card.getZoneChangeCounter(game);
effect.setValue("zoneChanges", zoneChanges);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
@ -150,7 +150,7 @@ class GraveBetrayalEffect extends OneShotEffect {
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
Integer zoneChanges = (Integer) getValue("zoneChanges");
if (card.getZoneChangeCounter() == zoneChanges) {
if (card.getZoneChangeCounter(game) == zoneChanges) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) {
Permanent creature = game.getPermanent(card.getId());

View file

@ -103,7 +103,7 @@ class TrostaniSelesnyasVoiceTriggeredAbility extends TriggeredAbilityImpl {
&& event.getTargetId() != this.getSourceId()) {
Effect effect = this.getEffects().get(0);
effect.setValue("lifeSource", event.getTargetId());
effect.setValue("zoneChangeCounter", permanent.getZoneChangeCounter());
effect.setValue("zoneChangeCounter", permanent.getZoneChangeCounter(game));
return true;
}
}
@ -142,7 +142,7 @@ class TrostaniSelesnyasVoiceEffect extends OneShotEffect {
UUID creatureId = (UUID) getValue("lifeSource");
Integer zoneChangeCounter = (Integer) getValue("zoneChangeCounter");
Permanent creature = game.getPermanent(creatureId);
if (creature == null || creature.getZoneChangeCounter() != zoneChangeCounter) {
if (creature == null || creature.getZoneChangeCounter(game) != zoneChangeCounter) {
creature = (Permanent) game.getLastKnownInformation(creatureId, Zone.BATTLEFIELD, zoneChangeCounter);
}
if (creature != null) {

View file

@ -131,7 +131,7 @@ class LeoninArbiterIgnoreEffect extends OneShotEffect {
String key = permanent.getId() + keyString;
// Using a Map.Entry since there is no pair class
long zoneChangeCount = permanent.getZoneChangeCounter();
long zoneChangeCount = permanent.getZoneChangeCounter(game);
long turnNum = game.getTurnNum();
Long activationState = zoneChangeCount << 32 | turnNum & 0xFFFFFFFFL;
@ -170,7 +170,7 @@ class LeoninArbiterCantSearchEffect extends ContinuousRuleModifyingEffectImpl {
String key = permanent.getId() + keyString;
Map.Entry<Long, Set<UUID>> turnIgnoringPlayersPair = (Map.Entry<Long, Set<UUID>>) game.getState().getValue(key);
if (turnIgnoringPlayersPair != null) {
long zoneChangeCount = permanent.getZoneChangeCounter();
long zoneChangeCount = permanent.getZoneChangeCounter(game);
long turnNum = game.getTurnNum();
Long activationState = zoneChangeCount << 32 | turnNum & 0xFFFFFFFFL;
if (activationState.equals(turnIgnoringPlayersPair.getKey())) {

View file

@ -131,7 +131,7 @@ class SkeletonizeDelayedTriggeredAbility extends DelayedTriggeredAbility {
if (zce.isDiesEvent()) {
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", this.getSourceId());
if (watcher != null) {
return watcher.wasDamaged(zce.getTarget());
return watcher.wasDamaged(zce.getTarget(), game);
}
}
}

View file

@ -96,7 +96,7 @@ class MarchOfTheMachinesEffect extends ContinuousEffectImpl {
affectedObjectList.clear();
for(Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)){
if(permanent != null){
affectedObjectList.add(new MageObjectReference(permanent));
affectedObjectList.add(new MageObjectReference(permanent, game));
permanent.getCardType().add(CardType.CREATURE);
}
}

View file

@ -120,7 +120,7 @@ class TimeToFeedTextEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
DelayedTriggeredAbility ability = new TimeToFeedDiesTriggeredAbility(creature.getId(), creature.getZoneChangeCounter());
DelayedTriggeredAbility ability = new TimeToFeedDiesTriggeredAbility(creature.getId(), creature.getZoneChangeCounter(game));
new CreateDelayedTriggeredAbilityEffect(ability, false).apply(game, source);
}
@ -155,7 +155,7 @@ class TimeToFeedDiesTriggeredAbility extends DelayedTriggeredAbility {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
if (event.getTargetId().equals(watchedCreatureId)) {
Permanent creature = (Permanent) game.getLastKnownInformation(watchedCreatureId, Zone.BATTLEFIELD);
if (creature.getZoneChangeCounter() == this.zoneChangeCounter) {
if (creature.getZoneChangeCounter(game) == this.zoneChangeCounter) {
return true;
}
}

View file

@ -127,7 +127,7 @@ class TritonTacticsUntapTargetEffect extends OneShotEffect {
} else {
targetMap = new HashMap<>();
}
targetMap.put(new Integer(game.getCard(source.getSourceId()).getZoneChangeCounter()), targets);
targetMap.put(new Integer(game.getCard(source.getSourceId()).getZoneChangeCounter(game)), targets);
if (object == null) {
game.getState().setValue("targets" + source.getSourceId().toString(), targetMap);
}

View file

@ -97,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)) {
affectedObjectList.add(new MageObjectReference(perm));
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
}
@ -107,7 +107,7 @@ 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)) {
if (affectedObjectList.contains(new MageObjectReference(permanent))) {
if (affectedObjectList.contains(new MageObjectReference(permanent, game))) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
permanent.removeAllAbilities(source.getSourceId(), game);

View file

@ -137,7 +137,7 @@ class DiabolicServitudeCreatureDiesTriggeredAbility extends TriggeredAbilityImpl
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Object object = game.getState().getValue(getSourceId().toString() + "returnedCreature");
if ((object instanceof MageObjectReference) && ((MageObjectReference)object).refersTo(zEvent.getTarget())) {
if ((object instanceof MageObjectReference) && ((MageObjectReference)object).refersTo(zEvent.getTarget(), game)) {
return true;
}
}

View file

@ -107,7 +107,7 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game)) {
affectedObjectList.add(new MageObjectReference(creature));
affectedObjectList.add(new MageObjectReference(creature, game));
}
}
}