mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
add color choice logic for future use by AI
This commit is contained in:
@@ -2,8 +2,8 @@ Name:Manamorphose
|
|||||||
ManaCost:1 RG
|
ManaCost:1 RG
|
||||||
Types:Instant
|
Types:Instant
|
||||||
Text:no text
|
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.
|
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 | SubAbility$ DBDraw
|
SVar:DBMana:DB$ Mana | Cost$ 0 | Produced$ Any | Amount$ 1 | AILogic$ MostProminentInComputerHand | SubAbility$ DBDraw
|
||||||
SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ 1
|
SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ 1
|
||||||
SVar:RemAIDeck:True
|
SVar:RemAIDeck:True
|
||||||
SVar:Rarity:Common
|
SVar:Rarity:Common
|
||||||
|
|||||||
@@ -611,8 +611,6 @@ public class ComputerUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> colors;
|
|
||||||
|
|
||||||
cost = manapool.subtractMana(sa, cost);
|
cost = manapool.subtractMana(sa, cost);
|
||||||
//ManaCost testCost = new ManaCost(cost.toString()); // temp variable for testing only
|
//ManaCost testCost = new ManaCost(cost.toString()); // temp variable for testing only
|
||||||
if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
||||||
@@ -856,118 +854,6 @@ public class ComputerUtil {
|
|||||||
return true;
|
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<AbilityMana> 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<String, Object> runParams = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
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) {
|
if (!test) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("ComputerUtil : payManaCost() cost was not paid for ");
|
sb.append("ComputerUtil : payManaCost() cost was not paid for ");
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package forge.card.abilityfactory;
|
package forge.card.abilityfactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -33,6 +32,7 @@ import forge.Constant.Zone;
|
|||||||
import forge.Counters;
|
import forge.Counters;
|
||||||
import forge.MyRandom;
|
import forge.MyRandom;
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.spellability.AbilityActivated;
|
import forge.card.spellability.AbilityActivated;
|
||||||
import forge.card.spellability.AbilityMana;
|
import forge.card.spellability.AbilityMana;
|
||||||
@@ -306,6 +306,24 @@ public class AbilityFactoryMana {
|
|||||||
String choice = (String) o;
|
String choice = (String) o;
|
||||||
abMana.setAnyChoice(InputPayManaCostUtil.getShortColorString(choice));
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user