When a card that allows "free cast" is in play, do not prefer to discard "unplayable" cards based on CMS, instead discard worst as normal.

...but AI still isn't very eager to actually play them for some reason.
This commit is contained in:
Seravy
2018-02-13 23:23:33 +01:00
committed by Agetian
parent c3f4c7fe4a
commit d5d70cd17d
4 changed files with 41 additions and 10 deletions

View File

@@ -1046,17 +1046,32 @@ public class AiController {
numLandsAvailable++;
}
//Discard unplayable card
// Discard unplayable card
boolean discardedUnplayable = false;
for (int j = 0; j < validCards.size(); j++) {
if (validCards.get(j).getCMC() > numLandsAvailable && !validCards.get(j).hasSVar("DoNotDiscardIfAble")) {
discardList.add(validCards.get(j));
validCards.remove(validCards.get(j));
discardedUnplayable = true;
break;
} else if (validCards.get(j).getCMC() <= numLandsAvailable) {
// cut short to avoid looping over cards which are guaranteed not to fit the criteria
break;
// But check if there is a card in play that allows casting spells for free!
// if yes, nothing is unplayable, at least based on CMC
boolean dreamHalls = false;
for (Card cardInPlay : game.getCardsIn(ZoneType.Battlefield)) {
if (cardInPlay.hasSVar("AllowFreeCast")) {
if ("Everyone".equals((cardInPlay.getSVar("AllowFreeCast")))) {
dreamHalls = true;
} else if (("Owner".equals((cardInPlay.getSVar("AllowFreeCast"))))
&& (cardInPlay.getOwner().equals(player))) {
dreamHalls = true;
}
}
}
if (!dreamHalls) {
for (int j = 0; j < validCards.size(); j++) {
if (validCards.get(j).getCMC() > numLandsAvailable && !validCards.get(j).hasSVar("DoNotDiscardIfAble")) {
discardList.add(validCards.get(j));
validCards.remove(validCards.get(j));
discardedUnplayable = true;
break;
} else if (validCards.get(j).getCMC() <= numLandsAvailable) {
// cut short to avoid looping over cards which are guaranteed not to fit the criteria
break;
}
}
}

View File

@@ -65,6 +65,20 @@ public class AiCostDecision extends CostDecisionMakerBase {
final String type = cost.getType();
CardCollectionView hand = player.getCardsIn(ZoneType.Hand);
/* // Dream Halls
if (type.equals("Card.SharesColorWith")) {
Card bestfound= null;
for (Card card : hand) {
if ((card.sharesColorWith(source))
&& (!card.equals(source))) {
if (bestfound==null) { bestfound=card; }
if (card.getCMC()<bestfound.getCMC()) { bestfound=card; }
}
}
if (bestfound==null) { return null; } else
{ return PaymentDecision.card(bestfound); }
} else */
if (type.equals("LastDrawn")) {
if (!hand.contains(player.getLastDrawnCard())) {
return null;

View File

@@ -4,5 +4,6 @@ Types:Enchantment
S:Mode$ Continuous | Affected$ Card.nonToken | AddKeyword$ Alternative Cost:Discard<1/Card.SharesColorWith/color sharing> | AffectedZone$ Hand,Graveyard,Exile,Library,Command | Description$ Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.
SVar:NonStackingEffect:True
AI:RemoveDeck:Random
SVar:AllowFreeCast:Everyone
SVar:Picture:http://www.wizards.com/global/images/magic/general/dream_halls.jpg
Oracle:Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.

View File

@@ -2,6 +2,7 @@ Name:Omniscience
ManaCost:7 U U U
Types:Enchantment
S:Mode$ Continuous | Affected$ Card.nonLand+YouOwn | MayPlay$ True | MayPlayWithoutManaCost$ True | AffectedZone$ Hand | Description$ You may cast spells from your hand without paying their mana costs.
SVar:AllowFreeCast:Owner
AI:RemoveDeck:Random
SVar:Picture:http://www.wizards.com/global/images/magic/general/omniscience.jpg
Oracle:You may cast spells from your hand without paying their mana costs.