convert Brave the Elements to script

This commit is contained in:
slapshot5
2011-10-15 11:56:44 +00:00
parent 8086b32820
commit af336b0f06
4 changed files with 17 additions and 93 deletions

View File

@@ -1,7 +1,10 @@
Name:Brave the Elements Name:Brave the Elements
ManaCost:W ManaCost:W
Types:Instant Types:Instant
Text:Choose a color. White creatures you control gain protection from the chosen color until end of turn. Text:no text
A:SP$ ChooseColor | Cost$ W | Defined$ You | AILogic$ MostProminentAttackers | SubAbility$ DBProtection | SpellDescription$ Choose a color. White creatures you control gain protection from the chosen color until end of turn.
SVar:DBProtection:DB$ ProtectionAll | ValidCards$ Creature.White+YouCtrl | Gains$ ChosenColor
SVar:PlayMain1:TRUE
SVar:RemAIDeck:True SVar:RemAIDeck:True
SVar:Rarity:Uncommon SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/brave_the_elements.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/brave_the_elements.jpg

View File

@@ -532,6 +532,7 @@ public class AbilityFactory_Choose {
* @return a boolean. * @return a boolean.
*/ */
private static boolean chooseColorCanPlayAI(final AbilityFactory af, final SpellAbility sa) { private static boolean chooseColorCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
//Note: if (AILogic == MostProminentAttackers) return isDuringCombat();
return chooseColorTriggerAI(af, sa, false); return chooseColorTriggerAI(af, sa, false);
} }
@@ -622,6 +623,9 @@ public class AbilityFactory_Choose {
list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()).getType("Creature"); list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()).getType("Creature");
chosen = CardFactoryUtil.getMostProminentColor(list); chosen = CardFactoryUtil.getMostProminentColor(list);
} }
if (logic.equals("MostProminentAttackers")) {
chosen = CardFactoryUtil.getMostProminentColor(new CardList(AllZone.getCombat().getAttackers()));
}
} }
if (chosen.equals("")) { if (chosen.equals("")) {
chosen = Constant.Color.Green; chosen = Constant.Color.Green;

View File

@@ -993,7 +993,14 @@ public final class AbilityFactory_Protection {
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE); JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
} }
} else { } else {
gains.addAll(choices); if (params.get("Gains").equals("ChosenColor")) {
for (String color : host.getChosenColor()) {
gains.add(color.toLowerCase());
}
}
else {
gains.addAll(choices);
}
} }
String valid = params.get("ValidCards"); String valid = params.get("ValidCards");

View File

@@ -8,7 +8,6 @@ import forge.CardUtil;
import forge.CardList; import forge.CardList;
import forge.CardListFilter; import forge.CardListFilter;
import forge.CardListUtil; import forge.CardListUtil;
import forge.Combat;
import forge.Command; import forge.Command;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
@@ -46,96 +45,7 @@ public class CardFactory_Instants {
//*************** START *********** START ************************** //*************** START *********** START **************************
if (cardName.equals("Brave the Elements")) { if (cardName.equals("Sprout Swarm")) {
/**
* This card now works slightly better than it did before the spAllPump
* keyword was created. The AI is too simple and needs some work.
*/
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -7998437920995642451L;
@Override
public boolean canPlayAI() {
return getAttacker() != null;
}
public Card getAttacker() {
// target creatures that is going to attack
Combat c = ComputerUtil.getAttackers();
Card[] att = c.getAttackers();
// Effect best used on at least a couple creatures
if (att.length > 1) {
return att[0];
} else {
return null;
}
} //getAttacker()
String getKeywordBoost() {
String theColor = getChosenColor();
return "Protection from " + theColor;
} //getKeywordBoost()
String getChosenColor() {
// Choose color for protection in Brave the Elements
String color = "Black";
if (card.getController().isHuman()) {
// String[] colors = Constant.Color.Colors;
// colors[colors.length-1] = null;
// You can no longer choose to gain "protection from null".
String[] colors = Constant.Color.onlyColors;
Object o = GuiUtils.getChoice("Choose color", colors);
color = (String) o;
} else {
if (getAttacker() != null) {
color = getAttacker().getColor().get(0).toString();
}
}
return color;
} // getChosenColor
@Override
public void resolve() {
final String kboost = getKeywordBoost();
CardList list = card.getController().getCardsIn(Zone.Battlefield);
list = list.filter(CardListFilter.white);
for (int i = 0; i < list.size(); i++) {
final Card[] target = new Card[1];
target[0] = list.get(i);
final Command untilEOT = new Command() {
private static final long serialVersionUID = 6308754740309909072L;
public void execute() {
if (AllZoneUtil.isCardInPlay(target[0])) {
target[0].removeExtrinsicKeyword(kboost);
}
}
}; //Command
if (AllZoneUtil.isCardInPlay(target[0]) && !target[0].hasKeyword(kboost)) {
target[0].addExtrinsicKeyword(kboost);
AllZone.getEndOfTurn().addUntil(untilEOT);
} //if
} //for
} //resolve
}; //SpellAbility
card.setSVar("PlayMain1", "TRUE");
card.addSpellAbility(spell);
} //*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("Sprout Swarm")) {
final SpellAbility spell_one = new Spell(card) { final SpellAbility spell_one = new Spell(card) {
private static final long serialVersionUID = -609007714604161377L; private static final long serialVersionUID = -609007714604161377L;