mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Convert Global Ruin to script.
This commit is contained in:
@@ -6145,6 +6145,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (!source.getChosenCard().contains(this)) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("nonChosenCard")) {
|
||||
if (source.getChosenCard().contains(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// ... Card colors
|
||||
else if (property.contains("White") || property.contains("Blue") || property.contains("Black")
|
||||
|
||||
@@ -54,25 +54,28 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
final int validAmount = !numericAmount.matches("[0-9][0-9]?")
|
||||
? CardFactoryUtil.xCount(host, host.getSVar(sa.getParam("Amount"))) : Integer.parseInt(numericAmount);
|
||||
|
||||
if (sa.hasParam("SunderingTitan")) {
|
||||
final List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
||||
for (final String type : CardType.getBasicTypes()) {
|
||||
final List<Card> cl = CardLists.getType(land, type);
|
||||
if (cl.size() > 0) {
|
||||
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
|
||||
final Object o = GuiChoose.one(prompt, cl);
|
||||
if (null != o) {
|
||||
final Card c = (Card) o;
|
||||
chosen.add(c);
|
||||
for (final Player p : tgtPlayers) {
|
||||
if (sa.hasParam("EachBasicType")) {
|
||||
// Get all lands,
|
||||
List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
||||
String eachBasic = sa.getParam("EachBasicType");
|
||||
if (eachBasic.equals("Controlled")) {
|
||||
land = CardLists.filterControlledBy(land, p);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
host.setChosenCard(chosen);
|
||||
return;
|
||||
}
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
} else if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
for (int i = 0; i < validAmount; i++) {
|
||||
|
||||
Card c;
|
||||
@@ -89,17 +92,17 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
break;
|
||||
}
|
||||
}
|
||||
host.setChosenCard(chosen);
|
||||
if (sa.hasParam("RememberChosen")) {
|
||||
for (final Card rem : chosen) {
|
||||
host.addRemembered(rem);
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("ForgetChosen")) {
|
||||
for (final Card rem : chosen) {
|
||||
host.removeRemembered(rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
host.setChosenCard(chosen);
|
||||
if (sa.hasParam("RememberChosen")) {
|
||||
for (final Card rem : chosen) {
|
||||
host.addRemembered(rem);
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("ForgetChosen")) {
|
||||
for (final Card rem : chosen) {
|
||||
host.removeRemembered(rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
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) {
|
||||
|
||||
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("Patriarch's Bidding")) { card.addSpellAbility(getPatriarchsBidding(card));
|
||||
} else if (cardName.equals("Transmute Artifact")) { card.addSpellAbility(getTransmuteArtifact(card));
|
||||
|
||||
Reference in New Issue
Block a user