This commit is contained in:
jeffwadsworth 2020-01-06 17:46:52 -06:00
parent 5a6f9022c0
commit b2ad1e30c0

View file

@ -1,7 +1,6 @@
package mage.cards.g; package mage.cards.g;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -24,8 +23,6 @@ import mage.game.stack.Spell;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -82,7 +79,12 @@ enum GadwickTheWizenedValue implements DynamicValue {
if (watcher == null) { if (watcher == null) {
return 0; return 0;
} }
return watcher.getX(new MageObjectReference(sourceAbility.getSourceId(), game)); if (game.getState().getValue(sourceAbility.getSourceId().toString()
+ "cardsToDraw") == null) {
return 0;
}
return (Integer) game.getState().getValue(sourceAbility.getSourceId().toString()
+ "cardsToDraw");
} }
@Override @Override
@ -103,8 +105,6 @@ enum GadwickTheWizenedValue implements DynamicValue {
class GadwickTheWizenedWatcher extends Watcher { class GadwickTheWizenedWatcher extends Watcher {
private final Map<MageObjectReference, Integer> xMap = new HashMap();
GadwickTheWizenedWatcher() { GadwickTheWizenedWatcher() {
super(WatcherScope.GAME); super(WatcherScope.GAME);
} }
@ -118,18 +118,10 @@ class GadwickTheWizenedWatcher extends Watcher {
if (spell == null) { if (spell == null) {
return; return;
} }
xMap.put(new MageObjectReference( if (spell.getSourceId() != super.getSourceId()) {
spell.getSourceId(), spell.getZoneChangeCounter(game) + 1, game return; // the spell is not Gadwick, the Wizened
), spell.getSpellAbility().getManaCostsToPay().getX());
} }
game.getState().setValue(spell.getSourceId().toString()
@Override + "cardsToDraw", spell.getSpellAbility().getManaCostsToPay().getX());
public void reset() {
super.reset();
xMap.clear();
}
public int getX(MageObjectReference mageObjectReference) {
return xMap.getOrDefault(mageObjectReference, 0);
} }
} }