diff --git a/res/cardsfolder/m/manamorphose.txt b/res/cardsfolder/m/manamorphose.txt index 5cd59b127db..f6281f9b68c 100644 --- a/res/cardsfolder/m/manamorphose.txt +++ b/res/cardsfolder/m/manamorphose.txt @@ -2,8 +2,8 @@ Name:Manamorphose ManaCost:1 RG Types:Instant Text:no text -A:SP$ Mana | Cost$ 1 RG | Produced$ Any | Amount$ 1 | SubAbility$ DBMana | SpellDescription$ Add two mana in any combination of colors to your mana pool. Draw a card. -SVar:DBMana:DB$ Mana | Cost$ 0 | Produced$ Any | Amount$ 1 | SubAbility$ DBDraw +A:SP$ Mana | Cost$ 1 RG | Produced$ Any | Amount$ 1 | SubAbility$ DBMana | AILogic$ MostProminentInComputerHand | SpellDescription$ Add two mana in any combination of colors to your mana pool. Draw a card. +SVar:DBMana:DB$ Mana | Cost$ 0 | Produced$ Any | Amount$ 1 | AILogic$ MostProminentInComputerHand | SubAbility$ DBDraw SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ 1 SVar:RemAIDeck:True SVar:Rarity:Common diff --git a/src/main/java/forge/ComputerUtil.java b/src/main/java/forge/ComputerUtil.java index 6eb37d5a573..c5c12040138 100644 --- a/src/main/java/forge/ComputerUtil.java +++ b/src/main/java/forge/ComputerUtil.java @@ -611,8 +611,6 @@ public class ComputerUtil { return true; } - ArrayList colors; - cost = manapool.subtractMana(sa, cost); //ManaCost testCost = new ManaCost(cost.toString()); // temp variable for testing only if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") { @@ -856,118 +854,6 @@ public class ComputerUtil { return true; } - /* - final CardList manaSources = ComputerUtil.getAvailableMana(); - - // this is to prevent errors for mana sources that have abilities that - // cost mana. - manaSources.remove(sa.getSourceCard()); - - for (int i = 0; i < manaSources.size(); i++) { - final Card sourceCard = manaSources.get(i); - ArrayList manaAbilities = sourceCard.getAIPlayableMana(); - - boolean used = false; // this is for testing paying mana only - - manaAbilities = ComputerUtil.sortForNeeded(cost, manaAbilities, player); - - for (final AbilityMana m : manaAbilities) { - - if (used) { - break; // mana source already used in the test - } - m.setActivatingPlayer(player); - // if the AI can't pay the additional costs skip the mana - // ability - if (m.getPayCosts() != null) { - if (!ComputerUtil.canPayAdditionalCosts(m, player)) { - continue; - } - } else if (sourceCard.isTapped()) { - continue; - } - - // don't use abilities with dangerous drawbacks - if (m.getSubAbility() != null) { - if (!m.getSubAbility().chkAIDrawback()) { - continue; - } - } - - colors = ComputerUtil.getProduceableColors(m, player); - for (int j = 0; j < colors.size(); j++) { - if (used) { - break; // mana source already used in the test - } - - if (cost.isNeeded(colors.get(j))) { - if (!test) { - // Pay additional costs - if (m.getPayCosts() != null) { - final CostPayment pay = new CostPayment(m.getPayCosts(), m); - if (!pay.payComputerCosts()) { - continue; - } - } else { - sourceCard.tap(); - } - } else { - used = true; // mana source is now used in the test - } - - cost.payMana(colors.get(j)); - - if (!test) { - // resolve subabilities - final AbilityFactory af = m.getAbilityFactory(); - if (af != null) { - AbilityFactory.resolveSubAbilities(m); - } - - if (sourceCard.getName().equals("Undiscovered Paradise")) { - sourceCard.setBounceAtUntap(true); - } - - if (sourceCard.getName().equals("Rainbow Vale")) { - final StringBuilder sb = new StringBuilder(); - sb.append("An opponent gains control of CARDNAME "); - sb.append("at the beginning of the next end step."); - sourceCard.addExtrinsicKeyword(sb.toString()); - } - - // System.out.println("just subtracted " + - // colors.get(j) + ", cost is now: " + - // cost.toString()); - // Run triggers - final HashMap runParams = new HashMap(); - - runParams.put("Card", sourceCard); - runParams.put("Player", player); - runParams.put("Produced", colors.get(j)); // can't - // tell - // what - // mana - // the - // computer - // just - // paid? - AllZone.getTriggerHandler().runTrigger("TapsForMana", runParams); - } // not a test - } - if (cost.isPaid()) { - // if (sa instanceof Spell_Permanent) // should probably - // add this - sa.getSourceCard().setColorsPaid(cost.getColorsPaid()); - sa.getSourceCard().setSunburstValue(cost.getSunburst()); - manapool.clearPay(sa, test); - return true; - } - } - } - - } - */ - if (!test) { final StringBuilder sb = new StringBuilder(); sb.append("ComputerUtil : payManaCost() cost was not paid for "); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java index 7e713a4b823..6582f97fb61 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java @@ -18,7 +18,6 @@ package forge.card.abilityfactory; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Random; @@ -33,6 +32,7 @@ import forge.Constant.Zone; import forge.Counters; import forge.MyRandom; import forge.Player; +import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityMana; @@ -246,7 +246,7 @@ public class AbilityFactoryMana { return sb.toString(); } - + /** *

manaGenerated.

* @@ -306,6 +306,24 @@ public class AbilityFactoryMana { String choice = (String) o; abMana.setAnyChoice(InputPayManaCostUtil.getShortColorString(choice)); } + else { + if (params.containsKey("AILogic")) { + final String logic = params.get("AILogic"); + String chosen = Constant.Color.BLACK; + if (logic.equals("MostProminentInComputerHand")) { + chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( + Zone.Hand)); + } + GuiUtils.getChoice("Computer picked: ", chosen); + abMana.setAnyChoice(InputPayManaCostUtil.getShortColorString(chosen)); + } + if (abMana.getAnyChoice().isEmpty()) { + final StringBuilder sb = new StringBuilder(); + sb.append("AbilityFactoryMana::manaResolve() - any color mana choice is empty for "); + sb.append(sa.getSourceCard().getName()); + throw new RuntimeException(sb.toString()); + } + } } } }