From 3f882b73c4760143da2ea34f06817faad07aa33b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 1 Nov 2016 14:31:02 +0100 Subject: [PATCH] Fixed a problem with activated spells that could not be used but were used by AI and available mana calculation. --- Mage.Sets/src/mage/cards/k/KormusBell.java | 4 ++-- .../mage/cards/l/LinvalaKeeperOfSilence.java | 5 ++-- Mage.Sets/src/mage/cards/l/LivingLands.java | 4 ++-- Mage.Sets/src/mage/cards/l/LivingPlane.java | 7 +++--- .../src/mage/cards/n/NaturalEmergence.java | 9 ++++---- Mage.Sets/src/mage/cards/n/NaturesRevolt.java | 9 ++++---- Mage.Sets/src/mage/cards/r/RudeAwakening.java | 7 +++--- .../continuous/BecomesCreatureAllEffect.java | 8 ++++++- .../main/java/mage/players/PlayerImpl.java | 23 +++++++++++++++---- 9 files changed, 50 insertions(+), 26 deletions(-) diff --git a/Mage.Sets/src/mage/cards/k/KormusBell.java b/Mage.Sets/src/mage/cards/k/KormusBell.java index 42f5964894f..d25ae953b57 100644 --- a/Mage.Sets/src/mage/cards/k/KormusBell.java +++ b/Mage.Sets/src/mage/cards/k/KormusBell.java @@ -49,7 +49,7 @@ import mage.game.permanent.token.Token; public class KormusBell extends CardImpl { public KormusBell(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); // All Swamps are 1/1 black creatures that are still lands. ContinuousEffect effect = new BecomesCreatureAllEffect(new KormusBellToken(), "lands", new FilterPermanent("Swamp", "Swamps"), Duration.WhileOnBattlefield); @@ -70,7 +70,7 @@ public class KormusBell extends CardImpl { class KormusBellToken extends Token { public KormusBellToken() { - super("", "1/1 creature"); + super("", "1/1 black creatures"); cardType.add(CardType.CREATURE); power = new MageInt(1); toughness = new MageInt(1); diff --git a/Mage.Sets/src/mage/cards/l/LinvalaKeeperOfSilence.java b/Mage.Sets/src/mage/cards/l/LinvalaKeeperOfSilence.java index 93806f12c28..d52e5d1234d 100644 --- a/Mage.Sets/src/mage/cards/l/LinvalaKeeperOfSilence.java +++ b/Mage.Sets/src/mage/cards/l/LinvalaKeeperOfSilence.java @@ -48,7 +48,7 @@ import mage.game.permanent.Permanent; public class LinvalaKeeperOfSilence extends CardImpl { public LinvalaKeeperOfSilence(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); this.supertype.add("Legendary"); this.subtype.add("Angel"); @@ -85,7 +85,8 @@ class LinvalaKeeperOfSilenceCantActivateEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return permanent.getCardType().contains(CardType.CREATURE) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId()); + return permanent.getCardType().contains(CardType.CREATURE) + && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId()); } @Override diff --git a/Mage.Sets/src/mage/cards/l/LivingLands.java b/Mage.Sets/src/mage/cards/l/LivingLands.java index 6fe92480c60..c7746845322 100644 --- a/Mage.Sets/src/mage/cards/l/LivingLands.java +++ b/Mage.Sets/src/mage/cards/l/LivingLands.java @@ -55,7 +55,7 @@ public class LivingLands extends CardImpl { } public LivingLands(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); // All Forests are 1/1 creatures that are still lands. ContinuousEffect effect = new BecomesCreatureAllEffect(new LivingLandsToken(), "lands", filter, Duration.WhileOnBattlefield); @@ -76,7 +76,7 @@ public class LivingLands extends CardImpl { class LivingLandsToken extends Token { public LivingLandsToken() { - super("", "1/1 creature"); + super("", "1/1 creatures"); cardType.add(CardType.CREATURE); power = new MageInt(1); toughness = new MageInt(1); diff --git a/Mage.Sets/src/mage/cards/l/LivingPlane.java b/Mage.Sets/src/mage/cards/l/LivingPlane.java index 470aa94f063..91d6f49743d 100644 --- a/Mage.Sets/src/mage/cards/l/LivingPlane.java +++ b/Mage.Sets/src/mage/cards/l/LivingPlane.java @@ -46,7 +46,7 @@ import mage.game.permanent.token.Token; public class LivingPlane extends CardImpl { public LivingPlane(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}"); this.supertype.add("World"); // All lands are 1/1 creatures that are still lands. @@ -64,10 +64,11 @@ public class LivingPlane extends CardImpl { } class LivingPlaneToken extends Token { + public LivingPlaneToken() { - super("Land", "1/1 creature"); + super("Land", "1/1 creatures"); cardType.add(CardType.CREATURE); power = new MageInt(1); toughness = new MageInt(1); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/n/NaturalEmergence.java b/Mage.Sets/src/mage/cards/n/NaturalEmergence.java index 063fa812505..16bed183208 100644 --- a/Mage.Sets/src/mage/cards/n/NaturalEmergence.java +++ b/Mage.Sets/src/mage/cards/n/NaturalEmergence.java @@ -50,7 +50,7 @@ import mage.game.permanent.token.Token; /** * * @author LoneFox - + * */ public class NaturalEmergence extends CardImpl { @@ -61,7 +61,7 @@ public class NaturalEmergence extends CardImpl { } public NaturalEmergence(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{G}"); // When Natural Emergence enters the battlefield, return a red or green enchantment you control to its owner's hand. Effect effect = new ReturnToHandChosenControlledPermanentEffect(filter); @@ -69,7 +69,7 @@ public class NaturalEmergence extends CardImpl { this.addAbility(new EntersBattlefieldTriggeredAbility(effect, false)); // Lands you control are 2/2 creatures with first strike. They're still lands. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new NaturalEmergenceToken(), - "lands", new FilterControlledLandPermanent("lands you control"), Duration.WhileOnBattlefield))); + "lands", new FilterControlledLandPermanent("lands you control"), Duration.WhileOnBattlefield))); } public NaturalEmergence(final NaturalEmergence card) { @@ -83,8 +83,9 @@ public class NaturalEmergence extends CardImpl { } class NaturalEmergenceToken extends Token { + public NaturalEmergenceToken() { - super("Land", "2/2 creature with first strike"); + super("Land", "2/2 creatures with first strike"); cardType.add(CardType.CREATURE); power = new MageInt(2); toughness = new MageInt(2); diff --git a/Mage.Sets/src/mage/cards/n/NaturesRevolt.java b/Mage.Sets/src/mage/cards/n/NaturesRevolt.java index 36643c69fbb..bd42c024568 100644 --- a/Mage.Sets/src/mage/cards/n/NaturesRevolt.java +++ b/Mage.Sets/src/mage/cards/n/NaturesRevolt.java @@ -42,16 +42,16 @@ import mage.game.permanent.token.Token; /** * * @author LoneFox - + * */ public class NaturesRevolt extends CardImpl { public NaturesRevolt(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{G}"); // All lands are 2/2 creatures that are still lands. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new NaturesRevoltToken(), - "lands", new FilterLandPermanent(), Duration.WhileOnBattlefield))); + "lands", new FilterLandPermanent(), Duration.WhileOnBattlefield))); } public NaturesRevolt(final NaturesRevolt card) { @@ -65,8 +65,9 @@ public class NaturesRevolt extends CardImpl { } class NaturesRevoltToken extends Token { + public NaturesRevoltToken() { - super("Land", "2/2 creature"); + super("Land", "2/2 creatures"); cardType.add(CardType.CREATURE); power = new MageInt(2); toughness = new MageInt(2); diff --git a/Mage.Sets/src/mage/cards/r/RudeAwakening.java b/Mage.Sets/src/mage/cards/r/RudeAwakening.java index 41909cdf4aa..977405927ff 100644 --- a/Mage.Sets/src/mage/cards/r/RudeAwakening.java +++ b/Mage.Sets/src/mage/cards/r/RudeAwakening.java @@ -40,7 +40,6 @@ import mage.constants.Duration; import mage.filter.common.FilterControlledLandPermanent; import mage.game.permanent.token.Token; - /** * * @author LevelX2 @@ -48,8 +47,7 @@ import mage.game.permanent.token.Token; public class RudeAwakening extends CardImpl { public RudeAwakening(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{G}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}"); // Choose one - this.getSpellAbility().getModes().setMinModes(1); @@ -76,8 +74,9 @@ public class RudeAwakening extends CardImpl { } class RudeAwakeningToken extends Token { + public RudeAwakeningToken() { - super("", "2/2 creature"); + super("", "2/2 creatures"); cardType.add(CardType.CREATURE); power = new MageInt(2); toughness = new MageInt(2); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java index 49d348290d0..13610ddd457 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java @@ -138,8 +138,14 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { if (!"".equals(duration.toString())) { sb.append(duration.toString()).append(", "); } + sb.append("all "); sb.append(filter.getMessage()); - sb.append(" become a ").append(token.getDescription()); + if ("".equals(duration.toString())) { + sb.append(" are "); + } else { + sb.append(" become "); + } + sb.append(token.getDescription()); if (type != null && type.length() > 0) { sb.append(". They are still ").append(type); } diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index c8da18f36d6..a4c11c54fd6 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -873,8 +873,11 @@ public abstract class PlayerImpl implements Player, Serializable { } else { TargetCard target = new TargetCard(Zone.ALL, new FilterCard("card to put on the bottom of your library (last one chosen will be bottommost)")); target.setRequired(true); - while (isInGame() && cards.size() > 1) { + while (cards.size() > 1) { this.choose(Outcome.Neutral, cards, target, game); + if (!canRespond()) { + return false; + } UUID targetObjectId = target.getFirstTarget(); cards.remove(targetObjectId); moveObjectToLibrary(targetObjectId, source == null ? null : source.getSourceId(), game, false, false); @@ -2376,11 +2379,15 @@ public abstract class PlayerImpl implements Player, Serializable { List> sourceWithoutManaCosts = new ArrayList<>(); List> sourceWithCosts = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { + Boolean canUse = null; boolean canAdd = false; boolean withCost = false; Abilities manaAbilities = permanent.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game); for (ManaAbility ability : manaAbilities) { - if (ability.canActivate(playerId, game)) { + if (canUse == null) { + canUse = permanent.canUseActivatedAbilities(game); + } + if (canUse && ability.canActivate(playerId, game)) { canAdd = true; if (!ability.getManaCosts().isEmpty()) { withCost = true; @@ -2410,13 +2417,17 @@ public abstract class PlayerImpl implements Player, Serializable { protected List getAvailableManaProducers(Game game) { List result = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { + Boolean canUse = null; boolean canAdd = false; for (ManaAbility ability : permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) { if (!ability.getManaCosts().isEmpty()) { canAdd = false; break; } - if (ability.canActivate(playerId, game)) { + if (canUse == null) { + canUse = permanent.canUseActivatedAbilities(game); + } + if (canUse && ability.canActivate(playerId, game)) { canAdd = true; } } @@ -2446,8 +2457,12 @@ public abstract class PlayerImpl implements Player, Serializable { public List getAvailableManaProducersWithCost(Game game) { List result = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { + Boolean canUse = null; for (ManaAbility ability : permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) { - if (ability.canActivate(playerId, game) && !ability.getManaCosts().isEmpty()) { + if (canUse == null) { + canUse = permanent.canUseActivatedAbilities(game); + } + if (canUse && ability.canActivate(playerId, game) && !ability.getManaCosts().isEmpty()) { result.add(permanent); break; }