mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Added AI support for Mox Diamond.
This commit is contained in:
@@ -825,7 +825,7 @@ public class AiController {
|
|||||||
return getCardsToDiscard(numDiscard, numDiscard, hand, sa);
|
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) {
|
if (validCards.size() < min) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -835,6 +835,9 @@ public class AiController {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
if (sa != null) {
|
if (sa != null) {
|
||||||
sourceCard = sa.getHostCard();
|
sourceCard = sa.getHostCard();
|
||||||
|
if ("Always".equals(sa.getParam("AILogic")) && !validCards.isEmpty()) {
|
||||||
|
min = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for good discards
|
// look for good discards
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DiscardEffect extends SpellAbilityEffect {
|
public class DiscardEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(SpellAbility sa) {
|
||||||
final String mode = sa.getParam("Mode");
|
final String mode = sa.getParam("Mode");
|
||||||
@@ -31,7 +32,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||||
|
|
||||||
if (tgtPlayers.size() > 0) {
|
if (!tgtPlayers.isEmpty()) {
|
||||||
|
|
||||||
for (final Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
sb.append(p.toString()).append(" ");
|
sb.append(p.toString()).append(" ");
|
||||||
@@ -113,14 +114,14 @@ public class DiscardEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
|
|
||||||
for (final Player p : discarders) {
|
for (final Player p : discarders) {
|
||||||
if ((mode.equals("RevealTgtChoose") && firstTarget != null)
|
if ((mode.equals("RevealTgtChoose") && firstTarget != null) || tgt == null || p.canBeTargetedBy(sa)) {
|
||||||
|| tgt == null || p.canBeTargetedBy(sa)) {
|
|
||||||
if (sa.hasParam("RememberDiscarder")) {
|
if (sa.hasParam("RememberDiscarder")) {
|
||||||
source.addRemembered(p);
|
source.addRemembered(p);
|
||||||
}
|
}
|
||||||
final int numCardsInHand = p.getCardsIn(ZoneType.Hand).size();
|
final int numCardsInHand = p.getCardsIn(ZoneType.Hand).size();
|
||||||
if (mode.equals("Defined")) {
|
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) {
|
if (runDiscard) {
|
||||||
final List<Card> toDiscard = AbilityUtils.getDefinedCards(source, sa.getParam("DefinedCards"), sa);
|
final List<Card> toDiscard = AbilityUtils.getDefinedCards(source, sa.getParam("DefinedCards"), sa);
|
||||||
for (final Card c : toDiscard) {
|
for (final Card c : toDiscard) {
|
||||||
@@ -150,8 +151,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mode.equals("NotRemembered")) {
|
if (mode.equals("NotRemembered")) {
|
||||||
final List<Card> dPHand =
|
final List<Card> dPHand = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", p, source);
|
||||||
CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", source.getController(), source);
|
|
||||||
for (final Card c : dPHand) {
|
for (final Card c : dPHand) {
|
||||||
p.discard(c, sa);
|
p.discard(c, sa);
|
||||||
discarded.add(c);
|
discarded.add(c);
|
||||||
@@ -161,8 +161,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
|||||||
int numCards = 1;
|
int numCards = 1;
|
||||||
if (sa.hasParam("NumCards")) {
|
if (sa.hasParam("NumCards")) {
|
||||||
numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
|
numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
|
||||||
if (p.getCardsIn(ZoneType.Hand).size() > 0
|
if (!p.getCardsIn(ZoneType.Hand).isEmpty() && p.getCardsIn(ZoneType.Hand).size() < numCards) {
|
||||||
&& p.getCardsIn(ZoneType.Hand).size() < numCards) {
|
|
||||||
// System.out.println("Scale down discard from " + numCards + " to " + p.getCardsIn(ZoneType.Hand).size());
|
// System.out.println("Scale down discard from " + numCards + " to " + p.getCardsIn(ZoneType.Hand).size());
|
||||||
numCards = p.getCardsIn(ZoneType.Hand).size();
|
numCards = p.getCardsIn(ZoneType.Hand).size();
|
||||||
}
|
}
|
||||||
@@ -174,7 +173,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
if (runDiscard) {
|
if (runDiscard) {
|
||||||
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
|
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);
|
list = CardLists.filter(list, Presets.NON_TOKEN);
|
||||||
for (int i = 0; i < numCards; i++) {
|
for (int i = 0; i < numCards; i++) {
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ ManaCost:0
|
|||||||
Types:Artifact
|
Types:Artifact
|
||||||
A:AB$ Mana | Cost$ T | Produced$ Any | SpellDescription$ Add one mana of any color to your mana pool.
|
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.
|
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: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:MoveToBattlefield:DB$ ChangeZone | Origin$ All | Destination$ Battlefield | Defined$ ReplacedCard | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ1 | References$ X | SubAbility$ DBCleanup
|
||||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||||
SVar:X:Remembered$Amount
|
SVar:X:Remembered$Amount
|
||||||
|
SVar:NeedsToPlayVar:Y GE1
|
||||||
|
SVar:Y:Count$ValidHand Land.YouCtrl
|
||||||
SVar:RemAIDeck:True
|
SVar:RemAIDeck:True
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/mox_diamond.jpg
|
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.
|
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user