Fixed a problem with activated spells that could not be used but were used by AI and available mana calculation.

This commit is contained in:
LevelX2 2016-11-01 14:31:02 +01:00
parent 35c90f2dec
commit 3f882b73c4
9 changed files with 50 additions and 26 deletions

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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<Abilities<ManaAbility>> sourceWithoutManaCosts = new ArrayList<>();
List<Abilities<ManaAbility>> sourceWithCosts = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
Boolean canUse = null;
boolean canAdd = false;
boolean withCost = false;
Abilities<ManaAbility> 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<MageObject> getAvailableManaProducers(Game game) {
List<MageObject> 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<Permanent> getAvailableManaProducersWithCost(Game game) {
List<Permanent> 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;
}