mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
[CMR] fixed Stumpsquall Hydra not being able to distribute counters (fixes #7823)
This commit is contained in:
parent
a85bf3af79
commit
7b22c88804
1 changed files with 7 additions and 34 deletions
|
@ -4,26 +4,24 @@ import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.WatcherScope;
|
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.ObjectSourcePlayer;
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
import mage.filter.predicate.mageobject.CommanderPredicate;
|
import mage.filter.predicate.mageobject.CommanderPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetAmount;
|
import mage.target.TargetAmount;
|
||||||
import mage.target.common.TargetCreatureOrPlaneswalkerAmount;
|
import mage.target.common.TargetCreatureOrPlaneswalkerAmount;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.common.ManaSpentToCastWatcher;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ public final class StumpsquallHydra extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// When Stumpsquall Hydra enters the battlefield, distribute X +1/+1 counters among it and any number of commanders.
|
// When Stumpsquall Hydra enters the battlefield, distribute X +1/+1 counters among it and any number of commanders.
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new StumpsquallHydraEffect()), new StumpsquallHydraWatcher());
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new StumpsquallHydraEffect()), new ManaSpentToCastWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
private StumpsquallHydra(final StumpsquallHydra card) {
|
private StumpsquallHydra(final StumpsquallHydra card) {
|
||||||
|
@ -93,12 +91,8 @@ class StumpsquallHydraEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
StumpsquallHydraWatcher watcher = game.getState().getWatcher(StumpsquallHydraWatcher.class, source.getSourceId());
|
|
||||||
if (watcher == null || game.getState().getValue(source.getSourceId().toString() + "xValue") == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
int xValue = (Integer) game.getState().getValue(source.getSourceId().toString() + "xValue");
|
int xValue = ManacostVariableValue.instance.calculate(game, source, this);
|
||||||
if (player == null || xValue < 1) {
|
if (player == null || xValue < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -110,31 +104,10 @@ class StumpsquallHydraEffect extends OneShotEffect {
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(targetAmount.getTargetAmount(targetId)), source.getControllerId(), source, game);
|
permanent.addCounters(CounterType.P1P1.createInstance(
|
||||||
|
targetAmount.getTargetAmount(targetId)), source.getControllerId(), source, game
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class StumpsquallHydraWatcher extends Watcher {
|
|
||||||
|
|
||||||
StumpsquallHydraWatcher() {
|
|
||||||
super(WatcherScope.CARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
if (spell.getSourceId() != super.getSourceId()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
game.getState().setValue(spell.getSourceId().toString() + "xValue", spell.getSpellAbility().getManaCostsToPay().getX());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue