mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fixed some wrong counter handling not firing game events from removing counters (fixes #1587).
This commit is contained in:
parent
080a1b883c
commit
5735efa18d
8 changed files with 32 additions and 35 deletions
|
@ -53,7 +53,6 @@ public class AEtherSnap extends CardImpl {
|
|||
super(ownerId, 133, "AEther Snap", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
|
||||
this.expansionSetCode = "C14";
|
||||
|
||||
|
||||
// Remove all counters from all permanents and exile all tokens.
|
||||
this.getSpellAbility().addEffect(new AEtherSnapEffect());
|
||||
}
|
||||
|
@ -88,13 +87,13 @@ class AEtherSnapEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Permanent permanent :game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
|
||||
if (permanent instanceof PermanentToken) {
|
||||
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
} else if (!permanent.getCounters().isEmpty()){
|
||||
} else if (!permanent.getCounters().isEmpty()) {
|
||||
Counters counters = permanent.getCounters().copy();
|
||||
for (Counter counter: counters.values()) {
|
||||
permanent.getCounters().removeCounter(counter.getName(), counter.getCount());
|
||||
for (Counter counter : counters.values()) {
|
||||
permanent.removeCounters(counter, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,10 +57,10 @@ public class ThiefOfBlood extends CardImpl {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
this.subtype.add("Vampire");
|
||||
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
|
||||
// As Thief of Blood enters the battlefield, remove all counters from all permanents. Thief of Blood enters the battlefield with a +1/+1 counter on it for each counter removed this way.
|
||||
this.addAbility(new EntersBattlefieldAbility(new ThiefOfBloodEffect(), null, "As {this} enters the battlefield, remove all counters from all permanents. {this} enters the battlefield with a +1/+1 counter on it for each counter removed this way", null));
|
||||
}
|
||||
|
@ -76,33 +76,34 @@ public class ThiefOfBlood extends CardImpl {
|
|||
}
|
||||
|
||||
class ThiefOfBloodEffect extends OneShotEffect {
|
||||
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("permanent with a counter");
|
||||
|
||||
static {
|
||||
filter.add(new CounterPredicate(null));
|
||||
}
|
||||
|
||||
|
||||
ThiefOfBloodEffect() {
|
||||
super(Outcome.BoostCreature);
|
||||
this.staticText = "remove all counters from all permanents. {this} enters the battlefield with a +1/+1 counter on it for each counter removed this way";
|
||||
}
|
||||
|
||||
|
||||
ThiefOfBloodEffect(final ThiefOfBloodEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ThiefOfBloodEffect copy() {
|
||||
return new ThiefOfBloodEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int countersRemoved = 0;
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||
Counters counters = permanent.getCounters().copy();
|
||||
for (Counter counter : counters.values()) {
|
||||
permanent.getCounters().removeCounter(counter.getName(), counter.getCount());
|
||||
permanent.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
countersRemoved += counter.getCount();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
package mage.sets.innistrad;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -41,7 +38,9 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
|||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.abilities.keyword.TransformAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
|
@ -83,6 +82,7 @@ public class LudevicsTestSubject extends CardImpl {
|
|||
}
|
||||
|
||||
class LudevicsTestSubjectEffect extends OneShotEffect {
|
||||
|
||||
LudevicsTestSubjectEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Then if there are five or more hatchling counters on it, remove all of them and transform it";
|
||||
|
@ -97,7 +97,7 @@ class LudevicsTestSubjectEffect extends OneShotEffect {
|
|||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
if (p.getCounters().getCount(CounterType.HATCHLING) >= 5) {
|
||||
p.getCounters().removeCounter(CounterType.HATCHLING, p.getCounters().getCount(CounterType.HATCHLING));
|
||||
p.removeCounters(CounterType.HATCHLING.getName(), p.getCounters().getCount(CounterType.HATCHLING), game);
|
||||
TransformSourceEffect effect = new TransformSourceEffect(true);
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
|
@ -109,4 +109,4 @@ class LudevicsTestSubjectEffect extends OneShotEffect {
|
|||
public LudevicsTestSubjectEffect copy() {
|
||||
return new LudevicsTestSubjectEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
package mage.sets.mirrodin;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
@ -39,7 +36,9 @@ import mage.abilities.costs.mana.GenericManaCost;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
|
@ -78,6 +77,7 @@ public class OblivionStone extends CardImpl {
|
|||
}
|
||||
|
||||
class OblivionStoneEffect extends OneShotEffect {
|
||||
|
||||
OblivionStoneEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
staticText = "Destroy each nonland permanent without a fate counter on it, then remove all fate counters from all permanents";
|
||||
|
@ -96,7 +96,7 @@ class OblivionStoneEffect extends OneShotEffect {
|
|||
}
|
||||
for (Permanent p : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (p.getCounters().containsKey(CounterType.FATE)) {
|
||||
p.getCounters().removeCounter(CounterType.FATE, p.getCounters().getCount(CounterType.FATE));
|
||||
p.removeCounters(CounterType.FATE.getName(), p.getCounters().getCount(CounterType.FATE), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -103,13 +103,13 @@ class HexParasiteEffect extends OneShotEffect {
|
|||
for (String counterName : counterNames) {
|
||||
if (player.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) {
|
||||
if (permanent.getCounters().get(counterName).getCount() == 1 || toRemove == 1) {
|
||||
permanent.getCounters().removeCounter(counterName, 1);
|
||||
permanent.removeCounters(counterName, 1, game);
|
||||
removed++;
|
||||
} else {
|
||||
int amount = player.getAmount(1, Math.min(permanent.getCounters().get(counterName).getCount(), toRemove - removed), "How many?", game);
|
||||
if (amount > 0) {
|
||||
removed += amount;
|
||||
permanent.getCounters().removeCounter(counterName, amount);
|
||||
permanent.removeCounters(counterName, amount, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ class DescendantOfMasumaroEffect extends OneShotEffect {
|
|||
}
|
||||
Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (targetOpponent != null && targetOpponent.getHand().size() > 0) {
|
||||
sourcePermanent.getCounters().removeCounter(CounterType.P1P1, targetOpponent.getHand().size());
|
||||
game.informPlayers(controller.getLogName() + " removes " + targetOpponent.getHand().size() + " +1/+1 counters from " + sourcePermanent.getLogName());
|
||||
sourcePermanent.removeCounters(CounterType.P1P1.getName(), targetOpponent.getHand().size(), game);
|
||||
game.informPlayers(controller.getLogName() + " removes " + targetOpponent.getHand().size() + " +1/+1 counters from " + sourcePermanent.getLogName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -73,10 +73,9 @@ public class CrovaxTheCursed extends CardImpl {
|
|||
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new CrovaxTheCursedEffect(), TargetController.YOU, false);
|
||||
this.addAbility(ability);
|
||||
|
||||
|
||||
// {B}: Crovax gains flying until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{B}")));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CrovaxTheCursed(final CrovaxTheCursed card) {
|
||||
|
@ -118,11 +117,9 @@ class CrovaxTheCursedEffect extends OneShotEffect {
|
|||
game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + sourceObject.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sourceObject != null && sourceObject.getCounters().containsKey(CounterType.P1P1)) {
|
||||
sourceObject.getCounters().removeCounter(CounterType.P1P1, 1);
|
||||
game.informPlayers(controller.getLogName() + " removes a +1/+1 counter from " + sourceObject.getName());
|
||||
}
|
||||
} else if (sourceObject != null && sourceObject.getCounters().containsKey(CounterType.P1P1)) {
|
||||
sourceObject.removeCounters(CounterType.P1P1.getName(), 1, game);
|
||||
game.informPlayers(controller.getLogName() + " removes a +1/+1 counter from " + sourceObject.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -107,10 +107,10 @@ class MagmasaurEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourceObject = (Permanent)source.getSourceObjectIfItStillExists(game);
|
||||
Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
|
||||
if (sourceObject != null && controller != null) {
|
||||
if (controller.chooseUse(outcome, "Remove a +1/+1 counter from " + sourceObject.getLogName() + "?", source, game)) {
|
||||
sourceObject.getCounters().removeCounter(CounterType.P1P1, 1);
|
||||
sourceObject.removeCounters(CounterType.P1P1.getName(), 1, game);
|
||||
} else {
|
||||
int counters = sourceObject.getCounters().getCount(CounterType.P1P1);
|
||||
sourceObject.sacrifice(source.getSourceId(), game);
|
||||
|
|
Loading…
Reference in a new issue