mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- The AI can now use mana abilities that produce the chosen color.
- Refactoring to prevent duplicate code in AbilityMana. - Commented out two unused functions in ComputerUtil.
This commit is contained in:
@@ -3,11 +3,10 @@ ManaCost:4
|
||||
Types:Artifact
|
||||
Text:no text
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Static$ True | Execute$ TrigChooseColor | TriggerDescription$ As CARDNAME enters the battlefield, choose a color.
|
||||
SVar:TrigChooseColor:AB$ ChooseColor | Cost$ 0
|
||||
SVar:TrigChooseColor:AB$ ChooseColor | Cost$ 0 | AILogic$ MostProminentInComputerDeck
|
||||
T:Mode$ SpellCast | ValidCard$ Card.ChosenColor | OptionalDecider$ You | Execute$ TrigGainLife | TriggerZones$ Battlefield | TriggerDescription$ Whenever a player casts a spell of the chosen color, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$ GainLife | Cost$ 0 | LifeAmount$ 1
|
||||
A:AB$ Mana | Cost$ T | Produced$ Chosen | SpellDescription$ Add one mana of the chosen color to your mana pool.
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/paradise_plume.jpg
|
||||
SetInfo:TSP|Uncommon|http://magiccards.info/scans/en/ts/260.jpg
|
||||
|
||||
@@ -5,9 +5,8 @@ Text:no text
|
||||
PT:1/3
|
||||
K:Reach
|
||||
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ ChooseColor | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, choose a color.
|
||||
SVar:ChooseColor:DB$ ChooseColor | Defined$ You
|
||||
SVar:ChooseColor:DB$ ChooseColor | Defined$ You | AILogic$ MostProminentInComputerDeck
|
||||
A:AB$ Mana | Cost$ T | Produced$ Chosen | SpellDescription$ Add one mana of the chosen color to your mana pool.
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/silhana_starfletcher.jpg
|
||||
SetInfo:GPT|Common|http://magiccards.info/scans/en/gp/95.jpg
|
||||
|
||||
@@ -920,7 +920,7 @@ public class ComputerUtil {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static ArrayList<String> getProduceableColors(final AbilityMana m, final Player player) {
|
||||
/*public static ArrayList<String> getProduceableColors(final AbilityMana m, final Player player) {
|
||||
final ArrayList<String> colors = new ArrayList<String>();
|
||||
|
||||
// if the mana ability is not avaiable move to the next one
|
||||
@@ -949,7 +949,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -1094,7 +1094,7 @@ public class ComputerUtil {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static ArrayList<AbilityMana> sortForNeeded(final ManaCost cost, final ArrayList<AbilityMana> manaAbilities,
|
||||
/*public static ArrayList<AbilityMana> sortForNeeded(final ManaCost cost, final ArrayList<AbilityMana> manaAbilities,
|
||||
final Player player) {
|
||||
|
||||
ArrayList<String> colors;
|
||||
@@ -1145,7 +1145,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -1189,19 +1189,19 @@ public class ComputerUtil {
|
||||
colorlessSources.add(m);
|
||||
|
||||
// find possible colors
|
||||
if (m.canProduce("W") || m.isAnyMana()) {
|
||||
if (m.canProduce("W")) {
|
||||
whiteSources.add(m);
|
||||
}
|
||||
if (m.canProduce("U") || m.isAnyMana()) {
|
||||
if (m.canProduce("U")) {
|
||||
blueSources.add(m);
|
||||
}
|
||||
if (m.canProduce("B") || m.isAnyMana()) {
|
||||
if (m.canProduce("B")) {
|
||||
blackSources.add(m);
|
||||
}
|
||||
if (m.canProduce("R") || m.isAnyMana()) {
|
||||
if (m.canProduce("R")) {
|
||||
redSources.add(m);
|
||||
}
|
||||
if (m.canProduce("G") || m.isAnyMana()) {
|
||||
if (m.canProduce("G")) {
|
||||
greenSources.add(m);
|
||||
}
|
||||
if (m.isSnow()) {
|
||||
|
||||
@@ -670,6 +670,9 @@ public final class AbilityFactoryChoose {
|
||||
if (logic.equals("MostProminentInHumanDeck")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame().getController(
|
||||
AllZone.getHumanPlayer()));
|
||||
} else if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame().getController(
|
||||
AllZone.getComputerPlayer()));
|
||||
}
|
||||
else if (logic.equals("MostProminentInGame")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame());
|
||||
|
||||
@@ -391,7 +391,6 @@ public class AbilityFactoryMana {
|
||||
private static String generatedMana(final AbilityMana abMana, final AbilityFactory af, final SpellAbility sa) {
|
||||
// Calculate generated mana here for stack description and resolving
|
||||
final HashMap<String, String> params = af.getMapParams();
|
||||
final Card card = sa.getSourceCard();
|
||||
int amount = params.containsKey("Amount") ? AbilityFactory.calculateAmount(af.getHostCard(),
|
||||
params.get("Amount"), sa) : 1;
|
||||
|
||||
@@ -405,11 +404,6 @@ public class AbilityFactoryMana {
|
||||
baseMana = abMana.mana();
|
||||
}
|
||||
|
||||
if (baseMana.equals("Chosen")) {
|
||||
// this will only support 1 chosen color for now.
|
||||
baseMana = InputPayManaCostUtil.getShortColorString(card.getChosenColor().get(0));
|
||||
}
|
||||
|
||||
if (params.containsKey("Bonus")) {
|
||||
// For mana abilities that get a bonus
|
||||
// Bonus currently MULTIPLIES the base amount. Base Amounts should
|
||||
@@ -769,7 +763,7 @@ public class AbilityFactoryMana {
|
||||
final ArrayList<String> colors) {
|
||||
for (final String col : Constant.Color.ONLY_COLORS) {
|
||||
final String s = InputPayManaCostUtil.getShortColorString(col);
|
||||
if ((ab.canProduce(s) || ab.isAnyMana()) && !colors.contains(col)) {
|
||||
if (ab.canProduce(s) && !colors.contains(col)) {
|
||||
colors.add(col);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import forge.Card;
|
||||
import forge.Player;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaPool;
|
||||
import forge.control.input.InputPayManaCostUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -228,7 +229,7 @@ public abstract class AbilityMana extends AbilityActivated implements java.io.Se
|
||||
if (i != 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(this.origProduced);
|
||||
sb.append(mana());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,6 +244,12 @@ public abstract class AbilityMana extends AbilityActivated implements java.io.Se
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String mana() {
|
||||
if (this.origProduced.contains("Chosen")) {
|
||||
if (this.getSourceCard() != null && !this.getSourceCard().getChosenColor().isEmpty()) {
|
||||
return InputPayManaCostUtil.getShortColorString(this.getSourceCard()
|
||||
.getChosenColor().get(0));
|
||||
}
|
||||
}
|
||||
return this.origProduced;
|
||||
}
|
||||
|
||||
@@ -367,7 +374,17 @@ public abstract class AbilityMana extends AbilityActivated implements java.io.Se
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean canProduce(final String s) {
|
||||
//TODO: look at where this called from and take "Any" into account
|
||||
if (isAnyMana()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.origProduced.contains("Chosen")) {
|
||||
if (this.getSourceCard() != null && !this.getSourceCard().getChosenColor().isEmpty()
|
||||
&& InputPayManaCostUtil.getShortColorString(this.getSourceCard().getChosenColor().get(0))
|
||||
.contains(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.origProduced.contains(s);
|
||||
}
|
||||
|
||||
@@ -379,7 +396,8 @@ public abstract class AbilityMana extends AbilityActivated implements java.io.Se
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBasic() {
|
||||
if (this.origProduced.length() != 1 && !this.origProduced.contains("Any")) {
|
||||
if (this.origProduced.length() != 1 && !this.origProduced.contains("Any")
|
||||
&& !this.origProduced.contains("Chosen")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,8 +230,7 @@ public class BoosterDraftAI {
|
||||
final ArrayList<AbilityMana> maList = typeList.get(i).getManaAbility();
|
||||
for (int j = 0; j < maList.size(); j++) {
|
||||
if (maList.get(j).canProduce(this.playerColors.get(player).getMana1())
|
||||
|| maList.get(j).canProduce(this.playerColors.get(player).getMana2())
|
||||
|| maList.get(j).isAnyMana()) {
|
||||
|| maList.get(j).canProduce(this.playerColors.get(player).getMana2())) {
|
||||
wouldPick.add(typeList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +325,7 @@ public class SealedDeck {
|
||||
public boolean addCard(final Card c) {
|
||||
final ArrayList<AbilityMana> maList = c.getManaAbility();
|
||||
for (int j = 0; j < maList.size(); j++) {
|
||||
if (maList.get(j).canProduce(aiDC.mana1) || maList.get(j).canProduce(aiDC.mana2)
|
||||
|| maList.get(j).isAnyMana()) {
|
||||
if (maList.get(j).canProduce(aiDC.mana1) || maList.get(j).canProduce(aiDC.mana2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user