mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
fixed Gadwick, the Wizened not drawing cards
This commit is contained in:
parent
674e24f020
commit
71aab17858
1 changed files with 83 additions and 7 deletions
|
@ -1,26 +1,31 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.TapTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.common.FilterNonlandPermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -49,8 +54,8 @@ public final class GadwickTheWizened extends CardImpl {
|
|||
|
||||
// When Gadwick, the Wizened enters the battlefield, draw X cards.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(
|
||||
new DrawCardSourceControllerEffect(ManacostVariableValue.instance)
|
||||
));
|
||||
new DrawCardSourceControllerEffect(GadwickTheWizenedValue.instance)
|
||||
), new GadwickTheWizenedWatcher());
|
||||
|
||||
// Whenever you cast a blue spell, tap target nonland permanent an opponent controls.
|
||||
Ability ability = new SpellCastControllerTriggeredAbility(new TapTargetEffect(), filter, false);
|
||||
|
@ -67,3 +72,74 @@ public final class GadwickTheWizened extends CardImpl {
|
|||
return new GadwickTheWizened(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum GadwickTheWizenedValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
GadwickTheWizenedWatcher watcher = game.getState().getWatcher(GadwickTheWizenedWatcher.class);
|
||||
if (watcher == null) {
|
||||
return 0;
|
||||
}
|
||||
return watcher.getX(new MageObjectReference(sourceAbility.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
class GadwickTheWizenedWatcher extends Watcher {
|
||||
|
||||
private final Map<MageObjectReference, Integer> xMap = new HashMap();
|
||||
|
||||
GadwickTheWizenedWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
private GadwickTheWizenedWatcher(final GadwickTheWizenedWatcher watcher) {
|
||||
super(watcher);
|
||||
this.xMap.putAll(watcher.xMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.SPELL_CAST) {
|
||||
return;
|
||||
}
|
||||
Spell spell = game.getSpellOrLKIStack(event.getTargetId());
|
||||
if (spell == null) {
|
||||
return;
|
||||
}
|
||||
xMap.put(new MageObjectReference(
|
||||
spell.getSourceId(), spell.getZoneChangeCounter(game) + 1, game
|
||||
), spell.getSpellAbility().getManaCostsToPay().getX());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GadwickTheWizenedWatcher copy() {
|
||||
return new GadwickTheWizenedWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
xMap.clear();
|
||||
}
|
||||
|
||||
public int getX(MageObjectReference mageObjectReference) {
|
||||
return xMap.getOrDefault(mageObjectReference, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue