[IKO] Price of Betrayal - fixed wrong ability effect;

This commit is contained in:
Oleg Agafonov 2020-04-19 22:55:11 +04:00
parent e61c7c22d3
commit 0aced5669f
2 changed files with 18 additions and 21 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -10,24 +8,21 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author BetaSteward
*/
public final class HexParasite extends CardImpl {
public HexParasite(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}");
this.subtype.add(SubType.INSECT);
this.power = new MageInt(1);
@ -76,7 +71,7 @@ class HexParasiteEffect extends OneShotEffect {
String[] counterNames = permanent.getCounters(game).keySet().toArray(new String[0]);
for (String counterName : counterNames) {
if (player.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) {
if (permanent.getCounters(game).get(counterName).getCount() == 1 || toRemove == 1) {
if (permanent.getCounters(game).get(counterName).getCount() == 1 || (toRemove - removed == 1)) {
permanent.removeCounters(counterName, 1, game);
removed++;
} else {
@ -91,7 +86,9 @@ class HexParasiteEffect extends OneShotEffect {
break;
}
}
game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source);
if (removed > 0) {
game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source);
}
return true;
}
return false;

View file

@ -2,11 +2,9 @@ package mage.cards.p;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterOpponent;
import mage.filter.FilterPermanent;
@ -34,12 +32,12 @@ public final class PriceOfBetrayal extends CardImpl {
));
}
private static final FilterPermanentOrPlayer filter2 = new FilterPermanentOrPlayer("artifact, creature, planeswalker, or opponent", filter, new FilterOpponent());
private static final FilterPermanentOrPlayer filter2 = new FilterPermanentOrPlayer("artifact, creature, planeswalker or opponent", filter, new FilterOpponent());
public PriceOfBetrayal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
// Remove up to five counters from target artifact, creature, planeswalker, or opponent.
// Remove up to five counters from target artifact, creature, planeswalker or opponent.
this.getSpellAbility().addEffect(new PriceOfBetrayalEffect());
this.getSpellAbility().addTarget(new TargetPermanentOrPlayer(1, 1, filter2, false));
}
@ -57,8 +55,8 @@ public final class PriceOfBetrayal extends CardImpl {
class PriceOfBetrayalEffect extends OneShotEffect {
PriceOfBetrayalEffect() {
super(Outcome.Benefit);
staticText = "Remove up to five counters from target artifact, creature, planeswalker, or opponent.";
super(Outcome.AIDontUseIt);
staticText = "Remove up to five counters from target artifact, creature, planeswalker or opponent.";
}
private PriceOfBetrayalEffect(final PriceOfBetrayalEffect effect) {
@ -76,6 +74,8 @@ class PriceOfBetrayalEffect extends OneShotEffect {
if (controller == null) {
return false;
}
// from permanent
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int toRemove = 5;
@ -83,7 +83,7 @@ class PriceOfBetrayalEffect extends OneShotEffect {
String[] counterNames = permanent.getCounters(game).keySet().toArray(new String[0]);
for (String counterName : counterNames) {
if (controller.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) {
if (permanent.getCounters(game).get(counterName).getCount() == 1 || toRemove == 1) {
if (permanent.getCounters(game).get(counterName).getCount() == 1 || (toRemove - removed == 1)) {
permanent.removeCounters(counterName, 1, game);
removed++;
} else {
@ -98,9 +98,10 @@ class PriceOfBetrayalEffect extends OneShotEffect {
break;
}
}
game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source);
return true;
}
// from player
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
int toRemove = 5;
@ -108,7 +109,7 @@ class PriceOfBetrayalEffect extends OneShotEffect {
String[] counterNames = player.getCounters().keySet().toArray(new String[0]);
for (String counterName : counterNames) {
if (controller.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) {
if (player.getCounters().get(counterName).getCount() == 1 || toRemove == 1) {
if (player.getCounters().get(counterName).getCount() == 1 || (toRemove - removed == 1)) {
player.removeCounters(counterName, 1, source, game);
removed++;
} else {
@ -123,7 +124,6 @@ class PriceOfBetrayalEffect extends OneShotEffect {
break;
}
}
game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source);
return true;
}
return false;