mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- AF Discard AI will now also use discardNumTypeAI.
- Improved discardNumTypeAI.
This commit is contained in:
@@ -1373,8 +1373,9 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
dPHand = AbilityFactoryReveal.getRevealedList(p, dPHand, amount);
|
dPHand = AbilityFactoryReveal.getRevealedList(p, dPHand, amount);
|
||||||
}
|
}
|
||||||
CardList dPChHand = new CardList(dPHand);
|
CardList dPChHand = new CardList(dPHand);
|
||||||
|
String[] dValid = null;
|
||||||
if (params.containsKey("DiscardValid")) { // Restrict card choices
|
if (params.containsKey("DiscardValid")) { // Restrict card choices
|
||||||
final String[] dValid = params.get("DiscardValid").split(",");
|
dValid = params.get("DiscardValid").split(",");
|
||||||
dPChHand = dPHand.getValidCards(dValid, source.getController(), source);
|
dPChHand = dPHand.getValidCards(dValid, source.getController(), source);
|
||||||
}
|
}
|
||||||
Player chooser = p;
|
Player chooser = p;
|
||||||
@@ -1386,12 +1387,24 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
|
|
||||||
if (chooser.isComputer()) {
|
if (chooser.isComputer()) {
|
||||||
// AI
|
// AI
|
||||||
|
if (p.isComputer()) { // discard AI cards
|
||||||
|
CardList list = ComputerUtil.discardNumTypeAI(numCards, dValid, sa);
|
||||||
|
if (mode.startsWith("Reveal")) {
|
||||||
|
GuiUtils.chooseOneOrNone("Computer has chosen", list.toArray());
|
||||||
|
}
|
||||||
|
discarded.addAll(list);
|
||||||
|
for (Card card : list) {
|
||||||
|
p.discard(card, sa);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// discard human cards
|
||||||
for (int i = 0; i < numCards; i++) {
|
for (int i = 0; i < numCards; i++) {
|
||||||
if (dPChHand.size() > 0) {
|
if (dPChHand.size() > 0) {
|
||||||
final CardList dChoices = new CardList();
|
final CardList dChoices = new CardList();
|
||||||
if (params.containsKey("DiscardValid")) {
|
if (params.containsKey("DiscardValid")) {
|
||||||
final String dValid = params.get("DiscardValid");
|
final String validString = params.get("DiscardValid");
|
||||||
if (dValid.contains("Creature") && !dValid.contains("nonCreature")) {
|
if (validString.contains("Creature") && !validString.contains("nonCreature")) {
|
||||||
final Card c = CardFactoryUtil.getBestCreatureAI(dPChHand);
|
final Card c = CardFactoryUtil.getBestCreatureAI(dPChHand);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
dChoices.add(CardFactoryUtil.getBestCreatureAI(dPChHand));
|
dChoices.add(CardFactoryUtil.getBestCreatureAI(dPChHand));
|
||||||
|
|||||||
@@ -1536,23 +1536,31 @@ public class ComputerUtil {
|
|||||||
if (hand.size() <= 0) {
|
if (hand.size() <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final CardList lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Land");
|
final int numLandsInPlay = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Land").size();
|
||||||
final CardList landsInHand = hand.getType("Land");
|
final CardList landsInHand = hand.getType("Land");
|
||||||
lands.addAll(landsInHand);
|
final int numLandsInHand = landsInHand.size();
|
||||||
if (lands.size() > 5) {
|
|
||||||
if (landsInHand.size() > 0) { // discard lands
|
// Discard a land
|
||||||
|
if (numLandsInHand > 3 || (numLandsInHand > 2 && numLandsInPlay > 0)
|
||||||
|
|| (numLandsInHand > 1 && numLandsInPlay > 2)
|
||||||
|
|| (numLandsInHand > 0 && numLandsInPlay > 5)) {
|
||||||
discardList.add(landsInHand.get(0));
|
discardList.add(landsInHand.get(0));
|
||||||
hand.remove(landsInHand.get(0));
|
hand.remove(landsInHand.get(0));
|
||||||
} else { // discard low costed stuff
|
} else { // Discard other stuff
|
||||||
CardListUtil.sortCMC(hand);
|
CardListUtil.sortCMC(hand);
|
||||||
hand.reverse();
|
int numLandsAvailable = numLandsInPlay;
|
||||||
discardList.add(hand.get(0));
|
if (numLandsInHand > 0) {
|
||||||
hand.remove(hand.get(0));
|
numLandsAvailable++;
|
||||||
}
|
}
|
||||||
} else { // discard high costed stuff
|
//Discard unplayable card
|
||||||
CardListUtil.sortCMC(hand);
|
if (hand.get(0).getCMC() > numLandsAvailable) {
|
||||||
discardList.add(hand.get(0));
|
discardList.add(hand.get(0));
|
||||||
hand.remove(hand.get(0));
|
hand.remove(hand.get(0));
|
||||||
|
} else { //Discard worst card
|
||||||
|
Card worst = CardFactoryUtil.getWorstAI(hand);
|
||||||
|
discardList.add(worst);
|
||||||
|
hand.remove(worst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user