- Added AI support for Mox Diamond.

This commit is contained in:
Sloth
2015-03-01 11:38:03 +00:00
parent fed033d430
commit 478d1e83cb
3 changed files with 15 additions and 11 deletions

View File

@@ -825,7 +825,7 @@ public class AiController {
return getCardsToDiscard(numDiscard, numDiscard, hand, sa);
}
public CardCollection getCardsToDiscard(final int min, final int max, final CardCollection validCards, final SpellAbility sa) {
public CardCollection getCardsToDiscard(int min, final int max, final CardCollection validCards, final SpellAbility sa) {
if (validCards.size() < min) {
return null;
}
@@ -835,6 +835,9 @@ public class AiController {
int count = 0;
if (sa != null) {
sourceCard = sa.getHostCard();
if ("Always".equals(sa.getParam("AILogic")) && !validCards.isEmpty()) {
min = 1;
}
}
// look for good discards

View File

@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List;
public class DiscardEffect extends SpellAbilityEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final String mode = sa.getParam("Mode");
@@ -31,7 +32,7 @@ public class DiscardEffect extends SpellAbilityEffect {
final List<Player> tgtPlayers = getTargetPlayers(sa);
if (tgtPlayers.size() > 0) {
if (!tgtPlayers.isEmpty()) {
for (final Player p : tgtPlayers) {
sb.append(p.toString()).append(" ");
@@ -113,14 +114,14 @@ public class DiscardEffect extends SpellAbilityEffect {
for (final Player p : discarders) {
if ((mode.equals("RevealTgtChoose") && firstTarget != null)
|| tgt == null || p.canBeTargetedBy(sa)) {
if ((mode.equals("RevealTgtChoose") && firstTarget != null) || tgt == null || p.canBeTargetedBy(sa)) {
if (sa.hasParam("RememberDiscarder")) {
source.addRemembered(p);
}
final int numCardsInHand = p.getCardsIn(ZoneType.Hand).size();
if (mode.equals("Defined")) {
boolean runDiscard = !sa.hasParam("Optional") || p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, sa.getParam("DiscardMessage"));
boolean runDiscard = !sa.hasParam("Optional")
|| p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, sa.getParam("DiscardMessage"));
if (runDiscard) {
final List<Card> toDiscard = AbilityUtils.getDefinedCards(source, sa.getParam("DefinedCards"), sa);
for (final Card c : toDiscard) {
@@ -150,8 +151,7 @@ public class DiscardEffect extends SpellAbilityEffect {
}
if (mode.equals("NotRemembered")) {
final List<Card> dPHand =
CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", source.getController(), source);
final List<Card> dPHand = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", p, source);
for (final Card c : dPHand) {
p.discard(c, sa);
discarded.add(c);
@@ -161,8 +161,7 @@ public class DiscardEffect extends SpellAbilityEffect {
int numCards = 1;
if (sa.hasParam("NumCards")) {
numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
if (p.getCardsIn(ZoneType.Hand).size() > 0
&& p.getCardsIn(ZoneType.Hand).size() < numCards) {
if (!p.getCardsIn(ZoneType.Hand).isEmpty() && p.getCardsIn(ZoneType.Hand).size() < numCards) {
// System.out.println("Scale down discard from " + numCards + " to " + p.getCardsIn(ZoneType.Hand).size());
numCards = p.getCardsIn(ZoneType.Hand).size();
}
@@ -174,7 +173,7 @@ public class DiscardEffect extends SpellAbilityEffect {
if (runDiscard) {
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
List<Card> list = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), valid, sa.getHostCard().getController(), sa.getHostCard());
List<Card> list = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), valid, source.getController(), source);
list = CardLists.filter(list, Presets.NON_TOKEN);
for (int i = 0; i < numCards; i++) {
if (list.isEmpty())

View File

@@ -3,11 +3,13 @@ ManaCost:0
Types:Artifact
A:AB$ Mana | Cost$ T | Produced$ Any | SpellDescription$ Add one mana of any color to your mana pool.
R:Event$ Moved | Destination$ Battlefield | ValidCard$ Card.Self | ReplaceWith$ PayBeforeETB | Description$ If CARDNAME would enter the battlefield, you may discard a land card instead. If you do, put CARDNAME onto the battlefield. If you don't, put it into its owner's graveyard.
SVar:PayBeforeETB:AB$ Discard | Cost$ 0 | DiscardValid$ Card.Land | Mode$ TgtChoose | RememberDiscarded$ True | Optional$ True | SubAbility$ MoveToGraveyard
SVar:PayBeforeETB:AB$ Discard | Cost$ 0 | DiscardValid$ Land | Mode$ TgtChoose | RememberDiscarded$ True | Optional$ True | AILogic$ Always | SubAbility$ MoveToGraveyard
SVar:MoveToGraveyard:DB$ ChangeZone | Origin$ All | Destination$ Graveyard | Defined$ ReplacedCard | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | References$ X | SubAbility$ MoveToBattlefield
SVar:MoveToBattlefield:DB$ ChangeZone | Origin$ All | Destination$ Battlefield | Defined$ ReplacedCard | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ1 | References$ X | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Remembered$Amount
SVar:NeedsToPlayVar:Y GE1
SVar:Y:Count$ValidHand Land.YouCtrl
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/mox_diamond.jpg
Oracle:If Mox Diamond would enter the battlefield, you may discard a land card instead. If you do, put Mox Diamond onto the battlefield. If you don't, put it into its owner's graveyard.\n{T}: Add one mana of any color to your mana pool.