- Convert Global Ruin to script.

This commit is contained in:
Sol
2013-03-20 01:31:33 +00:00
parent 347eae0ed5
commit 06bf9d3e65
5 changed files with 38 additions and 212 deletions

View File

@@ -1,7 +1,8 @@
Name:Global Ruin Name:Global Ruin
ManaCost:4 W ManaCost:4 W
Types:Sorcery Types:Sorcery
Text:Each player chooses from the lands he or she controls a land of each basic land type and sacrifices the rest. A:SP$ ChooseCard | Cost$ 4 W | Defined$ Player | EachBasicType$ Controlled | SubAbility$ DBDestroy | SpellDescription$ Each player chooses from the lands he or she controls a land of each basic land type, then sacrifices the rest. | StackDescription$ SpellDescription
SVar:DBDestroy:DB$ SacrificeAll | ValidCards$ Land.nonChosenCard | StackDescription$ None
SVar:RemRandomDeck:True SVar:RemRandomDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/global_ruin.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/global_ruin.jpg
Oracle:Each player chooses from the lands he or she controls a land of each basic land type, then sacrifices the rest. Oracle:Each player chooses from the lands he or she controls a land of each basic land type, then sacrifices the rest.

View File

@@ -4,7 +4,7 @@ Types:Artifact Creature Golem
PT:7/10 PT:7/10
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigChoose | TriggerDescription$ When CARDNAME enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands. T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigChoose | TriggerDescription$ When CARDNAME enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Any | ValidCard$ Card.Self | Execute$ TrigChoose | Secondary$ True | TriggerDescription$ When CARDNAME enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands. T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Any | ValidCard$ Card.Self | Execute$ TrigChoose | Secondary$ True | TriggerDescription$ When CARDNAME enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands.
SVar:TrigChoose:AB$ ChooseCard | Cost$ 0 | Defined$ You | SunderingTitan$ True | SubAbility$ DBDestroy SVar:TrigChoose:AB$ ChooseCard | Cost$ 0 | Defined$ You | EachBasicType$ Land | SubAbility$ DBDestroy
SVar:DBDestroy:DB$ DestroyAll | ValidCards$ Card.ChosenCard | SpellDescription$ Destroy all chosen cards. SVar:DBDestroy:DB$ DestroyAll | ValidCards$ Card.ChosenCard | SpellDescription$ Destroy all chosen cards.
SVar:RemAIDeck:True SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/sundering_titan.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/sundering_titan.jpg

View File

@@ -6145,6 +6145,10 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!source.getChosenCard().contains(this)) { if (!source.getChosenCard().contains(this)) {
return false; return false;
} }
} else if (property.equals("nonChosenCard")) {
if (source.getChosenCard().contains(this)) {
return false;
}
} }
// ... Card colors // ... Card colors
else if (property.contains("White") || property.contains("Blue") || property.contains("Black") else if (property.contains("White") || property.contains("Blue") || property.contains("Black")

View File

@@ -54,25 +54,28 @@ public class ChooseCardEffect extends SpellAbilityEffect {
final int validAmount = !numericAmount.matches("[0-9][0-9]?") final int validAmount = !numericAmount.matches("[0-9][0-9]?")
? CardFactoryUtil.xCount(host, host.getSVar(sa.getParam("Amount"))) : Integer.parseInt(numericAmount); ? CardFactoryUtil.xCount(host, host.getSVar(sa.getParam("Amount"))) : Integer.parseInt(numericAmount);
if (sa.hasParam("SunderingTitan")) { for (final Player p : tgtPlayers) {
final List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS); if (sa.hasParam("EachBasicType")) {
for (final String type : CardType.getBasicTypes()) { // Get all lands,
final List<Card> cl = CardLists.getType(land, type); List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS);
if (cl.size() > 0) { String eachBasic = sa.getParam("EachBasicType");
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type; if (eachBasic.equals("Controlled")) {
final Object o = GuiChoose.one(prompt, cl); land = CardLists.filterControlledBy(land, p);
if (null != o) { }
final Card c = (Card) o;
chosen.add(c); // Choose one of each BasicLand given special place
for (final String type : CardType.getBasicTypes()) {
final List<Card> cl = CardLists.getType(land, type);
if (!cl.isEmpty()) {
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
Card c = p.getController().chooseSingleCardForEffect(cl, sa, prompt, true);
if (null != c) {
chosen.add(c);
}
} }
} }
} } else if ((tgt == null) || p.canBeTargetedBy(sa)) {
host.setChosenCard(chosen);
return;
}
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
for (int i = 0; i < validAmount; i++) { for (int i = 0; i < validAmount; i++) {
Card c; Card c;
@@ -89,17 +92,17 @@ public class ChooseCardEffect extends SpellAbilityEffect {
break; break;
} }
} }
host.setChosenCard(chosen); }
if (sa.hasParam("RememberChosen")) { }
for (final Card rem : chosen) { host.setChosenCard(chosen);
host.addRemembered(rem); if (sa.hasParam("RememberChosen")) {
} for (final Card rem : chosen) {
} host.addRemembered(rem);
if (sa.hasParam("ForgetChosen")) { }
for (final Card rem : chosen) { }
host.removeRemembered(rem); if (sa.hasParam("ForgetChosen")) {
} for (final Card rem : chosen) {
} host.removeRemembered(rem);
} }
} }
} }

View File

@@ -248,187 +248,6 @@ public class CardFactorySorceries {
} }
private static final SpellAbility getGlobalRuin(final Card card) {
final List<Card> target = new ArrayList<Card>();
final List<Card> saveList = new ArrayList<Card>();
// need to use arrays so we can declare them final and still set the
// values in the input and runtime classes. This is a hack.
final int[] index = new int[1];
final int[] countBase = new int[1];
final Vector<String> humanBasic = new Vector<String>();
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 5739127258598357186L;
@Override
public boolean canPlayAI() {
return false;
// should check if computer has land in hand, or if computer
// has more basic land types than human.
}
@Override
public void resolve() {
// add computer's lands to target
// int computerCountBase = 0;
// Vector<?> computerBasic = new Vector();
// figure out which basic land types the computer has
List<Card> land = Singletons.getControl().getPlayer().getOpponent().getLandsInPlay();
for (final String element : Constant.Color.BASIC_LANDS) {
final List<Card> cl = CardLists.getType(land, element);
if (!cl.isEmpty()) {
// remove one land of this basic type from this list
// the computer AI should really jump in here and
// select the land which is the best.
// to determine the best look at which lands have
// enchantments, which lands are tapped
cl.remove(cl.get(0));
// add the rest of the lands of this basic type to
// the target list, this is the list which will be
// sacrificed.
target.addAll(cl);
}
}
// need to sacrifice the other non-basic land types
land = CardLists.filter(land, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
if (c.getName().contains("Dryad Arbor")) {
return true;
} else {
return (!(c.isType("Forest") || c.isType("Plains") || c.isType("Mountain")
|| c.isType("Island") || c.isType("Swamp")));
}
}
});
target.addAll(land);
// when this spell resolves all basic lands which were not
// selected are sacrificed.
for (int i = 0; i < target.size(); i++) {
if (target.get(i).isInPlay() && !saveList.contains(target.get(i))) {
Singletons.getModel().getGame().getAction().sacrifice(target.get(i), this);
}
}
} // resolve()
}; // SpellAbility
final Input input = new Input() {
private static final long serialVersionUID = 1739423591445361917L;
private int count;
@Override
public void showMessage() { // count is the current index we are
// on.
// countBase[0] is the total number of basic land types the
// human has
// index[0] is the number to offset the index by
this.count = countBase[0] - index[0] - 1; // subtract by one
// since humanBasic is
// 0 indexed.
if (this.count < 0) {
// need to reset the variables in case they cancel this
// spell and it stays in hand.
humanBasic.clear();
countBase[0] = 0;
index[0] = 0;
this.stop();
} else {
final StringBuilder sb = new StringBuilder();
sb.append("Select target ").append(humanBasic.get(this.count));
sb.append(" land to not sacrifice");
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
}
@Override
public void selectButtonCancel() {
this.stop();
}
@Override
public void selectCard(final Card c) {
if (!c.isLand() || !Singletons.getControl().getPlayer().getZone(ZoneType.Battlefield).contains(c) )
return;
if ( !c.isType(humanBasic.get(this.count) ) ) return;
List<Card> land = c.getController().getLandsInPlay();
List<Card> cl = CardLists.getType(land, humanBasic.get(this.count));
cl = CardLists.filter(cl, new Predicate<Card>() {
@Override
public boolean apply(final Card crd) {
return !saveList.contains(crd);
}
});
if (!c.getName().contains("Dryad Arbor")) {
cl.remove(c);
saveList.add(c);
}
target.addAll(cl);
index[0]++;
this.showMessage();
if (index[0] >= humanBasic.size()) {
this.stopSetNext(new InputPayManaSimple(Singletons.getModel().getGame(), spell));
}
// need to sacrifice the other non-basic land types
land = CardLists.filter(land, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
if (c.getName().contains("Dryad Arbor")) {
return true;
} else {
return (!(c.isType("Forest") || c.isType("Plains") || c.isType("Mountain")
|| c.isType("Island") || c.isType("Swamp")));
}
}
});
target.addAll(land);
} // selectCard()
}; // Input
final Input runtime = new Input() {
private static final long serialVersionUID = -122635387376995855L;
@Override
public void showMessage() {
countBase[0] = 0;
// figure out which basic land types the human has
// put those in an set to use laters
final List<Card> land = Singletons.getControl().getPlayer().getCardsIn(ZoneType.Battlefield);
for (final String element : Constant.Color.BASIC_LANDS) {
final List<Card> c = CardLists.getType(land, element);
if (!c.isEmpty()) {
humanBasic.add(element);
countBase[0]++;
}
}
if (countBase[0] == 0) {
// human has no basic land, so don't prompt to select
// one.
this.stop();
} else {
index[0] = 0;
target.clear();
this.stopSetNext(input);
}
}
}; // Input
spell.setBeforePayMana(runtime);
return spell;
}
private static final void balanceLands(Spell card) { private static final void balanceLands(Spell card) {
List<List<Card>> lands = new ArrayList<List<Card>>(); List<List<Card>> lands = new ArrayList<List<Card>>();
@@ -676,7 +495,6 @@ public class CardFactorySorceries {
public static void buildCard(final Card card, final String cardName) { public static void buildCard(final Card card, final String cardName) {
if (cardName.equals("Brilliant Ultimatum")) { card.addSpellAbility(getBrilliantUltimatum(card)); if (cardName.equals("Brilliant Ultimatum")) { card.addSpellAbility(getBrilliantUltimatum(card));
} else if (cardName.equals("Global Ruin")) { card.addSpellAbility(getGlobalRuin(card));
} else if (cardName.equals("Balance")) { card.addSpellAbility(getBalance(card)); } else if (cardName.equals("Balance")) { card.addSpellAbility(getBalance(card));
} else if (cardName.equals("Patriarch's Bidding")) { card.addSpellAbility(getPatriarchsBidding(card)); } else if (cardName.equals("Patriarch's Bidding")) { card.addSpellAbility(getPatriarchsBidding(card));
} else if (cardName.equals("Transmute Artifact")) { card.addSpellAbility(getTransmuteArtifact(card)); } else if (cardName.equals("Transmute Artifact")) { card.addSpellAbility(getTransmuteArtifact(card));