mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
convert Brave the Elements to script
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
Name:Brave the Elements
|
||||
ManaCost:W
|
||||
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:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/brave_the_elements.jpg
|
||||
|
||||
@@ -532,6 +532,7 @@ public class AbilityFactory_Choose {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean chooseColorCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||
//Note: if (AILogic == MostProminentAttackers) return isDuringCombat();
|
||||
return chooseColorTriggerAI(af, sa, false);
|
||||
}
|
||||
|
||||
@@ -622,6 +623,9 @@ public class AbilityFactory_Choose {
|
||||
list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()).getType("Creature");
|
||||
chosen = CardFactoryUtil.getMostProminentColor(list);
|
||||
}
|
||||
if (logic.equals("MostProminentAttackers")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(new CardList(AllZone.getCombat().getAttackers()));
|
||||
}
|
||||
}
|
||||
if (chosen.equals("")) {
|
||||
chosen = Constant.Color.Green;
|
||||
|
||||
@@ -993,7 +993,14 @@ public final class AbilityFactory_Protection {
|
||||
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
} 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");
|
||||
|
||||
@@ -8,7 +8,6 @@ import forge.CardUtil;
|
||||
import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.CardListUtil;
|
||||
import forge.Combat;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
@@ -46,96 +45,7 @@ public class CardFactory_Instants {
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
if (cardName.equals("Brave the Elements")) {
|
||||
/**
|
||||
* 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")) {
|
||||
if (cardName.equals("Sprout Swarm")) {
|
||||
final SpellAbility spell_one = new Spell(card) {
|
||||
private static final long serialVersionUID = -609007714604161377L;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user