Fixed that some cards doesn't trigger counter remove events;

This commit is contained in:
Oleg Agafonov 2019-04-30 18:50:03 +04:00
parent 2a2cfccad3
commit 07faf872ea
5 changed files with 31 additions and 29 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
@ -9,7 +7,9 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.*;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
@ -19,8 +19,9 @@ import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class AllHallowsEve extends CardImpl {
@ -72,7 +73,7 @@ class AllHallowsEveEffect extends OneShotEffect {
if (allHallowsEve != null
&& controller != null
&& game.getExile().getCard(allHallowsEve.getId(), game) != null) {
allHallowsEve.getCounters(game).removeCounter(CounterType.SCREAM, 1);
allHallowsEve.removeCounters(CounterType.SCREAM.getName(), 1, game);
if (allHallowsEve.getCounters(game).getCount(CounterType.SCREAM) == 0) {
allHallowsEve.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
@ -24,8 +22,9 @@ import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.SubTypeList;
import java.util.UUID;
/**
*
* @author andyfries
*/
@ -40,7 +39,7 @@ public final class Aurification extends CardImpl {
static final String rule = "Each creature with a gold counter on it is a Wall in addition to its other creature types and has defender.";
public Aurification(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
// Whenever a creature deals damage to you, put a gold counter on it.
this.addAbility(new AddGoldCountersAbility());
@ -127,8 +126,11 @@ public final class Aurification extends CardImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE)) {
if (permanent != null){
permanent.getCounters(game).removeAllCounters(CounterType.GOLD);
if (permanent != null) {
int numToRemove = permanent.getCounters(game).getCount(CounterType.GOLD);
if (numToRemove > 0) {
permanent.removeCounters(CounterType.GOLD.getName(), numToRemove, game);
}
}
}
return true;

View file

@ -1,7 +1,5 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -17,8 +15,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author spjspj
*/
public final class Inhumaniac extends CardImpl {
@ -71,7 +70,10 @@ class InhumaniacEffect extends OneShotEffect {
} else if (amount >= 5) {
permanent.addCounters(CounterType.P1P1.createInstance(2), source, game);
} else if (amount == 1) {
permanent.getCounters(game).removeAllCounters(CounterType.P1P1);
int numToRemove = permanent.getCounters(game).getCount(CounterType.P1P1);
if (numToRemove > 0) {
permanent.removeCounters(CounterType.P1P1.getName(), numToRemove, game);
}
}
return true;
}

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTappedTriggeredAbility;
@ -12,11 +10,11 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterLandPermanent;
@ -25,8 +23,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class MineLayer extends CardImpl {
@ -87,7 +86,10 @@ class RemoveAllMineCountersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.LAND)) {
if (permanent != null) {
permanent.getCounters(game).removeAllCounters(CounterType.MINE);
int numToRemove = permanent.getCounters(game).getCount(CounterType.MINE);
if (numToRemove > 0) {
permanent.removeCounters(CounterType.MINE.getName(), numToRemove, game);
}
}
}
return true;

View file

@ -1,9 +1,5 @@
package mage.abilities.costs.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
@ -18,8 +14,11 @@ import mage.players.Player;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX
*/
public class RemoveCounterCost extends CostImpl {
@ -102,10 +101,6 @@ public class RemoveCounterCost extends CostImpl {
new StringBuilder("Remove how many counters from ").append(permanent.getIdName()).toString(), game);
}
permanent.removeCounters(counterName, numberOfCountersSelected, game);
if (permanent.getCounters(game).getCount(counterName) == 0) {
// this removes only the item with number = 0 from the collection
permanent.getCounters(game).removeCounter(counterName);
}
countersRemoved += numberOfCountersSelected;
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(controller.getLogName())