diff --git a/.classpath b/.classpath
new file mode 100644
index 00000000000..d925f2fd147
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.gitattributes b/.gitattributes
index 1d80cb6bca8..abdeb92380e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,204 @@
* text=auto !eol
+/.classpath -text
+/.project -text
+.settings/org.eclipse.jdt.core.prefs -text
/delete-me.txt svneol=native#text/plain
+src/.classpath -text
+src/.project -text
+src/2009-10-12-00.txt -text svneol=native#text/plain
+src/Ability.java svneol=native#text/plain
+src/Ability_Activated.java svneol=native#text/plain
+src/Ability_Hand.java svneol=native#text/plain
+src/Ability_Mana.java -text svneol=native#text/plain
+src/Ability_Tap.java svneol=native#text/plain
+src/All.java svneol=native#text/plain
+src/AllZone.java svneol=native#text/plain
+src/BackgroundPanel.java -text svneol=native#text/plain
+src/BoosterDraft.java svneol=native#text/plain
+src/BoosterDraftAI.java svneol=native#text/plain
+src/BoosterPack.java svneol=native#text/plain
+src/ButtonUtil.java svneol=native#text/plain
+src/Card.java svneol=native#text/plain
+src/CardDetailUtil.java svneol=native#text/plain
+src/CardFactory.java svneol=native#text/plain
+src/CardFactoryUtil.java svneol=native#text/plain
+src/CardList.java svneol=native#text/plain
+src/CardListFilter.java svneol=native#text/plain
+src/CardListUtil.java svneol=native#text/plain
+src/CardPanel.java svneol=native#text/plain
+src/CardUtil.java svneol=native#text/plain
+src/Combat.java svneol=native#text/plain
+src/CombatPlaneswalker.java svneol=native#text/plain
+src/CombatUtil.java svneol=native#text/plain
+src/Command.java svneol=native#text/plain
+src/CommandArgs.java svneol=native#text/plain
+src/CommandList.java svneol=native#text/plain
+src/CommandReturn.java svneol=native#text/plain
+src/Computer.java svneol=native#text/plain
+src/ComputerAI_Burn.java svneol=native#text/plain
+src/ComputerAI_Burn2.java svneol=native#text/plain
+src/ComputerAI_General.java svneol=native#text/plain
+src/ComputerAI_Input.java svneol=native#text/plain
+src/ComputerAI_Rats2.java svneol=native#text/plain
+src/ComputerAI_StackNotEmpty.java svneol=native#text/plain
+src/ComputerAI_Testing.java svneol=native#text/plain
+src/ComputerAI_counterSpells.java -text svneol=native#text/plain
+src/ComputerUtil.java -text svneol=native#text/plain
+src/ComputerUtil_Attack2.java svneol=native#text/plain
+src/ComputerUtil_Block2.java svneol=native#text/plain
+src/Computer_Cleanup.java svneol=native#text/plain
+src/Computer_Draw.java svneol=native#text/plain
+src/Computer_Race.java svneol=native#text/plain
+src/Constant.java svneol=native#text/plain
+src/Deck.java svneol=native#text/plain
+src/DeckIO.java svneol=native#text/plain
+src/DefaultPlayerZone.java svneol=native#text/plain
+src/Display.java svneol=native#text/plain
+src/EndOfTurn.java svneol=native#text/plain
+src/ErrorViewer.java svneol=native#text/plain
+src/ExternalPanel.java svneol=native#text/plain
+src/FileUtil.java -text svneol=native#text/plain
+src/GameAction.java svneol=native#text/plain
+src/GameActionUtil.java svneol=native#text/plain
+src/GenerateConstructedDeck.java svneol=native#text/plain
+src/GenerateConstructedMultiColorDeck.java -text svneol=native#text/plain
+src/GenerateDraftDeck.java svneol=native#text/plain
+src/GenerateSealedDeck.java svneol=native#text/plain
+src/GuiDisplay.java svneol=native#text/plain
+src/GuiDisplay2.java svneol=native#text/plain
+src/GuiDisplay3.java -text svneol=native#text/plain
+src/GuiDisplayUtil.java svneol=native#text/plain
+src/GuiInput.java svneol=native#text/plain
+src/Gui_BoosterDraft.java svneol=native#text/plain
+src/Gui_DeckEditor.java -text svneol=native#text/plain
+src/Gui_DeckEditor_Menu.java svneol=native#text/plain
+src/Gui_DownloadPictures.java svneol=native#text/plain
+src/Gui_MultipleBlockers.java svneol=native#text/plain
+src/Gui_NewGame.java svneol=native#text/plain
+src/Gui_Quest.java svneol=native#text/plain
+src/Gui_QuestOptions.java svneol=native#text/plain
+src/Gui_Quest_DeckEditor.java -text svneol=native#text/plain
+src/Gui_Quest_DeckEditor_Menu.java -text svneol=native#text/plain
+src/Gui_SealedDeck.java svneol=native#text/plain
+src/Gui_SetEditor.java svneol=native#text/plain
+src/Gui_Welcome.java svneol=native#text/plain
+src/Gui_WinLose.java svneol=native#text/plain
+src/IO.java svneol=native#text/plain
+src/ImageCache.java svneol=native#text/plain
+src/ImageJPanel.java -text svneol=native#text/plain
+src/ImageUtil.java svneol=native#text/plain
+src/Input.java svneol=native#text/plain
+src/InputControl.java svneol=native#text/plain
+src/InputUtil.java svneol=native#text/plain
+src/Input_Attack.java svneol=native#text/plain
+src/Input_Attack_Instant.java -text svneol=native#text/plain
+src/Input_Attack_Planeswalker.java svneol=native#text/plain
+src/Input_Before_Attack_Instant.java -text svneol=native#text/plain
+src/Input_Block.java svneol=native#text/plain
+src/Input_Block_Instant.java svneol=native#text/plain
+src/Input_Block_Planeswalker.java svneol=native#text/plain
+src/Input_Cleanup.java svneol=native#text/plain
+src/Input_CombatDamage.java svneol=native#text/plain
+src/Input_Draw.java svneol=native#text/plain
+src/Input_EOT.java svneol=native#text/plain
+src/Input_FirstStrikeDamage.java -text svneol=native#text/plain
+src/Input_Main.java svneol=native#text/plain
+src/Input_Mulligan.java svneol=native#text/plain
+src/Input_NoCost_TapAbility.java svneol=native#text/plain
+src/Input_PayManaCost.java svneol=native#text/plain
+src/Input_PayManaCostUtil.java svneol=native#text/plain
+src/Input_PayManaCost_Ability.java svneol=native#text/plain
+src/Input_StackNotEmpty.java svneol=native#text/plain
+src/Input_Untap.java svneol=native#text/plain
+src/KeyListenerTest.java -text svneol=native#text/plain
+src/MagicStack.java svneol=native#text/plain
+src/ManaCost.java svneol=native#text/plain
+src/ManaPool.java svneol=native#text/plain
+src/Mana_Part.java svneol=native#text/plain
+src/Mana_PartColor.java svneol=native#text/plain
+src/Mana_PartColorless.java svneol=native#text/plain
+src/Mana_PartSplit.java svneol=native#text/plain
+src/Mana_PartTest.java svneol=native#text/plain
+src/Mana_PayCost.java svneol=native#text/plain
+src/MenuItem_HowToPlay.java svneol=native#text/plain
+src/Move.java svneol=native#text/plain
+src/MoveAttack.java svneol=native#text/plain
+src/MyButton.java svneol=native#text/plain
+src/MyObservable.java svneol=native#text/plain
+src/MyRandom.java svneol=native#text/plain
+src/NameChanger.java svneol=native#text/plain
+src/NewIO.java svneol=native#text/plain
+src/NonScrollingJEditorPane.java -text svneol=native#text/plain
+src/Phase.java svneol=native#text/plain
+src/PhaseObserver.java svneol=native#text/plain
+src/PicturePanel.java svneol=native#text/plain
+src/PlayerLife.java svneol=native#text/plain
+src/PlayerZone.java svneol=native#text/plain
+src/PlayerZoneUtil.java svneol=native#text/plain
+src/PlayerZone_ComesIntoPlay.java svneol=native#text/plain
+src/PrintCardNames.java svneol=native#text/plain
+src/PrintCardPictures.java svneol=native#text/plain
+src/QuestData.java svneol=native#text/plain
+src/QuestData_BoosterPack.java svneol=native#text/plain
+src/ReadBoosterPack.java svneol=native#text/plain
+src/ReadCard.java svneol=native#text/plain
+src/Run.java svneol=native#text/plain
+src/RunTest.java svneol=native#text/plain
+src/SimpleCombat.java svneol=native#text/plain
+src/Spell.java svneol=native#text/plain
+src/SpellAbility.java -text svneol=native#text/plain
+src/SpellAbilityList.java svneol=native#text/plain
+src/SpellAbilityUtil.java svneol=native#text/plain
+src/Spell_Evoke.java svneol=native#text/plain
+src/Spell_Permanent.java svneol=native#text/plain
+src/StackObserver.java svneol=native#text/plain
+src/StateBasedEffects.java -text svneol=native#text/plain
+src/TableModel.java -text svneol=native#text/plain
+src/TableSorter.java svneol=native#text/plain
+src/TempRun.java svneol=native#text/plain
+src/Test.java svneol=native#text/plain
+src/TestMove.java svneol=native#text/plain
+src/TestPanel.java svneol=native#text/plain
+src/Time.java svneol=native#text/plain
+src/UndoCommand.java svneol=native#text/plain
+src/Wait.java svneol=native#text/plain
+src/WinLose.java svneol=native#text/plain
+src/forge.properties svneol=native#text/plain
+src/forge/error/ErrorViewer.java svneol=native#text/plain
+src/forge/error/ExceptionHandler.java -text svneol=native#text/plain
+src/forge/gui/ForgeAction.java svneol=native#text/plain
+src/forge/gui/ListChooser.java svneol=native#text/plain
+src/forge/properties/ForgeProps.java svneol=native#text/plain
+src/forge/properties/NewConstants.java svneol=native#text/plain
+src/org/jdesktop/swingx/MultiSplitLayout.java -text svneol=native#text/plain
+src/org/jdesktop/swingx/MultiSplitPane.java -text svneol=native#text/plain
+src/res/AllTokens.txt -text svneol=native#text/plain
+src/res/all-decks2 -text svneol=unset#unset
+src/res/booster-decks -text svneol=unset#unset
+src/res/card-pictures.txt -text svneol=native#text/plain
+src/res/cards.txt -text svneol=native#text/plain
+src/res/common.txt -text svneol=native#text/plain
+src/res/gui/display_layout.xml svneol=native#text/xml
+src/res/gui/gui.properties svneol=native#text/plain
+src/res/lang/de.properties svneol=native#text/plain
+src/res/lang/en.properties svneol=native#text/plain
+src/res/lang/howTo/de.properties svneol=native#text/plain
+src/res/lang/howTo/en.properties svneol=native#text/plain
+src/res/lang/lang.properties svneol=native#text/plain
+src/res/main.properties svneol=native#text/plain
+src/res/name-mutator.txt -text svneol=native#text/plain
+src/res/quest/common.txt -text svneol=native#text/plain
+src/res/quest/easy.txt -text svneol=native#text/plain
+src/res/quest/hard.txt -text svneol=native#text/plain
+src/res/quest/medium.txt -text svneol=native#text/plain
+src/res/quest/quest.properties svneol=native#text/plain
+src/res/quest/questData -text svneol=unset#unset
+src/res/quest/rare.txt -text svneol=native#text/plain
+src/res/quest/uncommon.txt -text svneol=native#text/plain
+src/res/rare.txt -text svneol=native#text/plain
+src/res/tokens.txt -text svneol=native#text/plain
+src/res/uncommon.txt -text svneol=native#text/plain
+src/treeProperties/PropertyElement.java svneol=native#text/plain
+src/treeProperties/PropertyType.java -text svneol=native#text/plain
+src/treeProperties/TreeProperties.java -text svneol=native#text/plain
+src/treeProperties/types/FileType.java -text svneol=native#text/plain
diff --git a/.project b/.project
new file mode 100644
index 00000000000..22afe0576f5
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ ForgeSVN
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..e3a5f24edd2
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Oct 12 15:27:12 CDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/src/.classpath b/src/.classpath
new file mode 100644
index 00000000000..6d488d7cbbf
--- /dev/null
+++ b/src/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/.project b/src/.project
new file mode 100644
index 00000000000..4fd226bab1d
--- /dev/null
+++ b/src/.project
@@ -0,0 +1,17 @@
+
+
+ Forge2
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/src/2009-10-12-00.txt b/src/2009-10-12-00.txt
new file mode 100644
index 00000000000..9eb2dc5e72d
--- /dev/null
+++ b/src/2009-10-12-00.txt
@@ -0,0 +1,41 @@
+An error has occured. You can copy/paste this message or save it to a file.
+Please report this, plus what you tried to do, to:
+ http://www.slightlymagic.net/forum/viewforum.php?f=26
+If you don't want to register an account, you can mail it directly to
+ mtgrares@yahoo.com
+
+Index: 7, Size: 4
+
+Detailed error trace:
+java.lang.IndexOutOfBoundsException: Index: 7, Size: 4
+ at java.util.ArrayList.add(Unknown Source)
+ at CardList.add(CardList.java:69)
+ at GameAction.smoothComputerManaCurve(GameAction.java:831)
+ at GameAction.newGame(GameAction.java:783)
+ at Gui_NewGame.startButton_actionPerformed(Gui_NewGame.java:433)
+ at Gui_NewGame$5.actionPerformed(Gui_NewGame.java:272)
+ at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
+ at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
+ at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
+ at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
+ at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
+ at java.awt.Component.processMouseEvent(Unknown Source)
+ at javax.swing.JComponent.processMouseEvent(Unknown Source)
+ at java.awt.Component.processEvent(Unknown Source)
+ at java.awt.Container.processEvent(Unknown Source)
+ at java.awt.Component.dispatchEventImpl(Unknown Source)
+ at java.awt.Container.dispatchEventImpl(Unknown Source)
+ at java.awt.Component.dispatchEvent(Unknown Source)
+ at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
+ at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
+ at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
+ at java.awt.Container.dispatchEventImpl(Unknown Source)
+ at java.awt.Window.dispatchEventImpl(Unknown Source)
+ at java.awt.Component.dispatchEvent(Unknown Source)
+ at java.awt.EventQueue.dispatchEvent(Unknown Source)
+ at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
+ at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
+ at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
+ at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
+ at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
+ at java.awt.EventDispatchThread.run(Unknown Source)
diff --git a/src/Ability.java b/src/Ability.java
new file mode 100644
index 00000000000..8899c56f58b
--- /dev/null
+++ b/src/Ability.java
@@ -0,0 +1,21 @@
+abstract public class Ability extends SpellAbility
+{
+ public Ability(Card sourceCard, String manaCost)
+ {
+ super(SpellAbility.Ability, sourceCard);
+ setManaCost(manaCost);
+ }
+ public Ability(Card sourceCard, String manaCost, String stackDescription)
+ {
+ this(sourceCard, manaCost);
+ setStackDescription(stackDescription);
+ System.out.println("an ability is being played from" + sourceCard.getName());
+ }
+ public boolean canPlay()
+ {
+// if(getSourceCard().isCreature() && (!getSourceCard().hasSickness()))
+ return AllZone.GameAction.isCardInPlay(getSourceCard()) && !getSourceCard().isFaceDown();
+
+// return false;
+ }
+}
diff --git a/src/Ability_Activated.java b/src/Ability_Activated.java
new file mode 100644
index 00000000000..2746ecca904
--- /dev/null
+++ b/src/Ability_Activated.java
@@ -0,0 +1,24 @@
+abstract public class Ability_Activated extends SpellAbility implements java.io.Serializable
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public Ability_Activated(Card sourceCard)
+ {
+ this(sourceCard, "");
+ }
+ public Ability_Activated(Card sourceCard, String manaCost)
+ {
+ super(SpellAbility.Ability, sourceCard);
+ setManaCost(manaCost);
+ }
+ public boolean canPlay()
+ {
+ Card c = getSourceCard();
+
+ return AllZone.GameAction.isCardInPlay(c) && !c.isFaceDown();
+ //TODO: make sure you can't play the Computer's activated abilities
+ }
+}
diff --git a/src/Ability_Hand.java b/src/Ability_Hand.java
new file mode 100644
index 00000000000..35a3dbebf77
--- /dev/null
+++ b/src/Ability_Hand.java
@@ -0,0 +1,23 @@
+//TODO: make this class a type of Ability
+abstract public class Ability_Hand extends SpellAbility implements java.io.Serializable
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public Ability_Hand(Card sourceCard)
+ {
+ this(sourceCard, "");
+ }
+ public Ability_Hand(Card sourceCard, String manaCost)
+ {
+ super(SpellAbility.Ability, sourceCard);
+ setManaCost(manaCost);
+ }
+ public boolean canPlay()
+ {
+ PlayerZone zone = AllZone.getZone(getSourceCard());
+ return zone.is(Constant.Zone.Hand, getSourceCard().getController());
+ }
+}
\ No newline at end of file
diff --git a/src/Ability_Mana.java b/src/Ability_Mana.java
new file mode 100644
index 00000000000..2c45cc8d6b5
--- /dev/null
+++ b/src/Ability_Mana.java
@@ -0,0 +1,158 @@
+import java.util.*;
+
+abstract public class Ability_Mana extends SpellAbility implements java.io.Serializable
+{
+ private ArrayList runcommands = new ArrayList();
+ public String orig;
+ private String Mana;
+
+ public boolean isBasic()
+ {
+ return(orig.length() ==10 && orig.startsWith("tap: add ") && "1WBURG".contains(""+orig.charAt(9)));
+ }
+ private static final long serialVersionUID = 8292723782268822439L;
+ /*public Ability_Mana(Card sourceCard, String mana)
+ {
+ this(sourceCard, "0");
+ }*/
+ public boolean isTapAbility(){return isTapAbility(orig);}
+ private static boolean isTapAbility(String orig){
+ String cost = orig.split(":")[0];
+ cost = cost.replaceAll("tap", "T");
+ return (cost.contains("T"));
+ }
+ public Ability_Mana(Card sourceCard, String orig)
+ {
+ super(isTapAbility(orig) ? SpellAbility.Ability_Tap : SpellAbility.Ability, sourceCard);
+ this.orig=orig;
+ setDescription(orig);
+ if(isBasic())//lowers memory usage drastically
+ {
+ Mana = "" + orig.charAt(9);
+ setManaCost("0");
+ return;
+ }
+ String[] parts = orig.split(":");
+ Mana=parts[1];
+ Mana = Mana.replaceAll(" add ", "");
+ setStackDescription("Add "+ Mana +" to your mana pool.");
+ Mana = Mana.replaceAll(" ", "");
+
+ String cost=parts[0];
+ cost = cost.replaceAll("tap", "T");
+ //cost = cost.replaceAll("T, ", "");
+ setManaCost(cost.replaceAll("T", "").split(",")[0]);
+ if (getManaCost().equals("")) setManaCost("0");
+ //pain lands
+ ArrayList pain = new ArrayList();
+ pain.add("Battlefield Forge");
+ pain.add("Caves of Koilos");
+ pain.add("Llanowar Wastes");
+ pain.add("Shivan Reef");
+ pain.add("Yavimaya Coast");
+ pain.add("Adarkar Wastes");
+ pain.add("Brushland");
+ pain.add("Karplusan Forest");
+ pain.add("Underground River");
+ pain.add("Sulfurous Springs");
+ if(pain.contains(sourceCard.getName()) && !Mana.equals("1"))
+ runcommands.add(new Command()
+ {
+ private static final long serialVersionUID = 1L;
+ public void execute(){
+
+ AllZone.GameAction.getPlayerLife(getController()).subtractLife(1);
+ }});
+ //parseCosts();
+ /*for(String subcost : cost.split(","))
+ {
+ subcost.trim();
+ if (subcost.equals("") || subcost.equals("T") ||
+ subcost.equals(getManaCost())) continue;
+ if (subcost.startsWith("Sacrifice a")){
+ String sactype= subcost.substring(12).trim();//will remove both "Sac a " and "Sac an" :P
+ Input bpM_old = getBeforePayMana();
+ }
+ }*/
+ }
+ public boolean equals(Object o)//Mana abilities with equal descriptions are considered equal, please take this into account
+ {return (o instanceof Ability_Mana ? ((Ability_Mana)o).orig.equals(orig) : (o instanceof String ? o.toString().equals(orig) : false )) ;}
+ public boolean equalsIgnoreMana(Ability_Mana ma)
+ {
+ String noManaDesc=orig.substring(0,orig.indexOf(Mana));
+ noManaDesc+=orig.substring(orig.indexOf(Mana)+Mana.length());
+ String noManaDesc_2=ma.orig.substring(0,ma.orig.indexOf(Mana));
+ noManaDesc_2+=ma.orig.substring(ma.orig.indexOf(Mana)+Mana.length());
+ return noManaDesc.equals(noManaDesc_2);
+ }
+
+
+ public String toString(){return orig;}
+ boolean undoable=false;
+ public void undo(){getSourceCard().untap();}//override undo() and set undoable for custom undo costs
+ public boolean undoable(){return isBasic() || undoable;}
+ public void parseCosts(){parseCosts(orig);}
+ private void parseCosts(String orig)
+ {
+ setBeforePayMana(null);// reset everything
+ setAfterPayMana(null);
+ setAfterResolve(null);
+
+ String[] split={",",":","."};//i.e. "cost,cost,cost<...>:Effect.Effect.Effect.
+ String copy=orig+"";
+ for(String s : split)
+ {
+ copy=copy.replaceAll(" " + s, s); //trim splitter whitespace
+ copy=copy.replaceAll(s + " ", s);
+ }
+ copy=copy.replaceAll("T"+split[0], "");//i.e. "T,"-> ""(reason for this is that tapCost is already determined)
+ copy=copy.trim();
+ if (!("123456789GWURBXY(".contains(copy.charAt(0)+"")))
+ {
+ setManaCost("0");
+ copy=split[0] + copy;
+ }//Hacky, but should work
+ else setManaCost(copy.substring(0, copy.indexOf(",")));
+ String divider = ",";
+ while(!copy.trim().equals(""))
+ {
+ if(copy.startsWith(":"))
+ if (!divider.equals(".")) divider=".";
+ while (copy.startsWith(":") || copy.startsWith(divider) ) copy=copy.substring(1);
+ String current=copy.substring(0, copy.indexOf(","));
+ if (current.startsWith("Sacrifice a")){
+
+ }
+ copy=copy.substring(current.length());
+ }
+ }
+ public void resolve(){
+ AllZone.ManaPool.addMana(this);
+ if(!runcommands.isEmpty())
+ for(Command c : runcommands) c.execute();
+ }
+ public int getX(){return getSourceCard().getX();}//override these when not defined by card,
+ public void setX(int X){getSourceCard().setX(X);}//i.e. "T, remove X charge counters from {name}: add X+1 mana to your mana pool"
+ public String Mana(){return Mana;}//override for all non-X variable mana,
+ public String getController(){return getSourceCard().getController();}
+
+ public boolean canPlayAI(){return false;}
+ public boolean canPlay()
+ {
+ Card card = getSourceCard();
+ if(AllZone.GameAction.isCardInPlay(card) &&(!isTapAbility() || card.isUntapped()))
+ {
+ if(card.isFaceDown())
+ return false;
+
+ if(card.isArtifact() && card.isCreature())
+ return !(card.hasSickness() && isTapAbility());
+
+ if(card.isCreature() && (!card.hasSickness() || !isTapAbility()))
+ return true;
+ else if(card.isArtifact() || card.isGlobalEnchantment() || card.isLand())
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/Ability_Tap.java b/src/Ability_Tap.java
new file mode 100644
index 00000000000..e1924fdf871
--- /dev/null
+++ b/src/Ability_Tap.java
@@ -0,0 +1,33 @@
+abstract public class Ability_Tap extends SpellAbility implements java.io.Serializable
+{
+
+ private static final long serialVersionUID = 8292723782268822539L;
+ public Ability_Tap(Card sourceCard)
+ {
+ this(sourceCard, "0");
+ }
+ public Ability_Tap(Card sourceCard, String manaCost)
+ {
+ super(SpellAbility.Ability_Tap, sourceCard);
+ setManaCost(manaCost);
+ }
+ public boolean canPlay()
+ {
+ Card card = getSourceCard();
+
+ if(AllZone.GameAction.isCardInPlay(card) && card.isUntapped())
+ {
+ if(card.isFaceDown())
+ return false;
+
+ if(card.isArtifact() && card.isCreature())
+ return !card.hasSickness();
+
+ if(card.isCreature() && (!card.hasSickness()))
+ return true;
+ else if(card.isArtifact() || card.isGlobalEnchantment() || card.isLand())
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/All.java b/src/All.java
new file mode 100644
index 00000000000..5faa60f70bc
--- /dev/null
+++ b/src/All.java
@@ -0,0 +1,21 @@
+public class All
+{
+ public Phase Phase = new Phase();
+ public MagicStack Stack = new MagicStack();
+
+ public PlayerLife Human_Life = new PlayerLife();
+ public PlayerLife Computer_Life = new PlayerLife();
+
+ //Human_Play, Computer_Play is different because Card.comesIntoPlay() is called when a card is added by PlayerZone.add(Card)
+ public PlayerZone Human_Play = new PlayerZone_ComesIntoPlay(Constant.Zone.Play, Constant.Player.Human);
+ public PlayerZone Human_Hand = new DefaultPlayerZone(Constant.Zone.Hand , Constant.Player.Human);
+ public PlayerZone Human_Graveyard = new DefaultPlayerZone(Constant.Zone.Graveyard , Constant.Player.Human);
+ public PlayerZone Human_Library = new DefaultPlayerZone(Constant.Zone.Library , Constant.Player.Human);
+ public PlayerZone Human_Removed = new DefaultPlayerZone(Constant.Zone.Removed_From_Play, Constant.Player.Human);
+
+ public PlayerZone Computer_Play = new PlayerZone_ComesIntoPlay(Constant.Zone.Play , Constant.Player.Computer);
+ public PlayerZone Computer_Hand = new DefaultPlayerZone(Constant.Zone.Hand , Constant.Player.Computer);
+ public PlayerZone Computer_Graveyard = new DefaultPlayerZone(Constant.Zone.Graveyard , Constant.Player.Computer);
+ public PlayerZone Computer_Library = new DefaultPlayerZone(Constant.Zone.Library , Constant.Player.Computer);
+ public PlayerZone Computer_Removed = new DefaultPlayerZone(Constant.Zone.Removed_From_Play, Constant.Player.Computer);
+}
\ No newline at end of file
diff --git a/src/AllZone.java b/src/AllZone.java
new file mode 100644
index 00000000000..ef6057851ef
--- /dev/null
+++ b/src/AllZone.java
@@ -0,0 +1,99 @@
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import forge.properties.ForgeProps;
+import forge.properties.NewConstants;
+
+
+public class AllZone implements NewConstants {
+ //only for testing, should read decks from local directory
+// public static final IO IO = new IO("all-decks");
+
+ public static QuestData QuestData = null;
+ public static final NameChanger NameChanger = new NameChanger();
+
+ public static EndOfTurn EndOfTurn = new EndOfTurn();
+ public static final CardFactory CardFactory = new CardFactory(ForgeProps.getFile(CARDS));
+
+ public static final Phase Phase = new Phase();
+ public static final MagicStack Stack = new MagicStack();
+ public static final InputControl InputControl = new InputControl();
+ public static final GameAction GameAction = new GameAction();
+ public static final StateBasedEffects StateBasedEffects = new StateBasedEffects();
+
+ //initialized at Runtime since it has to be the last object constructed
+
+ public static ComputerAI_Input Computer;
+
+ //shared between Input_Attack , Input_Block,
+ // Input_CombatDamage , InputState_Computer
+ public static Combat Combat = new Combat();
+ public static Combat pwCombat = new Combat();//for Planeswalker combat
+
+ public static PlayerLife Human_Life = new PlayerLife();
+ public static PlayerLife Computer_Life = new PlayerLife();
+
+ //Human_Play, Computer_Play is different because Card.comesIntoPlay() is called when a card is added by PlayerZone.add(Card)
+ public final static PlayerZone Human_Play = new PlayerZone_ComesIntoPlay(Constant.Zone.Play, Constant.Player.Human);
+ public final static PlayerZone Human_Hand = new DefaultPlayerZone(Constant.Zone.Hand , Constant.Player.Human);
+ public final static PlayerZone Human_Graveyard = new DefaultPlayerZone(Constant.Zone.Graveyard , Constant.Player.Human);
+ public final static PlayerZone Human_Library = new DefaultPlayerZone(Constant.Zone.Library , Constant.Player.Human);
+ public final static PlayerZone Human_Removed = new DefaultPlayerZone(Constant.Zone.Removed_From_Play, Constant.Player.Human);
+
+ public final static PlayerZone Computer_Play = new PlayerZone_ComesIntoPlay(Constant.Zone.Play , Constant.Player.Computer);
+ public final static PlayerZone Computer_Hand = new DefaultPlayerZone(Constant.Zone.Hand , Constant.Player.Computer);
+ public final static PlayerZone Computer_Graveyard = new DefaultPlayerZone(Constant.Zone.Graveyard , Constant.Player.Computer);
+ public final static PlayerZone Computer_Library = new DefaultPlayerZone(Constant.Zone.Library , Constant.Player.Computer);
+ public final static PlayerZone Computer_Removed = new DefaultPlayerZone(Constant.Zone.Removed_From_Play, Constant.Player.Computer);
+
+ public static final ManaPool ManaPool = new ManaPool();
+
+ public static Display Display = new GuiDisplay2();
+
+
+ private final static Map map = new HashMap();
+
+ static
+ {
+ map.put(Constant.Zone.Graveyard + Constant.Player.Human, Human_Graveyard);
+ map.put(Constant.Zone.Hand + Constant.Player.Human, Human_Hand);
+ map.put(Constant.Zone.Library + Constant.Player.Human, Human_Library);
+ map.put(Constant.Zone.Play + Constant.Player.Human, Human_Play);
+ map.put(Constant.Zone.Removed_From_Play + Constant.Player.Human, Human_Removed);
+
+ map.put(Constant.Zone.Graveyard + Constant.Player.Computer, Computer_Graveyard);
+ map.put(Constant.Zone.Hand + Constant.Player.Computer, Computer_Hand);
+ map.put(Constant.Zone.Library + Constant.Player.Computer, Computer_Library);
+ map.put(Constant.Zone.Play + Constant.Player.Computer, Computer_Play);
+ map.put(Constant.Zone.Removed_From_Play + Constant.Player.Computer, Computer_Removed);
+ }
+ public static PlayerZone getZone(Card c)
+ {
+ Iterator it = map.values().iterator();
+ PlayerZone p;
+ while(it.hasNext())
+ {
+ p = (PlayerZone)it.next();
+
+ if(GameAction.isCardInZone(c, p))
+ return p;
+ }
+ return null;
+// throw new RuntimeException("AllZone : getZone() error, card is not found, card is " +c);
+ }
+ public static PlayerZone getZone(String zone, String player)
+ {
+ if (player.equals("")) { //this is a really bad hack, to allow raging goblin to attack on turn 1
+ player = "Human";
+ System.out.println("Evil hack");
+ }
+ Object o = map.get(zone + player);
+ if(o == null)
+ throw new RuntimeException("AllZone : getZone() invalid parameters " +zone +" " +player);
+
+ return (PlayerZone)o;
+ }
+}//AllZone
\ No newline at end of file
diff --git a/src/BackgroundPanel.java b/src/BackgroundPanel.java
new file mode 100644
index 00000000000..5dd508b5ae1
--- /dev/null
+++ b/src/BackgroundPanel.java
@@ -0,0 +1,275 @@
+import java.awt.*;
+import javax.swing.*;
+
+/*
+ * Support custom painting on a panel in the form of
+ *
+ * a) images - that can be scaled, tiled or painted at original size
+ * b) non solid painting - that can be done by using a Paint object
+ *
+ * Also, any component added directly to this panel will be made
+ * non-opaque so that the custom painting can show through.
+ */
+public class BackgroundPanel extends JPanel
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final int SCALED = 0;
+ public static final int TILED = 1;
+ public static final int ACTUAL = 2;
+
+ private Paint painter;
+ private Image image;
+ private int style = ACTUAL;
+ private float alignmentX = 0.5f;
+ private float alignmentY = 0.5f;
+ private boolean isTransparentAdd = true;
+
+ /*
+ * Set image-string as the background with the SCALED style
+ */
+ public BackgroundPanel(String s)
+ {
+
+ ImageIcon imageIcon = new ImageIcon("pics\\" + s);
+ image = imageIcon.getImage();
+
+ setImage( image );
+ setStyle( style );
+ setLayout( new BorderLayout() );
+ repaint();
+ }
+
+ public BackgroundPanel()
+ {
+ setStyle( style );
+ setLayout( new BorderLayout() );
+ repaint();
+ }
+
+
+ /*
+ * Set image as the background with the SCALED style
+ */
+ public BackgroundPanel(Image image)
+ {
+ this(image, SCALED);
+
+ }
+
+ /*
+ * Set image as the background with the specified style
+ */
+ public BackgroundPanel(Image image, int style)
+ {
+ setImage( image );
+ setStyle( style );
+ setLayout( new BorderLayout() );
+ }
+
+ /*
+ * Set image as the backround with the specified style and alignment
+ */
+ public BackgroundPanel(Image image, int style, float alignmentX, float alignmentY)
+ {
+ setImage( image );
+ setStyle( style );
+ setImageAlignmentX( alignmentX );
+ setImageAlignmentY( alignmentY );
+ setLayout( new BorderLayout() );
+ }
+
+ /*
+ * Use the Paint interface to paint a background
+ */
+ public BackgroundPanel(Paint painter)
+ {
+ setPaint( painter );
+ setLayout( new BorderLayout() );
+ }
+
+ /*
+ * Set the image used as the background
+ */
+ public void setImage(Image image)
+ {
+ this.image = image;
+ repaint();
+ }
+
+ /*
+ * Set the style used to paint the background image
+ */
+ public void setStyle(int style)
+ {
+ this.style = style;
+ repaint();
+ }
+
+ /*
+ * Set the Paint object used to paint the background
+ */
+ public void setPaint(Paint painter)
+ {
+ this.painter = painter;
+ repaint();
+ }
+
+ /*
+ * Specify the horizontal alignment of the image when using ACTUAL style
+ */
+ public void setImageAlignmentX(float alignmentX)
+ {
+ this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
+ repaint();
+ }
+
+ /*
+ * Specify the horizontal alignment of the image when using ACTUAL style
+ */
+ public void setImageAlignmentY(float alignmentY)
+ {
+ this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
+ repaint();
+ }
+
+ /*
+ * Override method so we can make the component transparent
+ */
+ public void add(JComponent component)
+ {
+ add(component, null);
+ }
+
+ /*
+ * Override method so we can make the component transparent
+ */
+ public void add(JComponent component, Object constraints)
+ {
+ if (isTransparentAdd)
+ {
+ makeComponentTransparent(component);
+ }
+
+ super.add(component, constraints);
+ }
+
+ /*
+ * Controls whether components added to this panel should automatically
+ * be made transparent. That is, setOpaque(false) will be invoked.
+ * The default is set to true.
+ */
+ public void setTransparentAdd(boolean isTransparentAdd)
+ {
+ this.isTransparentAdd = isTransparentAdd;
+ }
+
+ /*
+ * Try to make the component transparent.
+ * For components that use renderers, like JTable, you will also need to
+ * change the renderer to be transparent. An easy way to do this it to
+ * set the background of the table to a Color using an alpha value of 0.
+ */
+ private void makeComponentTransparent(JComponent component)
+ {
+ component.setOpaque( false );
+
+ if (component instanceof JScrollPane)
+ {
+ JScrollPane scrollPane = (JScrollPane)component;
+ JViewport viewport = scrollPane.getViewport();
+ viewport.setOpaque( false );
+ Component c = viewport.getView();
+
+ if (c instanceof JComponent)
+ {
+ ((JComponent)c).setOpaque( false );
+ }
+ }
+ }
+
+ /*
+ * Add custom painting
+ */
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+
+ // Invoke the painter for the background
+
+ if (painter != null)
+ {
+ Dimension d = getSize();
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setPaint(painter);
+ g2.fill( new Rectangle(0, 0, d.width, d.height) );
+ }
+
+ // Draw the image
+
+ if (image == null ) return;
+
+ switch (style)
+ {
+ case SCALED :
+ drawScaled(g);
+ break;
+
+ case TILED :
+ drawTiled(g);
+ break;
+
+ case ACTUAL :
+ drawActual(g);
+ break;
+
+ default:
+ drawScaled(g);
+ }
+ }
+
+ /*
+ * Custom painting code for drawing a SCALED image as the background
+ */
+ private void drawScaled(Graphics g)
+ {
+ Dimension d = getSize();
+ g.drawImage(image, 0, 0, d.width, d.height, null);
+ }
+
+ /*
+ * Custom painting code for drawing TILED images as the background
+ */
+ private void drawTiled(Graphics g)
+ {
+ Dimension d = getSize();
+ int width = image.getWidth( null );
+ int height = image.getHeight( null );
+
+ for (int x = 0; x < d.width; x += width)
+ {
+ for (int y = 0; y < d.height; y += height)
+ {
+ g.drawImage( image, x, y, null, null );
+ }
+ }
+ }
+
+ /*
+ * Custom painting code for drawing the ACTUAL image as the background.
+ * The image is positioned in the panel based on the horizontal and
+ * vertical alignments specified.
+ */
+ private void drawActual(Graphics g)
+ {
+ Dimension d = getSize();
+ Insets insets = getInsets();
+ int width = d.width - insets.left - insets.right;
+ int height = d.height - insets.top - insets.left;
+ float x = (width - image.getWidth(null)) * alignmentX;
+ float y = (height - image.getHeight(null)) * alignmentY;
+ g.drawImage(image, (int)x + insets.left, (int)y + insets.top, this);
+ }
+}
diff --git a/src/BoosterDraft.java b/src/BoosterDraft.java
new file mode 100644
index 00000000000..e11e6899d10
--- /dev/null
+++ b/src/BoosterDraft.java
@@ -0,0 +1,122 @@
+
+
+public interface BoosterDraft
+{
+ public CardList nextChoice();
+ public void setChoice(Card c);
+ public boolean hasNextChoice();
+ public Deck[] getDecks(); //size 7, all the computers decks
+}
+
+class BoosterDraft_1 implements BoosterDraft
+{
+ private final BoosterDraftAI draftAI = new BoosterDraftAI();
+ private final int nPlayers = 8;
+ private final int boosterPackSize = 15;
+ private final int stopCount = boosterPackSize * 3;//should total of 45
+
+ private int currentCount = 0;
+ private CardList[] pack;//size 8
+
+ //helps the computer choose which booster packs to pick from
+ //the first row says "pick from boosters 1-7, skip 0" since the players picks from 0
+ //the second row says "pick from 0 and 2-7 boosters, skip 1" - player chooses from 1
+ private final int computerChoose[][] = {
+ { 1,2,3,4,5,6,7},
+ {0, 2,3,4,5,6,7},
+ {0,1, 3,4,5,6,7},
+ {0,1,2, 4,5,6,7},
+ {0,1,2,3, 5,6,7},
+ {0,1,2,3,4, 6,7},
+ {0,1,2,3,4,5, 7},
+ {0,1,2,3,4,5,6 }
+ };
+
+ public static void main(String[] args)
+ {
+ BoosterDraft_1 draft = new BoosterDraft_1();
+ while(draft.hasNextChoice())
+ {
+ CardList list = draft.nextChoice();
+ System.out.println(list.size());
+ draft.setChoice(list.get(0));
+ }
+ }
+ BoosterDraft_1() {pack = get8BoosterPack();}
+
+ public CardList nextChoice()
+ {
+ if(pack[getMod()].size() == 0)
+ pack = get8BoosterPack();
+
+ computerChoose();
+ CardList list = pack[getMod()];
+ return list;
+ }
+ public CardList[] get8BoosterPack()
+ {
+ CardList[] list = new CardList[]
+ {//nPlayers is 8
+ new CardList(),
+ new CardList(),
+ new CardList(),
+ new CardList(),
+
+ new CardList(),
+ new CardList(),
+ new CardList(),
+ new CardList(),
+ };
+ ReadBoosterPack pack = new ReadBoosterPack();
+
+ for(int i = 0; i < list.length; i++)
+ list[i].addAll(pack.getBoosterPack().toArray());
+
+ return list;
+ }//get8BoosterPack()
+
+ //size 7, all the computers decks
+ public Deck[] getDecks() {return draftAI.getDecks();}
+
+ private void computerChoose()
+ {
+ int row[] = computerChoose[getMod()];
+
+ for(int i = 0; i < row.length; i++)
+ draftAI.choose(pack[row[i]]);
+ }//computerChoose()
+
+ private int getMod() {return currentCount % nPlayers;}
+ public boolean hasNextChoice() {return currentCount < stopCount;}
+
+ public void setChoice(Card c)
+ {
+ CardList list = pack[getMod()];
+ currentCount++;
+
+ if(! list.contains(c))
+ throw new RuntimeException("BoosterDraft : setChoice() error - card not found - " +c +" - booster pack = " +list);
+
+ list.remove(c);
+ }//setChoice()
+}
+
+class BoosterDraftTest implements BoosterDraft
+{
+ int n = 3;
+ public Deck[] getDecks() {return null;}
+
+ public CardList nextChoice()
+ {
+ n--;
+ ReadBoosterPack pack = new ReadBoosterPack();
+ return pack.getBoosterPack();
+ }
+ public void setChoice(Card c) {System.out.println(c.getName());}
+ public boolean hasNextChoice()
+ {
+ return n > 0;
+ }
+ public CardList getChosenCards() {return null;}
+ public CardList getUnchosenCards() {return null;}
+}
diff --git a/src/BoosterDraftAI.java b/src/BoosterDraftAI.java
new file mode 100644
index 00000000000..7f10445c0bf
--- /dev/null
+++ b/src/BoosterDraftAI.java
@@ -0,0 +1,302 @@
+import java.util.*;
+
+public class BoosterDraftAI
+{
+ //once a deck has this number of creatures the computer randomly
+ //picks a card, so the final computer deck has 12-20 creatures
+ //minimum of creatures per deck
+ private final int nCreatures = 16;
+ private final int nDecks = 7;
+
+ //holds all the cards for each of the computer's decks
+ private CardList[] deck = new CardList[nDecks];
+ private String[][] deckColor = new String[nDecks][];
+
+ private static Map colorToLand = new HashMap();
+
+ public static void main(String[] args)
+ {
+ BoosterDraftAI ai = new BoosterDraftAI();
+ ai.runTestPrint();
+ }
+ public void runTestPrint()
+ {
+ BoosterDraftAI ai = new BoosterDraftAI();
+ ai.runTest(ai);
+
+ Deck[] deck = ai.getDecks();
+
+ for(int outer = 0; outer < 7; outer++)
+ {
+ System.out.print(deck[outer].countMain() +" - ");
+
+ for(int i = 0; i < 16; i++)
+ System.out.print(deck[outer].getMain(i) +", ");
+
+ System.out.println("");
+
+ for(int i = 16; i < 22; i++)
+ System.out.print(deck[outer].getMain(i) +", ");
+
+ System.out.println("\n");
+ }//for outer
+ }//runTestPrint()
+
+ //throws Exception if error
+ public void runTest(BoosterDraftAI ai)
+ {
+ ReadBoosterPack booster = new ReadBoosterPack();
+ for(int outer = 0; outer < 1; outer++)
+ {
+ CardList allBooster = new CardList();
+ for(int i = 0; i < 21; i++)
+ allBooster.addAll(booster.getBoosterPack().toArray());
+
+ int stop = allBooster.size();
+ for(int i = 0; i < stop; i++)
+ {
+ ai.choose(allBooster);
+ }
+ //ai.checkDeckList(ai.deck);
+ }
+ }//runTest()
+
+ //picks one Card from augment, removes that card, and returns the list
+ //returns the cards not picked
+ public CardList choose(final CardList in_choose)
+ {
+ //in_choose should ONLY be on the RIGHT side of any equal sign
+ //only 1 card should be removed from in_choose
+
+ CardList list = new CardList();
+ boolean hasPicked = false;
+
+ //try to choose a creature that has one of the colors that are in the deck
+ for(int i = 0; i < nDecks; i++)
+ {
+ if(countCreatures(deck[i]) < nCreatures)
+ {
+ list.clear();
+
+ //get creature cards that match the decks 2 colors
+ list.addAll(CardListUtil.getColor(in_choose.getType("Creature"), deckColor[i][0]).toArray());
+ list.addAll(CardListUtil.getColor(in_choose.getType("Creature"), deckColor[i][1]).toArray());
+
+ for(int j=0;j 1)
+ {
+ //TODO maybe keep in cards that have 2 colors, and match the colors
+ list.remove(list.get(j));
+ }
+ }
+
+ list.shuffle();
+
+ if(! list.isEmpty())
+ {
+
+ deck[i].add(list.get(0));
+ hasPicked = true;
+ break;
+ }
+ }//if
+ }//for
+
+ //no card was chosen
+ if(! hasPicked)
+ {
+ //TODO: remove cards that the computer can't play
+ //holds instants and sorceries
+ CardList spell = new CardList();
+ spell.addAll(in_choose.getType("Instant").toArray());
+ spell.addAll(in_choose.getType("Sorcery").toArray());
+
+ //choose any card that matches the decks color
+ for(int i = 0; i < nDecks; i++)
+ {
+ list.clear();
+
+ list.addAll(deck[i].getType("Instant").toArray());
+ list.addAll(deck[i].getType("Sorcery").toArray());
+
+ //does the deck need more spells?
+ //16 creatures, 6 spells per deck
+ if(list.size() < 6)
+ {
+ list.clear();
+
+ //get any cards that match the decks 2 colors
+ list.addAll(CardListUtil.getColor(new CardList(spell.toArray()), deckColor[i][0]).toArray());
+ list.addAll(CardListUtil.getColor(new CardList(spell.toArray()), deckColor[i][1]).toArray());
+
+ list.shuffle();
+
+
+
+ if(! list.isEmpty())
+ {
+ deck[i].add(list.get(0));
+ hasPicked = true;
+ break;
+ }
+ }//if - deck[i].size() < 22
+ }//for
+ }//if - choose any card
+
+ if(hasPicked)
+ in_choose.remove(list.get(0));
+ else//computer didn't choose a card, just remove any card - all computer decks are done
+ {
+ in_choose.remove(0);
+ }
+
+ return in_choose;
+ }//choose()
+
+/*
+ I get some wierd error when I have this method, I don't know whats wrong
+
+ private void checkDeckList(CardList[] deck)
+ {
+ if(deck.length != nDecks)
+ throw new RuntimeException("BoosterDraftAI : checkDeckList() error, deck list size is not 7 - " +deck.length);
+
+ for(int i = 0; i < nDecks; i++)
+ {
+ if(deck[i].size() != 22)
+ {
+ throw new RuntimeException("BoosterDraftAI : checkDeckList() error, deck list size is not 22 - " +deck[i].size() +" - " +deck.toString());
+ }
+ if(countCreatures(deck[i]) < nCreatures)
+ throw new RuntimeException("BoosterDraftAI : checkDeckList() error, deck needs more creatures - " +countCreatures(deck[i]));
+
+ for(int inner = 0; inner < 22; inner++)
+ if(! CardUtil.getColors(deck[i].getCard(inner)).contains(deckColor[i][0]) &&
+ ! CardUtil.getColors(deck[i].getCard(inner)).contains(deckColor[i][1]))
+ throw new RuntimeException("BoosterDraftAI : checkDeckList() error, deck has different card colors");
+ }//for
+ }//checkDeckList()
+*/
+
+ private int countCreatures(CardList list) {return list.getType("Creature").size();}
+
+ private void testColors(int[] n)
+ {
+ if(n.length != nDecks)
+ throw new RuntimeException("BoosterDraftAI : testColors error, numbers array length does not equal 7");
+
+ HashSet set = new HashSet();
+ for(int i = 0; i < nDecks; i++)
+ set.add(new Integer(n[i]));
+
+ if(set.size() != nDecks)
+ throw new RuntimeException("BoosterDraftAI : testColors error, numbers not unique");
+
+ for(int i = 0; i < nDecks; i++)
+ if(n[i] < 0 || deckColorChoices.length <= n[i])
+ throw new RuntimeException("BoosterDraftAI : testColors error, index out of range - " +n[i]);
+ }//testColors()
+
+ public Deck[] getDecks()
+ {
+ //check CardList[] deck for errors
+ //checkDeckList(deck);
+
+ Deck[] out = new Deck[deck.length];
+
+ for(int i = 0; i < deck.length; i++)
+ {
+ addLand(deck[i], deckColor[i]);
+ out[i] = getDeck(deck[i]);
+ }
+ return out;
+ }//getDecks()
+
+ private Deck getDeck(CardList list)
+ {
+ Deck out = new Deck(Constant.GameType.Draft);
+ for(int i = 0; i < list.size(); i++)
+ out.addMain(list.get(i).getName());
+
+ return out;
+ }//getDeck()
+
+ //add Land to list argument
+ private void addLand(CardList list, String[] color)
+ {
+ Card land;
+ for(int i = 0; i < 9; i++)
+ {
+ land = AllZone.CardFactory.getCard(colorToLand.get(color[0]).toString(), Constant.Player.Computer);
+ list.add(land);
+
+ land = AllZone.CardFactory.getCard(colorToLand.get(color[1]).toString(), Constant.Player.Computer);
+ list.add(land);
+ }
+
+ if(list.getType("Land").size() != 18)
+ throw new RuntimeException("BoosterDraftAI : addLand() error, deck does not have 18 lands - " +list.getType("Land").size());
+
+ if(list.size() != 40)
+ throw new RuntimeException("BoosterDraftAI : addLand() error, deck is not 40 cards - " +list.size());
+ }//addLand()
+
+
+ //returns 7 different ints, within the range of 0-9
+ private int[] getDeckColors()
+ {
+ int[] out = new int[nDecks];
+ int start = MyRandom.random.nextInt();
+ start = Math.abs(start);//make number positive, stupid number generator
+
+ for(int i = 0; i < out.length; i++)
+ {
+ //% to get an index between 0 and deckColorChoices.length
+ out[i] = start % deckColorChoices.length;
+ start++;
+ }
+ testColors(out);
+
+ return out;
+ }//getDeckColors()
+
+ public BoosterDraftAI()
+ {
+ //choose colors for decks
+ int[] n = getDeckColors();
+ for(int i = 0; i < n.length; i++)
+ deckColor[i] = deckColorChoices[n[i]];
+
+ //initilize color map
+ colorToLand.put(Constant.Color.Black , "Swamp");
+ colorToLand.put(Constant.Color.Blue , "Island");
+ colorToLand.put(Constant.Color.Green , "Forest");
+ colorToLand.put(Constant.Color.Red , "Mountain");
+ colorToLand.put(Constant.Color.White , "Plains");
+
+ //initilize deck array
+ for(int i = 0; i < deck.length; i++)
+ deck[i] = new CardList();
+ }//BoosterDraftAI()
+
+
+ //all 10 two color combinations
+ private String[][] deckColorChoices =
+ {
+ {Constant.Color.Black, Constant.Color.Blue},
+ {Constant.Color.Black, Constant.Color.Green},
+ {Constant.Color.Black, Constant.Color.Red},
+ {Constant.Color.Black, Constant.Color.White},
+
+ {Constant.Color.Blue, Constant.Color.Green},
+ {Constant.Color.Blue, Constant.Color.Red},
+ {Constant.Color.Blue, Constant.Color.White},
+
+ {Constant.Color.Green, Constant.Color.Red},
+ {Constant.Color.Green, Constant.Color.White},
+
+ {Constant.Color.Red, Constant.Color.White}
+ };
+}//BoosterDraftAI()
\ No newline at end of file
diff --git a/src/BoosterPack.java b/src/BoosterPack.java
new file mode 100644
index 00000000000..9df679ed4e3
--- /dev/null
+++ b/src/BoosterPack.java
@@ -0,0 +1,27 @@
+
+
+public class BoosterPack
+{
+ public static CardList getBoosterPack(int number)
+ {
+ CardList all = new CardList();
+ for(int i = 0; i < number; i++)
+ all.addAll(getBoosterPack().toArray());
+
+ return all;
+ }
+
+ public static CardList getBoosterPack()
+ {
+ CardList all = AllZone.CardFactory.getAllCards();
+ CardList pack = new CardList();
+
+ for(int i = 0; i < 10; i++)
+ pack.add(all.get(MyRandom.random.nextInt(all.size())));
+
+ for(int i = 0; i < 5; i++)
+ pack.add(AllZone.CardFactory.copyCard(pack.get(i)));
+
+ return pack;
+ }//getBoosterPack()
+}
\ No newline at end of file
diff --git a/src/ButtonUtil.java b/src/ButtonUtil.java
new file mode 100644
index 00000000000..1debb07c8bf
--- /dev/null
+++ b/src/ButtonUtil.java
@@ -0,0 +1,34 @@
+public class ButtonUtil
+{
+ public static void reset()
+ {
+ getOK().setText("OK");
+ getCancel().setText("Cancel");
+
+ getOK().setSelectable(false);
+ getCancel().setSelectable(false);
+ }
+ public static void enableOnlyOK()
+ {
+ getOK().setSelectable(true);
+ getCancel().setSelectable(false);
+ }
+ public static void enableOnlyCancel()
+ {
+ getOK().setSelectable(false);
+ getCancel().setSelectable(true);
+ }
+ public static void disableAll()
+ {
+ getOK().setSelectable(false);
+ getCancel().setSelectable(false);
+ }
+ public static void enableAll()
+ {
+ getOK().setSelectable(true);
+ getCancel().setSelectable(true);
+ }
+
+ private static MyButton getOK() {return AllZone.Display.getButtonOK();}
+ private static MyButton getCancel() {return AllZone.Display.getButtonCancel();}
+}
diff --git a/src/Card.java b/src/Card.java
new file mode 100644
index 00000000000..c20bc00f7b8
--- /dev/null
+++ b/src/Card.java
@@ -0,0 +1,855 @@
+import java.util.*;
+
+enum Counters {
+ AGE, BLAZE, CHARGE, DIVINITY, FADE, HOOFPRINT, ICE, LOYALTY, M1M1, MANA, P0M1, P1P1, QUEST, SPORE
+}
+
+public class Card extends MyObservable
+{
+ private static int nextUniqueNumber;
+ private int uniqueNumber = nextUniqueNumber++;
+
+
+ //private Collection keyword = new TreeSet();
+ //private ArrayList keyword = new ArrayList();
+ private ArrayList intrinsicKeyword = new ArrayList();
+ private ArrayList extrinsicKeyword = new ArrayList();
+ private ArrayList prevIntrinsicKeyword = new ArrayList();
+ private ArrayList attached = new ArrayList();
+ private ArrayList equippedBy = new ArrayList(); //which equipment cards are equipping this card?
+ //equipping size will always be 0 or 1
+ private ArrayList equipping = new ArrayList(); //if this card is of the type equipment, what card is it currently equipping?
+ private ArrayList enchantedBy = new ArrayList(); //which auras enchanted this card?
+ //enchanting size will always be 0 or 1
+ private ArrayList enchanting = new ArrayList(); //if this card is an Aura, what card is it enchanting?
+ private ArrayList type = new ArrayList();
+ private ArrayList prevType = new ArrayList();
+ private ArrayList spellAbility = new ArrayList();
+ private ArrayList manaAbility = new ArrayList();
+
+ private HashMap receivedDamageFromThisTurn = new HashMap();
+
+ private boolean tapped;
+ private boolean sickness = true;//summoning sickness
+ private boolean token = false;
+ private boolean creatureAttackedThisTurn = false;
+ private boolean creatureBlockedThisTurn = false;
+ private boolean creatureGotBlockedThisTurn = false;
+ private boolean dealtCombatDmgToOppThisTurn = false;
+ private boolean dealtDmgToOppThisTurn = false;
+ private boolean exaltedBonus = false;
+ private boolean faceDown = false;
+ private boolean echoPaid = false;
+ private boolean sacrificeAtEOT = false;
+
+ private boolean firstStrike = false;
+ private boolean doubleStrike = false;
+
+ private boolean flashback = false;
+
+ private int exaltedMagnitude = 0;
+
+ private int baseAttack;
+ private int baseDefense;
+
+ private int damage;
+ private int assignedDamage;
+ private int nShield;
+ private int turnInZone;
+
+ private int tempAttackBoost = 0;
+ private int tempDefenseBoost = 0;
+
+ private int semiPermanentAttackBoost = 0;
+ private int semiPermanentDefenseBoost = 0;
+
+ private int otherAttackBoost = 0;
+ private int otherDefenseBoost = 0;
+
+ private int randomPicture = 0;
+
+ private int X = 0;
+
+ private String owner = "";
+ private String controller = "";
+ private String name = "";
+ private String imageName = "";
+ private String rarity = "";
+ private String text = "";
+ private String manaCost = "";
+ private String chosenType = "";
+
+ private ArrayList comesIntoPlayCommandList = new ArrayList();
+ private ArrayList destroyCommandList = new ArrayList();
+ private ArrayList leavesPlayCommandList = new ArrayList();
+ private ArrayList turnFaceUpCommandList = new ArrayList();
+ private ArrayList equipCommandList = new ArrayList();
+ private ArrayList unEquipCommandList = new ArrayList();
+ private ArrayList enchantCommandList = new ArrayList();
+ private ArrayList unEnchantCommandList = new ArrayList();
+ private ArrayList replaceMoveToGraveyardCommandList = new ArrayList();
+ private ArrayList cycleCommandList = new ArrayList();
+
+ private Hashtable counters = new Hashtable();
+
+ //hacky code below, used to limit the number of times an ability
+ //can be used per turn like Vampire Bats
+ //should be put in SpellAbility, but it is put here for convienance
+ //this is make public just to make things easy
+ //this code presumes that each card only has one ability that can be
+ //used a limited number of times per turn
+ //CardFactory.SSP_canPlay(Card) uses these variables
+
+ private int abilityTurnUsed; //What turn did this card last use this ability?
+ private int abilityUsed; //How many times has this ability been used?
+
+ public void setAbilityTurnUsed(int i) {abilityTurnUsed = i; }
+ public int getAbilityTurnUsed() { return abilityTurnUsed; }
+
+ public void setAbilityUsed(int i) {abilityUsed = i;}
+ public int getAbilityUsed() { return abilityUsed; }
+
+ //****************TODO:Check
+ public void setX(int i){X = i;}
+ public int getX() { return X; }
+ //***************/
+
+ //used to see if an attacking creature with a triggering attack ability triggered this turn:
+ public void setCreatureAttackedThisTurn(boolean b) { creatureAttackedThisTurn = b; }
+ public boolean getCreatureAttackedThisTurn() { return creatureAttackedThisTurn; }
+
+ public void setCreatureBlockedThisTurn(boolean b) { creatureBlockedThisTurn = b; }
+ public boolean getCreatureBlockedThisTurn() { return creatureBlockedThisTurn; }
+
+ public void setCreatureGotBlockedThisTurn(boolean b) { creatureGotBlockedThisTurn = b; }
+ public boolean getCreatureGotBlockedThisTurn() { return creatureGotBlockedThisTurn; }
+
+ public void setDealtCombatDmgToOppThisTurn(boolean b) { dealtCombatDmgToOppThisTurn = b; }
+ public boolean getDealtCombatDmgToOppThisTurn() { return dealtCombatDmgToOppThisTurn; }
+
+ public void setDealtDmgToOppThisTurn(boolean b) { dealtDmgToOppThisTurn = b;}
+ public boolean getDealtDmgToOppThisTurn() { return dealtDmgToOppThisTurn; }
+
+ public void addReceivedDamageFromThisTurn(Card c, int damage) { receivedDamageFromThisTurn.put(c, damage);}
+ public void setReceivedDamageFromThisTurn(HashMap receivedDamageFromThisTurn) {
+ this.receivedDamageFromThisTurn = receivedDamageFromThisTurn;
+ }
+ public HashMap getReceivedDamageFromThisTurn() {
+ return receivedDamageFromThisTurn;
+ }
+
+ public void resetReceivedDamageFromThisTurn() {
+ receivedDamageFromThisTurn.clear();
+ }
+
+
+ public boolean getSacrificeAtEOT()
+ {
+ return sacrificeAtEOT;
+ }
+
+ public void setSacrificeAtEOT(boolean sacrificeAtEOT)
+ {
+ this.sacrificeAtEOT = sacrificeAtEOT;
+ }
+
+ public boolean hasFirstStrike() {
+ return firstStrike || getKeyword().contains("First Strike");
+ }
+
+ public void setFirstStrike(boolean firstStrike){
+ this.firstStrike = firstStrike;
+ }
+
+ public void setDoubleStrike(boolean doubleStrike){
+ this.doubleStrike = doubleStrike;
+ }
+
+ public boolean hasDoubleStrike() {
+ return doubleStrike || getKeyword().contains("Double Strike");
+ }
+
+ public void addCounter(Counters counterName, int n)
+ {
+ if(counters.containsKey(counterName))
+ {
+ Integer aux = counters.get(counterName) + n;
+ counters.put(counterName,aux);
+ }
+ else
+ {
+ counters.put(counterName, new Integer(n));
+ }
+ this.updateObservers();
+ }
+
+ public void subtractCounter(Counters counterName, int n)
+ {
+ if(counters.containsKey(counterName))
+ {
+ Integer aux = counters.get(counterName) - n;
+ counters.put(counterName,aux);
+ this.updateObservers();
+ }
+ }
+ public int getCounters(Counters counterName)
+ {
+ if(counters.containsKey(counterName))
+ {
+ return counters.get(counterName);
+ }
+ else
+ return 0;
+ }
+
+ public void setCounter(Counters counterName, int n) {
+ counters.put(counterName,new Integer(n));
+ this.updateObservers();
+ }
+
+ public int sumAllCounters()
+ {
+ Object[] values = counters.values().toArray();
+ int count = 0;
+ int num = 0;
+ for(int i=0;i keyword = getKeyword();
+ for(int i = 0; i < keyword.size(); i++)
+ {
+ if(i != 0)
+ s += ", ";
+ s += keyword.get(i).toString();
+ }
+
+ s += "\r\n" +text +"\r\n";
+
+ SpellAbility[] sa = getSpellAbility();
+ for(int i = 0; i < sa.length; i++)
+ {
+ //presumes the first SpellAbility added to this card, is the "main" spell
+ //skip the first SpellAbility for creatures, since it says "Summon this creature"
+ //looks bad on the Gui card detail
+ if(isPermanent() && i != 0 && !(manaAbility.contains(sa[i]) && ((Ability_Mana) sa[i]).isBasic()))//prevent mana ability duplication
+ s += sa[i].toString() +"\r\n";
+ }
+
+ return s.trim();
+ }//getText()
+
+ /* private ArrayList addLandAbilities ()
+ {
+ ArrayList res = new ArrayList(manaAbility);
+ if (!getType().contains("Land")) return res;
+ ArrayList types = getType();
+ for(int i = 0; i < basics.length; i++)
+ if(types.contains(basics[i]) && !res.contains("tap: add "+ ManaPool.colors.charAt(i)))
+ res.add(new Ability_Mana(this, "tap: add "+ ManaPool.colors.charAt(i)){});
+ return res;
+ }*/
+ /*ArrayList addExtrinsicAbilities(ArrayList have)
+ {
+ try{
+ if (AllZone.getZone(this).is(Constant.Zone.Play))
+ {
+ for (Card c : AllZone.getZone(Constant.Zone.Play, getController()).getCards())
+ if (c.getName().equals("Joiner Adept") && getType().contains("Land") || c.getName().equals("Gemhide Sliver") && getType().contains("Sliver"))
+ for (char ch : ManaPool.colors.toCharArray())
+ have.add(new Ability_Mana(this, "tap: add " + ch){});
+ }}
+ catch(NullPointerException ex){}//TODO: fix this to something more memory-efficient than catching 2000 NullPointer Exceptions every time you open deck editor
+ return have;
+ }*/
+ public ArrayList getManaAbility(){return new ArrayList(manaAbility);}
+ public ArrayList getBasicMana()
+ {
+ ArrayList res = new ArrayList();
+ for(Ability_Mana am : getManaAbility())
+ if(am.isBasic() && !res.contains(am))
+ res.add(am);
+ return res;
+ }
+
+ public void clearSpellAbility() {spellAbility.clear(); manaAbility.clear();}
+ public void clearSpellKeepManaAbility() { spellAbility.clear(); }
+ public void clearManaAbility() { manaAbility.clear(); }
+ public void addSpellAbility(SpellAbility a) {a.setSourceCard(this); if (a instanceof Ability_Mana) manaAbility.add((Ability_Mana) a); else spellAbility.add(a);}
+
+ public void removeSpellAbility(SpellAbility a)
+ {
+ if(a instanceof Ability_Mana)
+ //if (a.isExtrinsic()) //never remove intrinsic mana abilities, is this the way to go??
+ manaAbility.remove((Ability_Mana)a);
+ else
+ spellAbility.remove(a);
+
+ }
+
+
+
+ public void removeAllExtrinsicManaAbilities()
+ {
+ //temp ArrayList, otherwise ConcurrentModificationExceptions occur:
+ ArrayList saList = new ArrayList();
+
+ for (SpellAbility var : manaAbility)
+ {
+ if(var.isExtrinsic())
+ saList.add(var);
+ }
+ for (SpellAbility sa : saList)
+ {
+ removeSpellAbility(sa);
+ }
+ }
+
+ public ArrayList getIntrinsicManaAbilitiesDescriptions()
+ {
+ ArrayList list = new ArrayList();
+ for (SpellAbility var : manaAbility)
+ {
+ if (var.isIntrinsic())
+ list.add(var.toString());
+ }
+ return list;
+ }
+
+ public SpellAbility[] getSpellAbility()
+ {
+ ArrayList res = new ArrayList(spellAbility);
+ res.addAll(getManaAbility());
+ SpellAbility[] s = new SpellAbility[res.size()];
+ res.toArray(s);
+ return s;
+ }
+
+ //shield = regeneration
+ public void setShield(int n) {nShield = n;}
+ public int getShield() {return nShield;}
+ public void addShield() {nShield++;}
+ public void subtractShield() {nShield--;}
+ public void resetShield() {nShield = 0;}
+
+ //is this "Card" supposed to be a token?
+ public void setToken(boolean b) {token = b;}
+ public boolean isToken() {return token;}
+
+ public void setExaltedBonus(boolean b) {exaltedBonus = b;}
+ public boolean hasExaltedBonus() {return exaltedBonus;}
+ public void setExaltedMagnitude(int i) {exaltedMagnitude = i;}
+ public int getExaltedMagnitude() { return exaltedMagnitude; }
+
+ public void setIsFaceDown(boolean b) { faceDown = b;}
+ public boolean isFaceDown() { return faceDown; }
+
+ public void addComesIntoPlayCommand(Command c) {comesIntoPlayCommandList.add(c);}
+ public void removeComesIntoPlayCommand(Command c) { comesIntoPlayCommandList.remove(c);}
+ public void comesIntoPlay() {
+ for (Command var : comesIntoPlayCommandList)
+ var.execute();
+ }
+
+ public void addTurnFaceUpCommand(Command c) { turnFaceUpCommandList.add(c); }
+ public void removeTurnFaceUpCommand(Command c) { turnFaceUpCommandList.remove(c); }
+ public void turnFaceUp() {
+ for (Command var : turnFaceUpCommandList)
+ var.execute();
+ }
+
+ public void addDestroyCommand(Command c) {destroyCommandList.add(c);}
+ public void removeDestroyCommand(Command c) {destroyCommandList.remove(c); }
+ public void destroy()
+ {
+ for (Command var : destroyCommandList)
+ var.execute();
+ }
+
+ public void addLeavesPlayCommand(Command c) { leavesPlayCommandList.add(c);}
+ public void removeLeavesPlayCommand(Command c) { leavesPlayCommandList.remove(c); }
+ public void leavesPlay() {
+ for (Command var : leavesPlayCommandList)
+ var.execute();
+ }
+
+ public void addEquipCommand(Command c) {equipCommandList.add(c); }
+ public void removeEquipCommand(Command c) { equipCommandList.remove(c); }
+ public void equip() {
+ for (Command var : equipCommandList)
+ var.execute();
+ }
+
+ public void addUnEquipCommand(Command c) {unEquipCommandList.add(c); }
+ public void removeUnEquipCommand(Command c) { unEquipCommandList.remove(c); }
+ public void unEquip() {
+ for (Command var : unEquipCommandList)
+ var.execute();
+ }
+
+ public void addEnchantCommand(Command c) {enchantCommandList.add(c); }
+ public void removeEnchantCommand(Command c) {enchantCommandList.add(c); }
+ public void enchant() {
+ for (Command var : enchantCommandList)
+ var.execute();
+ }
+
+ public void addUnEnchantCommand(Command c) { unEnchantCommandList.add(c); }
+ public void unEnchant() {
+ for (Command var : unEnchantCommandList)
+ var.execute();
+ }
+
+ public ArrayList getReplaceMoveToGraveyard() { return replaceMoveToGraveyardCommandList; }
+ public void addReplaceMoveToGraveyardCommand(Command c) { replaceMoveToGraveyardCommandList.add(c);}
+ public void replaceMoveToGraveyard()
+ {
+ for (Command var : replaceMoveToGraveyardCommandList)
+ var.execute();
+ }
+
+ public void addCycleCommand(Command c) { cycleCommandList.add(c); }
+ public void cycle() {
+ for (Command var : cycleCommandList)
+ var.execute();
+ }
+
+ public void setSickness(boolean b) {sickness = b;}
+ public boolean hasSickness()
+ {
+ if(getKeyword().contains("Haste"))
+ return false;
+
+ return sickness;
+ }
+
+ public void setRarity(String s) {rarity = s;}
+ public String getRarity() {return rarity;}
+
+ public void addDamage(int n)
+ {
+ if (this.getName().equals("Cho-Manno, Revolutionary"))
+ n = 0;
+ setDamage(getDamage() + n);
+ }
+ public void setDamage(int n)
+ {
+ if (this.getName().equals("Cho-Manno, Revolutionary"))
+ n = 0;
+ damage = n;
+ }
+ public int getDamage() {return damage;}
+
+ public void setAssignedDamage(int n) {assignedDamage = n;}
+ public int getAssignedDamage() {return assignedDamage;}
+
+ public void setImageName(String s) { imageName = s; }
+ public String getImageName()
+ {
+ if (!imageName.equals(""))
+ return imageName;
+ return name;
+ }
+
+ public String getName() {return name;}
+ public String getOwner() {return owner;}
+ public String getController(){return controller;}
+
+ public void setName(String s) {name = s; this.updateObservers();}
+ public void setOwner(String player) {owner = player;}
+ public void setController(String player){controller = player; this.updateObservers();}
+
+ public ArrayList getEquippedBy()
+ {
+ return equippedBy;
+ }
+
+ public void setEquippedBy(ArrayList list)
+ {
+ equippedBy = list;
+ }
+
+ public ArrayList getEquipping()
+ {
+ return equipping;
+ }
+
+ public void setEquipping(ArrayList list)
+ {
+ equipping = list;
+ }
+
+ public boolean isEquipped()
+ {
+ Card c[] = new Card[equippedBy.size()];
+ equippedBy.toArray(c);
+ return c.length != 0;
+ }
+
+ public boolean isEquipping()
+ {
+ Card c[] = new Card[equipping.size()];
+ equippedBy.toArray();
+ return c.length != 0;
+ }
+
+ public void addEquippedBy(Card c)
+ {
+ equippedBy.add(c);
+ this.updateObservers();
+ }
+
+ public void removeEquippedBy(Card c)
+ {
+ equippedBy.remove(c);
+ this.updateObservers();
+ }
+
+ public void addEquipping(Card c)
+ {
+ equipping.add(c);
+ this.updateObservers();
+ }
+
+ public void removeEquipping(Card c)
+ {
+ equipping.remove(c);
+ this.updateObservers();
+ }
+
+ public void equipCard(Card c) //equipment.equipCard(cardToBeEquipped);
+ {
+ equipping.add(c);
+ c.addEquippedBy(this);
+ this.equip();
+ }
+
+ public void unEquipCard(Card c) //equipment.unEquipCard(equippedCard);
+ {
+ this.unEquip();
+ equipping.remove(c);
+ c.removeEquippedBy(this);
+ }
+
+ public void unEquipAllCards()
+ {
+ for (int i=0; i getEnchantedBy()
+ {
+ return enchantedBy;
+ }
+
+ public void setEnchantedBy(ArrayList list)
+ {
+ enchantedBy = list;
+ }
+
+ public ArrayList getEnchanting()
+ {
+ return enchanting;
+ }
+
+ public void setEnchanting(ArrayList list)
+ {
+ enchanting = list;
+ }
+
+ public boolean isEnchanted()
+ {
+ Card c[] = new Card[enchantedBy.size()];
+ enchantedBy.toArray(c);
+ return c.length != 0;
+ }
+
+ public boolean isEnchanting()
+ {
+ Card c[] = new Card[enchanting.size()];
+ enchantedBy.toArray();
+ return c.length != 0;
+ }
+
+ public void addEnchantedBy(Card c)
+ {
+ enchantedBy.add(c);
+ this.updateObservers();
+ }
+
+ public void removeEnchantedBy(Card c)
+ {
+ enchantedBy.remove(c);
+ this.updateObservers();
+ }
+
+ public void addEnchanting(Card c)
+ {
+ enchanting.add(c);
+ this.updateObservers();
+ }
+
+ public void removeEnchanting(Card c)
+ {
+ enchanting.remove(c);
+ this.updateObservers();
+ }
+
+ public void enchantCard(Card c)
+ {
+ enchanting.add(c);
+ c.addEnchantedBy(this);
+ this.enchant();
+ }
+
+ public void unEnchantCard(Card c)
+ {
+ this.unEnchant();
+ enchanting.remove(c);
+ c.removeEnchantedBy(this);
+ }
+
+ public void unEnchantAllCards()
+ {
+ for (int i=0; i a) {type = new ArrayList(a);}
+ public void addType(String a) {type.add(a); this.updateObservers();}
+ public void removeType(String a) {type.remove(a); this.updateObservers();}
+ public ArrayList getType() {return new ArrayList(type);}
+
+ public void setPrevType(ArrayList a) {prevType = new ArrayList(a);}
+ public void addPrevType(String a) {prevType.add(a);}
+ public void removePrevType(String a) {prevType.remove(a);}
+ public ArrayList getPrevType() {return new ArrayList(prevType);}
+
+ //values that are printed on card
+ public int getBaseAttack() {return baseAttack;}
+ public int getBaseDefense() {return baseDefense;}
+
+ //values that are printed on card
+ public void setBaseAttack(int n) {baseAttack = n; this.updateObservers();}
+ public void setBaseDefense(int n) {baseDefense = n; this.updateObservers();}
+
+ public int getNetAttack()
+ {
+ int total = getBaseAttack();
+ total += getTempAttackBoost() + getSemiPermanentAttackBoost() + getOtherAttackBoost() + getCounters(Counters.P1P1)
+ - getCounters(Counters.M1M1);
+ return total;
+ }
+ public int getNetDefense()
+ {
+ int total = getBaseDefense();
+ total += getTempDefenseBoost() + getSemiPermanentDefenseBoost() + getOtherDefenseBoost() + getCounters(Counters.P1P1)
+ - getCounters(Counters.M1M1) - getCounters(Counters.P0M1);
+ return total;
+ }
+
+ public void setRandomPicture(int n) { randomPicture = n; }
+ public int getRandomPicture() { return randomPicture; }
+
+ //public int getAttack(){return attack;}
+
+ //for cards like Giant Growth, etc.
+ public int getTempAttackBoost() {return tempAttackBoost;}
+ public int getTempDefenseBoost() {return tempDefenseBoost;}
+
+ public void addTempAttackBoost(int n) {tempAttackBoost += n; this.updateObservers();}
+ public void addTempDefenseBoost(int n) {tempDefenseBoost += n; this.updateObservers();}
+ public void setTempAttackBoost(int n) {tempAttackBoost = n; this.updateObservers();}
+ public void setTempDefenseBoost(int n) {tempDefenseBoost = n; this.updateObservers();}
+
+ //for cards like Glorious Anthem, etc.
+ public int getSemiPermanentAttackBoost() {return semiPermanentAttackBoost;}
+ public int getSemiPermanentDefenseBoost() {return semiPermanentDefenseBoost;}
+
+ public void addSemiPermanentAttackBoost(int n) { semiPermanentAttackBoost += n;}
+ public void addSemiPermanentDefenseBoost(int n){ semiPermanentDefenseBoost += n;}
+ public void setSemiPermanentAttackBoost(int n){ semiPermanentAttackBoost = n;}
+ public void setSemiPermanentDefenseBoost(int n) { semiPermanentDefenseBoost = n;}
+
+ //for cards like Relentless Rats, Master of Etherium, etc.
+ public int getOtherAttackBoost() {return otherAttackBoost;}
+ public int getOtherDefenseBoost() {return otherDefenseBoost;}
+
+ public void addOtherAttackBoost(int n) { otherAttackBoost += n;}
+ public void addOtherDefenseBoost(int n){ otherDefenseBoost += n;}
+ public void setOtherAttackBoost(int n){ otherAttackBoost = n;}
+ public void setOtherDefenseBoost(int n) { otherDefenseBoost = n;}
+
+ //public void setAttack(int n) {attack = n; this.updateObservers();}
+ //public void setDefense(int n) {defense = n; this.updateObservers();}
+
+ public boolean isUntapped() {return ! tapped;}
+ public boolean isTapped() {return tapped;}
+ public void setTapped(boolean b) {tapped = b; updateObservers();}
+ public void tap() {setTapped(true);}
+ public void untap() {setTapped(false);}
+
+ //keywords are like flying, fear, first strike, etc...
+ public ArrayList getKeyword()
+ {
+ ArrayList a1 = new ArrayList(getIntrinsicKeyword());
+ ArrayList a2 = new ArrayList(getExtrinsicKeyword());
+ a1.addAll(a2);
+
+ for(Ability_Mana sa : getManaAbility())
+ if(sa.isBasic())
+ a1.add(((Ability_Mana)sa).orig);
+
+ return a1;
+ }
+ //public void setKeyword(ArrayList a) {keyword = new ArrayList(a); this.updateObservers();}
+ //public void addKeyword(String s) {keyword.add(s); this.updateObservers();}
+ //public void removeKeyword(String s) {keyword.remove(s); this.updateObservers();}
+ //public int getKeywordSize() {return keyword.size();}
+
+ public String[] basics = {"Plains", "Island", "Swamp", "Mountain", "Forest"};
+
+ public ArrayList getIntrinsicKeyword() {return new ArrayList(intrinsicKeyword);}
+ public void setIntrinsicKeyword(ArrayList a) {intrinsicKeyword = new ArrayList(a); this.updateObservers();}
+ public void addIntrinsicKeyword(String s) {/*if (s.startsWith("tap: add")) manaAbility.add(new Ability_Mana(this, s){}); else*/ intrinsicKeyword.add(s);}
+ public void removeIntrinsicKeyword(String s) { intrinsicKeyword.remove(s); this.updateObservers();}
+ public int getIntrinsicKeywordSize() {return intrinsicKeyword.size(); }
+
+ public ArrayList getExtrinsicKeyword() {return new ArrayList(extrinsicKeyword);}
+ public void setExtrinsicKeyword(ArrayList a) {extrinsicKeyword = new ArrayList(a); this.updateObservers();}
+ public void addExtrinsicKeyword(String s) {
+ if(!getKeyword().contains(s)){
+ if (s.startsWith("tap: add")) manaAbility.add(new Ability_Mana(this, s)
+ {
+ private static final long serialVersionUID = 221124403788942412L;
+ });
+ else extrinsicKeyword.add(s);
+ }
+ }
+ public void removeExtrinsicKeyword(String s) {extrinsicKeyword.remove(s); this.updateObservers();}
+ public int getExtrinsicKeywordSize() {return extrinsicKeyword.size(); }
+
+ public ArrayList getPrevIntrinsicKeyword() { return new ArrayList(prevIntrinsicKeyword);}
+ public void setPrevIntrinsicKeyword(ArrayList a) { prevIntrinsicKeyword = new ArrayList(a); this.updateObservers();}
+ public void addPrevIntrinsicKeyword(String s) { prevIntrinsicKeyword.add(s);}
+ public void removePrevIntrinsicKeyword(String s) { prevIntrinsicKeyword.remove(s); this.updateObservers();}
+ public int getPrevIntrinsicKeywordSize() {return prevIntrinsicKeyword.size();}
+
+
+ public boolean isPermanent() {return !(isInstant() || isSorcery());}
+
+ public boolean isCreature() {return type.contains("Creature");}
+ public boolean isBasicLand() {return type.contains("Basic");}
+ public boolean isLand() {return type.contains("Land");}
+ public boolean isSorcery() {return type.contains("Sorcery");}
+ public boolean isInstant() {return type.contains("Instant") /*|| getKeyword().contains("Flash")*/;}
+ public boolean isArtifact() {return type.contains("Artifact");}
+
+ public boolean isEquipment() {return type.contains("Equipment");}
+ public boolean isPlaneswalker() {return type.contains("Planeswalker");}
+ public boolean isTribal() {return type.contains("Tribal");}
+
+ //global and local enchantments
+ public boolean isEnchantment() {return typeContains("Enchantment"); }
+ public boolean isLocalEnchantment() {return typeContains("Aura"); }
+ public boolean isAura() {return typeContains("Aura"); }
+ public boolean isGlobalEnchantment() {return typeContains("Enchantment") && (! isLocalEnchantment());}
+
+ private boolean typeContains(String s)
+ {
+ Iterator> it = this.getType().iterator();
+ while(it.hasNext())
+ if(it.next().toString().startsWith(s))
+ return true;
+
+ return false;
+ }
+
+ public void setUniqueNumber(int n) {uniqueNumber = n; this.updateObservers();}
+ public int getUniqueNumber() {return uniqueNumber;}
+
+ public boolean equals(Object o)
+ {
+ if(o instanceof Card)
+ {
+ Card c = (Card)o;
+ int a = getUniqueNumber();
+ int b = c.getUniqueNumber();
+ return (a == b);
+ }
+ return false;
+ }
+ public int hashCode()
+ {
+ return getUniqueNumber();
+ }
+ public String toString()
+ {
+ return this.getName() +" (" +this.getUniqueNumber() +")";
+ }
+ public boolean hasFlashback() {
+ return flashback;
+ }
+ public void setFlashback(boolean b)
+ {
+ flashback = b;
+ }
+}
diff --git a/src/CardDetailUtil.java b/src/CardDetailUtil.java
new file mode 100644
index 00000000000..10e1eb87086
--- /dev/null
+++ b/src/CardDetailUtil.java
@@ -0,0 +1,48 @@
+import javax.swing.*;
+
+interface CardDetail
+{
+ public void updateCardDetail(Card c);
+}
+
+public class CardDetailUtil
+{
+ public static void updateCardDetail(Card card, JTextArea area, JPanel cardDetailPanel, JPanel picturePanel, JLabel label[])
+ {
+ if(card == null)
+ return;
+ //System.out.println("label length: " + label.length);
+ for(int i = 0; i < label.length; i++)
+ label[i].setText("");
+
+ area.setText("");
+
+ if(card.isLand())
+ label[0].setText(card.getName());
+ else
+ label[0].setText(card.getName() +" - " +card.getManaCost());
+
+ label[1].setText(GuiDisplayUtil.formatCardType(card));
+
+ if(card.isCreature())
+ {
+ String stats = "" +card.getNetAttack() +" / " +card.getNetDefense();
+ label[2].setText(stats);
+ }
+
+ if(card.isCreature())
+ label[3].setText("Damage: " +card.getDamage() +" Assigned Damage: " +card.getAssignedDamage());
+
+ String uniqueID = card.getUniqueNumber() +" ";
+ label[4].setText("Card ID " +uniqueID);
+
+ area.setText(card.getText());
+
+ cardDetailPanel.setBorder(GuiDisplayUtil.getBorder(card));
+
+ //picture
+ picturePanel.removeAll();
+ picturePanel.add(GuiDisplayUtil.getPicture(card));
+ picturePanel.revalidate();
+ }//updateCardDetail
+}
\ No newline at end of file
diff --git a/src/CardFactory.java b/src/CardFactory.java
new file mode 100644
index 00000000000..6f881d07a43
--- /dev/null
+++ b/src/CardFactory.java
@@ -0,0 +1,41235 @@
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+
+import forge.error.ErrorViewer;
+import forge.properties.ForgeProps;
+import forge.properties.NewConstants;
+
+
+public class CardFactory implements NewConstants {
+ // String cardname is the key, Card is the value
+ private Map map = new HashMap();
+ @SuppressWarnings("unused")
+ // random
+ private Random random = new Random();
+ private CardList allCards = new CardList();
+
+ private HashSet removedCardList;
+ private Card blankCard = new Card(); //new code
+
+ public CardFactory(String filename) {
+ this(new File(filename));
+ }
+
+ public CardFactory(File file) {
+ SpellAbility spell = new SpellAbility(SpellAbility.Spell, blankCard) {
+ //neither computer nor human play can play this card
+ @Override
+ public boolean canPlay() {
+ return false;
+ }
+
+ @Override
+ public void resolve() {}
+ };
+ blankCard.addSpellAbility(spell);
+ spell.setManaCost("1");
+ blankCard.setName("Removed Card");
+
+ //owner and controller will be wrong sometimes
+ //but I don't think it will matter
+ //theoretically blankCard will go to the wrong graveyard
+ blankCard.setOwner(Constant.Player.Human);
+ blankCard.setController(Constant.Player.Human);
+
+ removedCardList = new HashSet(FileUtil.readFile(ForgeProps.getFile(REMOVED)));
+
+
+ try {
+ readCards(file);
+
+ // initialize CardList allCards
+ Iterator it = map.keySet().iterator();
+ Card c;
+ while(it.hasNext()) {
+ c = getCard(it.next().toString(), Constant.Player.Human);
+ allCards.add(c);
+ //System.out.println("cardName: " + c.getName());
+
+ }
+ } catch(Exception ex) {
+ ErrorViewer.showError(ex);
+ }
+ }// constructor
+
+ public CardList getAllCards() {
+ return new CardList(allCards.toArray());
+ }// getAllCards()
+
+ private void readCards(File file) {
+ map.clear();
+
+ ReadCard read = new ReadCard(ForgeProps.getFile(CARDS));
+ try {
+ read.run();
+ // javax.swing.SwingUtilities.invokeAndWait(read);
+ } catch(Exception ex) {
+ ErrorViewer.showError(ex);
+ throw new RuntimeException("CardFactory : readCards() thread error - " + ex.getMessage());
+ }
+
+ ArrayList simpleList = read.getCards();
+ Card s;
+ Iterator it = simpleList.iterator();
+ while(it.hasNext()) {
+ s = it.next();
+ map.put(s.getName(), s);
+ //System.out.println("cardName: " + s.getName());
+ }
+ }// readCard()
+
+ final public Card copyCard(Card in) {
+ Card out = getCard(in.getName(), in.getOwner());
+ out.setUniqueNumber(in.getUniqueNumber());
+ return out;
+ }
+
+ /*
+ final public Card getCard(String cardName, String owner) {
+ cardName = AllZone.NameChanger.getOriginalName(cardName);
+ return getCard2(cardName, owner);
+ }
+ */
+
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //this is the new getCard() method, you have to remove the old getCard()
+ final public Card getCard(String cardName, String owner) {
+ if(removedCardList.contains(cardName) || cardName.equals(blankCard.getName())) return blankCard;
+
+ return getCard2(cardName, owner);
+ }
+
+ //self-targeted power and/or toughness pumping abilities
+ //-1 means "PTPump" is not found
+ //any other int means that "PTPump" was found in the Card keyword
+ private final int shouldPTPumpCard(Card c)
+ {
+ ArrayList a = c.getKeyword();
+ for(int i = 0; i < a.size(); i++)
+ if(a.get(i).toString().startsWith("PTPump"))
+ return i;
+
+ return -1;
+ }
+ //same thing, for "KPump" - self-targeted keyword adding abilities
+ private final int shouldKPumpCard(Card c)
+ {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if(a.get(i).toString().startsWith("KPump"))
+ return i;
+
+ return -1;
+ }
+ //same thing, for "PTKPump" - self-targeted power and/or toughness pumping
+ //plus keyword adding abilities
+ private final int shouldPTKPumpCard(Card c)
+ {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if(a.get(i).toString().startsWith("PTKPump"))
+ return i;
+
+ return -1;
+ }
+
+ //"TgtKPump" - targeted keyword adding abilities
+ private final int shouldTgtKPumpCard(Card c)
+ {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if(a.get(i).toString().startsWith("TgtKPump"))
+ return i;
+
+ return -1;
+ }
+
+ // Check for self-regenerate ability
+ private final int shouldRegenerateMe(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("RegenerateMe"))
+ return i;
+
+ return -1;
+ }
+
+ // Check for Cycling ability
+ private final int shouldCycle(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Cycling"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSporeSaproling(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Remove three spore counters"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSpDamageTgt(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (a.get(i).toString().startsWith("spDamageTgt"))
+ return i;
+ }
+ return -1;
+ }
+
+ private final int shouldSpDamageCP(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (a.get(i).toString().startsWith("spDamageCP"))
+ return i;
+ }
+ return -1;
+ }
+
+ private final int shouldSpDamageP(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (a.get(i).toString().startsWith("spDamageP"))
+ return i;
+ }
+ return -1;
+ }
+
+ private final int shouldRebelSearch(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("SearchRebel"))
+ return i;
+ return -1;
+ }
+
+ private final int shouldMercSearch(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("SearchMerc"))
+ return i;
+ return -1;
+ }
+
+ private final int shouldMorph(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Morph"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldDevour(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Devour"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSpellbomb(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("1, Sacrifice"))//
+ if(a.get(i).equals("1, Sacrifice "+c.getName()+": Draw a card."))
+ return i;
+ return -1;
+ }
+
+ private final int shouldModular(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (a.get(i).toString().startsWith("Modular"))
+ return i;
+ }
+ return -1;
+ }
+
+ private final int shouldUntap(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Untap"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldFlashback(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("Flashback"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldAbDamageCP(Card c) {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (a.get(i).toString().startsWith("abDamageCP"))
+ return i;
+ }
+ return -1;
+ }
+
+ private final int shouldAbTgtPTPumpCard(Card c)
+ {
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("abTgtPTPump"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSpPumpTgt(Card c){
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("spPumpTgt"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSpDestroyTgt(Card c){
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("spDestroyTgt:"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldSpDrawCards(Card c){
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("spDrawCards"))
+ return i;
+
+ return -1;
+ }
+
+ // spLoseLifeGainLife
+ private final int shouldSpLoseLifeGainLife(Card c){
+ ArrayList a = c.getKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().startsWith("spLoseLifeGainLife"))
+ return i;
+
+ return -1;
+ }
+
+ private final int shouldManaAbility(Card c){
+ ArrayList a = c.getIntrinsicKeyword();
+ for (int i = 0; i < a.size(); i++)
+ if (a.get(i).toString().contains(": add "))
+ return i;
+
+ return -1;
+ }
+
+
+ final private Card getCard2(final String cardName, final String owner)
+ {
+ //o should be Card object
+ Object o = map.get(cardName);
+ if(o == null)
+ throw new RuntimeException("CardFactory : getCard() invalid card name - " +cardName);
+
+ final Card card = copyStats(o);
+ card.setOwner(owner);
+ card.setController(owner);
+ //may have to change the spell
+ //this is so permanents like creatures and artifacts have a "default" spell
+ if(! card.isLand())
+ card.addSpellAbility(new Spell_Permanent(card));
+
+ //look for "Comes into play tapped." in the "no text" line
+ //of card.txt and add the appropriate code to make that happen
+ if(card.getKeyword().contains("Comes into play tapped."))
+ {
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 203335252453049234L;
+
+ public void execute()
+ {
+ card.tap();
+ }
+ });
+ }//if "Comes into play tapped."
+
+ //Creatures with simple, self-targeted mana-activated keyword adding abilities
+ //-1 means not found
+ while(shouldKPumpCard(card) != -1)
+ {
+ int n = shouldKPumpCard(card);
+ if(n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+
+ final String manaCost = k[0].substring(6);
+ final String keyword = k[1];
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -2904643243256352517L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.removeIntrinsicKeyword(keyword);
+ }
+ }
+ };
+
+ SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+ private static final long serialVersionUID = -630655617339584299L;
+
+ public boolean canPlayAI()
+ {
+ //in case if a lifelink pump, allow multiple pumps
+ if (CardFactoryUtil.AI_doesCreatureAttack(card) &&
+ !card.getKeyword().contains(keyword))
+ {
+ Random r = new Random();
+ if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
+ return true;
+ else
+ return false;
+ }
+ else
+ return false;
+ }
+ public boolean canPlay()
+ {
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword(keyword);
+
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+ String Desc = new String();
+ Desc = cardName + " gains " + keyword + " until end of turn.";
+
+ ability.setDescription(manaCost + " : " + Desc);
+ ability.setStackDescription(Desc);
+
+ card.addSpellAbility(ability);
+ }//if (should pump card)
+ }//while - card has more pump keywords - Blistering Dieflyn has two pump keywords
+
+
+ //Creatures with simple, self-targeted mana-activated power and/or toughness
+ //pumping abilities
+ //is the card "self pumper" like Furnace Whelp - this card gets +1/+1 until end of turn?
+ //-1 means not found
+ while(shouldPTPumpCard(card) != -1)
+ {
+ int n = shouldPTPumpCard(card);
+ if(n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ final int attack[] = new int[1];
+ final int defense[] = new int[1];
+
+ String k[] = parse.split(":");
+ String pt[] = k[1].split("/");
+
+ final String manaCost = k[0].substring(7);
+
+
+ Integer na = card.getNetAttack();
+ Integer nd = card.getNetDefense();
+
+ pt[0].replace("p", na.toString());
+ pt[0].replace("t", nd.toString());
+
+ pt[1].replace("p", na.toString());
+ pt[1].replace("t", nd.toString());
+
+ attack[0] = Integer.parseInt(pt[0].replace("+", ""));
+ defense[0] = Integer.parseInt(pt[1].replace("+", ""));
+
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -4518618729662470596L;
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addTempAttackBoost(-attack[0]);
+ card.addTempDefenseBoost(-defense[0]);
+ }
+ }
+ };
+
+ SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+ private static final long serialVersionUID = -5718931378326228534L;
+
+ public boolean canPlayAI()
+ {
+ if (card.getNetDefense() + defense[0] < 1) // no point if it would kill the creature outright
+ return false;
+ return CardFactoryUtil.AI_doesCreatureAttack(card);
+ }
+ public boolean canPlay()
+ {
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) &&
+ !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addTempAttackBoost(attack[0]);
+ card.addTempDefenseBoost(defense[0]);
+
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+ String Desc = new String();
+ Desc = cardName + " gets ";
+ if (attack[0] > 0)
+ Desc = Desc + "+" + attack[0];
+ else
+ Desc = Desc + attack[0];
+ Desc = Desc + "/";
+ if (defense[0] > 0)
+ Desc = Desc + "+" + defense[0];
+ else
+ Desc = Desc + defense[0];
+ Desc = Desc + " until end of turn.";
+
+ ability.setDescription(manaCost + " : " + Desc);
+ ability.setStackDescription(Desc);
+
+ card.addSpellAbility(ability);
+ }//if (should pump card)
+ }//while - card has more pump keywords - Blistering Dieflyn has two pump keywords
+
+ //Creatures with simple, self-targeted mana-activated power and/or toughness
+ //pumping plus keyword adding abilities
+ //is the card "self pumper" like Furnance Whelp - this card gets +1/+1 until end of turn?
+ //-1 means not found
+ while(shouldPTKPumpCard(card) != -1)
+ {
+ int n = shouldPTKPumpCard(card);
+ if(n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ final int attack[] = new int[1];
+ final int defense[] = new int[1];
+
+ String k[] = parse.split(":");
+ String ptk[] = k[1].split("/");
+
+ final String manaCost = k[0].substring(8);
+
+ attack[0] = Integer.parseInt(ptk[0].replace("+", ""));
+ defense[0] = Integer.parseInt(ptk[1].replace("+", ""));
+ final String keyword = ptk[2];
+
+
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -3554196069508466753L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.removeIntrinsicKeyword(keyword);
+ card.addTempAttackBoost(-attack[0]);
+ card.addTempDefenseBoost(-defense[0]);
+
+ }
+ }
+ };
+
+ SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+ private static final long serialVersionUID = 4196412133232530875L;
+
+ public boolean canPlayAI()
+ {
+ if (card.getNetDefense() + defense[0] < 1) // no point if it would kill the creature outright
+ return false;
+
+ if (card.getKeyword().contains(keyword))
+ return false;
+
+ return CardFactoryUtil.AI_doesCreatureAttack(card);
+ }
+ public boolean canPlay()
+ {
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) &&
+ !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword(keyword);
+ card.addTempAttackBoost(attack[0]);
+ card.addTempDefenseBoost(defense[0]);
+
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+
+ String Desc = new String();
+ Desc = cardName + " gets ";
+ if (attack[0] > 0)
+ Desc = Desc + "+" + attack[0];
+ else
+ Desc = Desc + attack[0];
+ Desc = Desc + "/";
+ if (defense[0] > 0)
+ Desc = Desc + "+" + defense[0];
+ else
+ Desc = Desc + defense[0];
+ Desc = Desc + " and gains " + keyword + " until end of turn.";
+
+ ability.setDescription(manaCost + " : " + Desc);
+ ability.setStackDescription(Desc);
+
+ card.addSpellAbility(ability);
+ }//if (should pump card)
+ }//while - card has more pump keywords - Blistering Dieflyn has two pump keywords
+
+ //Creatures with simple, targeted keyword adding abilities
+ // costs may include "T" to indicate a tap cost
+ //-1 means not found
+ while(shouldTgtKPumpCard(card) != -1)
+ {
+ int n = shouldTgtKPumpCard(card);
+ if(n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+
+ String tmpCost = k[0].substring(9);
+ final String keyword = k[1];
+
+ boolean tapCost = false;
+ boolean tapOnlyCost = false;
+
+ if (tmpCost.contains("T"))
+ {
+ tapCost = true;
+ tmpCost = tmpCost.replace("T", "");
+ tmpCost = tmpCost.trim();
+ if (tmpCost.length() == 0)
+ tapOnlyCost = true;
+ }
+
+ final String manaCost = tmpCost;
+
+ String tempDesc = new String();
+ tempDesc = "Target creature gains " + keyword + " until end of turn.";
+ final String Desc = tempDesc;
+
+ if (! tapCost)
+ {
+ final SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+
+ private static final long serialVersionUID = -1118592153328758083L;
+
+ public boolean canPlayAI()
+ {
+ //if(CardFactoryUtil.AI_doesCreatureAttack(card))
+ // return false;
+ CardList list = getCreature();
+ if (list.isEmpty())
+ return false;
+ else
+ {
+ Random r = new Random();
+ if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
+ return true;
+ else
+ return false;
+ }
+ }
+
+
+ public boolean canPlay()
+ {
+
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card)&&
+ !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() &&
+ (!CardFactoryUtil.AI_doesCreatureAttack(c)) && CardFactoryUtil.canTarget(card, c) &&
+ (! c.getKeyword().contains(keyword)) &&
+ (! c.getKeyword().contains("Defender")) &&
+ (! c.hasSickness() && keyword.equals("Haste"));
+ }
+ });
+ // list.remove(card); // if mana-only cost, allow self-target
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ final Card[] creature = new Card[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = -8840812331316327448L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ creature[0].removeExtrinsicKeyword(keyword);
+ }
+ };
+ creature[0] = getTargetCard();
+ creature[0].addExtrinsicKeyword(keyword);
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+ AllZone.EndOfTurn.addUntil(EOT);
+ }//if (card is in play)
+ }//resolve()
+ };//SpellAbility
+
+ ability.setDescription(manaCost + ":" + Desc);
+ ability.setStackDescription(Desc);
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ card.addSpellAbility(ability);
+ }
+ if (tapOnlyCost)
+ {
+ final SpellAbility ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 5252594757468128739L;
+
+ public boolean canPlayAI()
+ {
+ if(CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+
+ return getCreature().size() != 0;
+ }
+ public boolean canPlay()
+ {
+ boolean sick = true;
+
+ if (!card.hasSickness() || !card.isCreature())
+ sick = false;
+
+ if (card.isUntapped() && CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card)
+ && !sick && !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() &&
+ (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
+ (! c.getKeyword().contains(keyword)) &&
+ (! c.getKeyword().contains("Defender")) &&
+ (! c.hasSickness() && keyword.equals("Haste"));
+ }
+ });
+ list.remove(card);
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ final Card[] creature = new Card[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = 2134353417588894452L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ creature[0].removeExtrinsicKeyword(keyword);
+ }
+ };
+ creature[0] = getTargetCard();
+ creature[0].addExtrinsicKeyword(keyword);
+ AllZone.EndOfTurn.addUntil(EOT);
+ }//if (card is in play)
+ }//resolve()
+ };//SpellAbility
+
+ ability.setDescription("tap:" + Desc);
+ ability.setStackDescription(Desc);
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ card.addSpellAbility(ability);
+ }
+ if (! tapOnlyCost && tapCost)
+ {
+ final SpellAbility ability = new Ability_Tap(card, manaCost)
+ {
+ private static final long serialVersionUID = 7593387152288440603L;
+
+ public boolean canPlayAI()
+ {
+ if(CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+
+ return getCreature().size() != 0;
+ }
+ public boolean canPlay()
+ {
+ boolean sick = true;
+
+ if (!card.hasSickness() || !card.isCreature())
+ sick = false;
+
+ if (card.isUntapped() && CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) &&
+ !sick && !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() &&
+ (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
+ (! c.getKeyword().contains(keyword)) &&
+ (! c.getKeyword().contains("Defender")) &&
+ (! c.hasSickness() && keyword.equals("Haste"));
+ }
+ });
+ list.remove(card);
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card ,getTargetCard()))
+ {
+ final Card[] creature = new Card[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = 3532917180149273560L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ creature[0].removeExtrinsicKeyword(keyword);
+ }
+ };
+ creature[0] = getTargetCard();
+ creature[0].addExtrinsicKeyword(keyword);
+ AllZone.EndOfTurn.addUntil(EOT);
+ }//if (card is in play)
+ }//resolve()
+ };//SpellAbility
+
+ ability.setDescription(manaCost + ", tap:" + Desc);
+ ability.setStackDescription(Desc);
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ card.addSpellAbility(ability);
+ }
+ }
+ }//while
+
+
+ //Creatures with self-regenerate abilities
+ //-1 means keyword "RegenerateMe" not found
+ while (shouldRegenerateMe(card) != -1)
+ {
+ int n = shouldRegenerateMe(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ final Command untilEOT = new Command() {
+ private static final long serialVersionUID = -7619842476705984912L;
+
+ public void execute()
+ {
+ card.setShield(0);
+
+ }
+ };
+
+ final SpellAbility a1 = new Ability(card, manacost) {
+ public boolean canPlayAI()
+ {
+ if (CardFactoryUtil.AI_isMainPhase())
+ {
+ if (CardFactoryUtil.AI_doesCreatureAttack(card))
+ {
+ //"Fuzzy logic" to determine if using a regenerate ability might be helpful because
+ //we can't wait to decide to play this ability during combat, like the human can
+ //weight[] is a set of probability percentages to be averaged later
+ int weight[] = new int[3];
+
+ // cards with real keywords (flying, trample, etc) are probably more desireable
+ if (card.getKeyword().size() > 0)
+ weight[0] = 75;
+ else
+ weight[0] = 0;
+
+ // if there are many cards in hand, then maybe it's not such a great idea to waste mana
+ CardList HandList = new CardList(AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer).getCards());
+
+ if (HandList.size() >= 4)
+ weight[1] = 25;
+ else
+ weight[1] = 75;
+
+ // compare the highest converted mana cost of cards in hand to the number of lands
+ // if there's spare mana, then regeneration might be viable
+ int hCMC = 0;
+ for (int i = 0; i < HandList.size(); i++)
+ if (CardUtil.getConvertedManaCost(HandList.getCard(i).getManaCost()) > hCMC)
+ hCMC = CardUtil.getConvertedManaCost(HandList.getCard(i).getManaCost());
+
+ CardList LandList = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
+ LandList = LandList.getType("Land");
+
+ //most regenerate abilities cost 2 or less
+ if (hCMC + 2 >= LandList.size())
+ weight[2] = 50;
+ else
+ weight[2] = 0;
+
+ // ultimately, it's random fate that dictates if this was the right play
+ int aw = (weight[0] + weight[1] + weight[2]) / 3;
+ Random r = new Random();
+ if (r.nextInt(100) <= aw)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void resolve()
+ {
+ card.addShield();
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }; //SpellAbility
+
+ card.addSpellAbility(a1);
+
+ String Desc = new String();
+ Desc = "Regenerate " + cardName;
+
+ a1.setDescription(manacost + " : " + Desc);
+ a1.setStackDescription(Desc);
+
+ a1.setBeforePayMana(new Input_PayManaCost(a1));
+ } //if (should RegenerateMe)
+ } //while - card has more RegenerateMe - Jungle Troll has two Regenerate keywords
+
+
+ if (shouldUntap(card) != -1)
+ {
+ int n = shouldUntap(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.ability_Untap(card, manacost));
+ }
+ }
+
+ if (shouldSporeSaproling(card) != -1)
+ {
+ int n = shouldSporeSaproling(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ card.addSpellAbility(CardFactoryUtil.ability_Spore_Saproling(card));
+ }
+ }//Spore Saproling
+
+ if (shouldSpDamageTgt(card) != -1)
+ {
+ int n = shouldSpDamageTgt(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ card.clearSpellAbility();
+
+ String k[] = parse.split(":");
+
+ final boolean TgtCreature[] = {false};
+ final boolean TgtPlayer[] = {false};
+ final boolean TgtCP[] = {false};
+
+ if (k[0].contains("CP"))
+ TgtCP[0] = true;
+ else if (k[0].contains("P"))
+ TgtPlayer[0] = true;
+ else if (k[0].contains("C"))
+ TgtCreature[0] = true;
+
+ // how much damage
+ final int NumDmg[] = {-1};
+ final String NumDmgX[] = {"none"};
+
+ if (k[1].length() <= 2) // numeric
+ NumDmg[0] = Integer.parseInt(k[1]);
+ else // result of some sort of function
+ {
+ if (k[1].startsWith("Count$"))
+ {
+ String kk[] = k[1].split("\\$");
+ NumDmgX[0] = kk[1];
+ }
+ }
+
+ //drawbacks and descriptions
+ final String DrawBack[] = {"none"};
+ final String spDesc[] = {"none"};
+ final String stDesc[] = {"none"};
+ if (k.length > 2)
+ {
+ if (k[2].contains("Drawback$"))
+ {
+ String kk[] = k[2].split("\\$");
+ DrawBack[0] = kk[1];
+ if (k.length > 3)
+ spDesc[0] = k[3];
+ if (k.length > 4)
+ stDesc[0] = k[4];
+ }
+ else
+ {
+ if (k.length > 2)
+ spDesc[0] = k[2];
+ if (k.length > 3)
+ stDesc[0] = k[3];
+ }
+ }
+
+ final SpellAbility DamageTgt = new Spell(card)
+ {
+ private static final long serialVersionUID = 7239608350643325111L;
+ private int damage;
+
+ public int getNumDamage()
+ {
+ if (NumDmg[0] != -1)
+ return NumDmg[0];
+
+ if (! NumDmgX[0].equals("none"))
+ return CardFactoryUtil.xCount(card, NumDmgX[0]);
+
+ return 0;
+ }
+
+ boolean shouldTgtP()
+ {
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 7) // anti-discard-at-EOT
+ return true;
+
+ if(AllZone.Human_Life.getLife() < (10 - damage)) // if damage from this spell would drop the human to less than 10 life
+ return true;
+
+ return false;
+ }
+
+ Card chooseTgtC()
+ {
+ // Combo alert!!
+ PlayerZone compy = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList cPlay = new CardList(compy.getCards());
+ if (cPlay.size() > 0)
+ for (int i = 0; i < cPlay.size(); i++)
+ if (cPlay.get(i).getName().equals("Stuffy Doll"))
+ return cPlay.get(i);
+
+ PlayerZone human = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList hPlay = new CardList(human.getCards());
+ hPlay = hPlay.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ // will include creatures already dealt damage
+ return c.isCreature() && ((c.getNetDefense() + c.getDamage()) <= damage) && CardFactoryUtil.canTarget(card, c);
+ }
+ }
+ );
+
+ if (hPlay.size() > 0)
+ {
+ Card best = hPlay.get(0);
+
+ if (hPlay.size() > 1)
+ {
+ for (int i = 1; i < hPlay.size(); i++)
+ {
+ Card b = hPlay.get(i);
+ // choose best overall creature?
+ if (b.getSpellAbility().length > best.getSpellAbility().length ||
+ b.getKeyword().size() > best.getKeyword().size() ||
+ b.getNetAttack() > best.getNetAttack())
+ best = b;
+ }
+ }
+
+ return best;
+ }
+
+ return null;
+ }
+
+ public boolean canPlayAI()
+ {
+ damage = getNumDamage();
+
+ if (TgtCP[0] == true)
+ {
+ if (shouldTgtP() == true)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return true;
+ }
+
+ Card c = chooseTgtC();
+ if (c != null)
+ {
+ setTargetCard(c);
+ return true;
+ }
+ }
+
+ if (TgtPlayer[0] == true)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return shouldTgtP();
+ }
+
+ if (TgtCreature[0] == true)
+ {
+ Card c = chooseTgtC();
+ if (c != null)
+ {
+ setTargetCard(c);
+ return c != null;
+ }
+ }
+
+ return false;
+ }
+
+ public void resolve()
+ {
+ damage = getNumDamage();
+ String tgtP = new String();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ //c.addDamage(damage);
+ AllZone.GameAction.addDamage(c, damage);
+ tgtP = c.getController();
+ }
+ }
+ else
+ {
+ AllZone.GameAction.addDamage(getTargetPlayer(), damage);
+ tgtP = getTargetPlayer();
+ }
+
+ if (! DrawBack[0].equals("none"))
+ CardFactoryUtil.doDrawBack(DrawBack[0], damage, card.getController(), AllZone.GameAction.getOpponent(card.getController()), tgtP, card, getTargetCard());
+ }// resolove
+ }; //spellAbility
+ if (! spDesc[0].equals("none"))
+ DamageTgt.setDescription(spDesc[0]);
+ else
+ {
+ String s;
+ s = card.getName() + " deals " + NumDmg[0] + " damage to target";
+ if (TgtCP[0])
+ s = s + " creature or player.";
+ else if (TgtCreature[0])
+ s = s + " creature.";
+ else if (TgtPlayer[0])
+ s = s + " player.";
+ DamageTgt.setDescription(s);
+ }
+
+ if (! stDesc[0].equals("none"))
+ DamageTgt.setStackDescription(stDesc[0]);
+ else
+ DamageTgt.setStackDescription(card.getName() + " - deals " + NumDmg[0] + " damage.");
+
+ if (TgtCP[0])
+ DamageTgt.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(DamageTgt, true));
+ else if (TgtCreature[0])
+ DamageTgt.setBeforePayMana(CardFactoryUtil.input_targetCreature(DamageTgt));
+ else if (TgtPlayer[0])
+ DamageTgt.setBeforePayMana(CardFactoryUtil.input_targetPlayer(DamageTgt));
+
+ card.addSpellAbility(DamageTgt);
+ }
+ }// spDamageTgt
+
+
+ //Spell damage cards CP means Computer and Player (like shock, Lightning Bolt)
+ if (shouldSpDamageCP(card) != -1)
+ {
+ int n = shouldSpDamageCP(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ //System.out.println("parse: " + parse);
+ card.removeIntrinsicKeyword(parse);
+
+ card.clearSpellAbility();
+
+ String k[] = parse.split(":");
+ final String dmg = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.spellability_spDamageCP(card, dmg));
+ }
+ }
+
+ if (shouldSpDamageP(card) != -1)
+ {
+ int n = shouldSpDamageP(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removePrevIntrinsicKeyword(parse);
+
+ card.clearSpellAbility();
+
+ String k[] = parse.split(":");
+ final String dmg = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.spellability_spDamageP(card, dmg));
+ }
+ }//SpDamageP
+
+ if (shouldAbDamageCP(card) != -1)
+ {
+ int n = shouldAbDamageCP(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+
+ String tmpCost = k[0].substring(11);
+
+ final int dmg[] = new int[1];
+ dmg[0] = Integer.parseInt(k[1]);
+
+ boolean tapCost = false;
+ boolean tapOnlyCost = false;
+
+ if (tmpCost.contains("T"))
+ {
+ tapCost = true;
+ tmpCost = tmpCost.replace("T", "");
+ tmpCost = tmpCost.trim();
+ if (tmpCost.length() == 0)
+ tapOnlyCost = true;
+ }
+
+ final String manaCost = tmpCost;
+
+ String tempDesc = new String();
+ tempDesc = cardName + " deals " + dmg[0] + " damage to target creature or player.";
+ final String Desc = tempDesc;
+
+ if (! tapCost)
+ {
+ final SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+ private static final long serialVersionUID = -7560349014757367722L;
+
+ public boolean canPlayAI()
+ {
+ Random r = new Random();
+ if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
+ return true;
+ else
+ return false;
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(dmg[0], card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5 + dmg[0])
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }//chooseTargetAI
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) {
+ getTargetCard().addDamage(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+ }
+ }
+ else {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+ }
+ }//resolve()
+ };//Ability_Activated
+
+ ability.setDescription(manaCost + ": " + Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ card.addSpellAbility(ability);
+ }//!tapCost
+
+ if (tapOnlyCost == true)
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -7560349014757367722L;
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5 + dmg[0])
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }//chooseTargetAI
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addDamage(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+
+ }
+ }
+ else {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+
+ card.setDealtDmgToOppThisTurn(true);
+ }
+ }//resolve()
+ };//Ability_Tap
+
+ ability.setDescription("tap: " + Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ card.addSpellAbility(ability);
+ }//tapOnlyCost
+
+ if (! tapOnlyCost && tapCost)
+ {
+ final SpellAbility ability = new Ability_Tap(card, manaCost)
+ {
+ private static final long serialVersionUID = -7560349014757367722L;
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5 + dmg[0])
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }//chooseTargetAI
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) {
+ getTargetCard().addDamage(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+ }
+ }
+ else {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(dmg[0]);
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, dmg[0]);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, dmg[0]);
+
+ card.setDealtDmgToOppThisTurn(true);
+ }
+ }//resolve()
+ };//Ability_Tap
+
+ ability.setDescription(manaCost + ", tap: " + Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ card.addSpellAbility(ability);
+ }//!tapOnlyCost && tapCost
+ }//n
+ }//AbDamageCP
+
+
+ while (shouldAbTgtPTPumpCard(card) != -1)
+ {
+ int n = shouldAbTgtPTPumpCard(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ String pt[] = k[1].split("/");
+
+ final int attack[] = new int[1];
+ final int defense[] = new int[1];
+
+ attack[0] = Integer.parseInt(pt[0].replace("+", ""));
+ defense[0] = Integer.parseInt(pt[1].replace("+", ""));
+
+ String tmpCost = k[0].substring(11);
+ boolean tapCost = false;
+ boolean tapOnlyCost = false;
+
+ if (tmpCost.contains("T"))
+ {
+ tapCost = true;
+ tmpCost = tmpCost.replace("T", "");
+ tmpCost = tmpCost.trim();
+ if (tmpCost.length() == 0)
+ tapOnlyCost = true;
+ }
+
+ final String manaCost = tmpCost;
+ //System.out.println("manaCost is " + manaCost + " for " + card.getName());
+
+ String tmpDesc = new String();
+ tmpDesc = "Target creature gets ";
+ if (attack[0] > 0)
+ tmpDesc = tmpDesc + "+" + attack[0];
+ else
+ tmpDesc = tmpDesc + attack[0];
+ tmpDesc = tmpDesc + "/";
+ if (defense[0] > 0)
+ tmpDesc = tmpDesc + "+" + defense[0];
+ else
+ tmpDesc = tmpDesc + defense[0];
+ tmpDesc = tmpDesc + " until end of turn.";
+ final String Desc = tmpDesc;
+
+ if (!tapCost)
+ {
+ final SpellAbility ability = new Ability_Activated(card, manaCost)
+ {
+ private static final long serialVersionUID = -845173064437485113L;
+
+ public boolean canPlay()
+ {
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) &&
+ !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public boolean canPlayAI()
+ {
+ CardList list = getAttackers();
+ if (list.isEmpty())
+ return false;
+ else
+ {
+ if (list.get(0).getNetDefense() + defense[0] < 1)
+ return false;
+ Random r = new Random();
+ if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
+ {
+ setTargetCard(list.get(0));
+ return true;
+ }
+ else
+ return false;
+ }
+ }//canPlayAI
+ public CardList getAttackers()
+ {
+ Card[] c = ComputerUtil.getAttackers().getAttackers();
+ CardList list = new CardList(c);
+
+ return list;
+ }//getAttacker
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ final Card[] creature = new Card[1];
+
+ creature[0] = getTargetCard();
+ creature[0].addTempAttackBoost(attack[0]);
+ creature[0].addTempDefenseBoost(defense[0]);
+
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = 122944434978198700L;
+
+ public void execute()
+ {
+ if (AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].addTempAttackBoost(-attack[0]);
+ creature[0].addTempDefenseBoost(-defense[0]);
+ }
+ }
+ };//EOT
+ AllZone.EndOfTurn.addUntil(EOT);
+ }
+ }//resolve
+ };//ability
+ ability.setDescription(manaCost+": "+Desc);
+ ability.setStackDescription(Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ card.addSpellAbility(ability);
+ }//!tapCost
+
+ if (tapOnlyCost)
+ {
+ final SpellAbility ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 6723777240105966031L;
+
+ public boolean canPlay()
+ {
+ boolean sick = true;
+ if (!card.hasSickness() || !card.isCreature())
+ sick = false;
+ if (card.isUntapped() && CardFactoryUtil.canUseAbility(card) &&
+ AllZone.GameAction.isCardInPlay(card) && !sick && !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }//canPlay
+ public boolean canPlayAI()
+ {
+ CardList list = getAttackers();
+ if (list.isEmpty())
+ return false;
+ else
+ if (list.get(0).getNetDefense() + defense[0] < 1)
+ return false;
+ if (CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI
+ public CardList getAttackers()
+ {
+ Card[] c = ComputerUtil.getAttackers().getAttackers();
+ CardList list = new CardList(c);
+ list.remove(card);
+ return list;
+ }
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ final Card[] creature = new Card[1];
+
+ creature[0] = getTargetCard();
+ creature[0].addTempAttackBoost(attack[0]);
+ creature[0].addTempDefenseBoost(defense[0]);
+
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = -852905560563053752L;
+
+ public void execute()
+ {
+ if (AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].addTempAttackBoost(-attack[0]);
+ creature[0].addTempDefenseBoost(-defense[0]);
+ }
+ }
+ };//EOT
+ AllZone.EndOfTurn.addUntil(EOT);
+ }
+ }//resolve
+ };//ability
+ ability.setDescription("tap: "+Desc);
+ ability.setStackDescription(Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature_NoCost_TapAbility((Ability_Tap)ability));
+ card.addSpellAbility(ability);
+ }//tapOnlyCost
+
+ if (!tapOnlyCost && tapCost)
+ {
+ final SpellAbility ability = new Ability_Tap(card, manaCost)
+ {
+ private static final long serialVersionUID = 2749576299299014851L;
+
+ public boolean canPlay()
+ {
+ boolean sick = true;
+ if (!card.hasSickness() || !card.isCreature())
+ sick = false;
+ if (card.isUntapped() && CardFactoryUtil.canUseAbility(card) &&
+ AllZone.GameAction.isCardInPlay(card) && !sick && !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }//canPlay
+ public boolean canPlayAI()
+ {
+ CardList list = getAttackers();
+ if (list.isEmpty())
+ return false;
+ else
+ if (list.get(0).getNetDefense() + defense[0] < 1)
+ return false;
+ if (CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI
+ public CardList getAttackers()
+ {
+ Card[] c = ComputerUtil.getAttackers().getAttackers();
+ CardList list = new CardList(c);
+ list.remove(card);
+ return list;
+ }//getAttackers
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ final Card[] creature = new Card[1];
+
+ creature[0] = getTargetCard();
+ creature[0].addTempAttackBoost(attack[0]);
+ creature[0].addTempDefenseBoost(defense[0]);
+
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = 8179097336678296338L;
+
+ public void execute()
+ {
+ if (AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].addTempAttackBoost(-attack[0]);
+ creature[0].addTempDefenseBoost(-defense[0]);
+ }
+ }
+ };//EOT
+ AllZone.EndOfTurn.addUntil(EOT);
+ }
+ }//resolve
+ };//ability
+ ability.setDescription(manaCost+ ", tap: "+Desc);
+ ability.setStackDescription(Desc);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ card.addSpellAbility(ability);
+ }//!tapCost
+ }
+ }//while
+
+ // Generic destroy target card
+ if (shouldSpDestroyTgt(card) != -1)
+ {
+ int n = shouldSpDestroyTgt(card);
+
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ String Targets = k[1]; // Artifact, Creature, Enchantment, Land, Permanent, White, Blue, Black, Red, Green, Colorless, MultiColor
+ // non-Artifact, non-Creature, non-Enchantment, non-Land, non-Permanent,
+ //non-White, non-Blue, non-Black, non-Red, non-Green, non-Colorless, non-MultiColor
+ final String Tgts[] = Targets.split(",");
+
+ String tmpDesc = card.getText().substring(15);
+ int i = tmpDesc.indexOf(".");
+ tmpDesc = tmpDesc.substring(0, i);
+ final String Selec = new String("Select target " + tmpDesc + " to destroy.");
+
+ final boolean NoRegen = (k.length == 3);
+
+ card.clearSpellAbility();
+
+ final SpellAbility spDstryTgt = new Spell(card)
+ {
+ private static final long serialVersionUID = 142142142142L;
+
+ public boolean canPlayAI()
+ {
+ CardList results = new CardList();
+ CardList choices = getTargets();
+
+ if (choices.size() > 0)
+ {
+ for (int i = 0; i < Tgts.length; i++)
+ {
+ if (Tgts[i].equals("Artifact")) {
+ if (CardFactoryUtil.AI_getBestArtifact(choices) != null)
+ results.add(CardFactoryUtil.AI_getBestArtifact(choices));
+ }
+ else if (Tgts[i].equals("Creature")) {
+ if (CardFactoryUtil.AI_getBestCreature(choices) != null)
+ results.add(CardFactoryUtil.AI_getBestCreature(choices));
+ }
+ else if (Tgts[i].equals("Enchantment")) {
+ if (CardFactoryUtil.AI_getBestEnchantment(choices, card, true) != null)
+ results.add(CardFactoryUtil.AI_getBestEnchantment(choices, card, true));
+ }
+ else if (Tgts[i].equals("Land")) {
+ if (CardFactoryUtil.AI_getBestLand(choices) != null)
+ results.add(CardFactoryUtil.AI_getBestLand(choices));
+ }
+ else if (Tgts[i].equals("Permanent")){
+ if (CardFactoryUtil.AI_getMostExpensivePermanent(choices, card, true) != null)
+ results.add(CardFactoryUtil.AI_getMostExpensivePermanent(choices, card, true));
+ }
+ }
+ }
+
+
+ if (results.size() > 0)
+ {
+ results.shuffle();
+ setTargetCard(results.get(0));
+ return true;
+ }
+ return false;
+ }
+ CardList getTargets()
+ {
+ CardList tmpList = new CardList();
+ tmpList.addAll(AllZone.Human_Play.getCards());
+ tmpList.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (CardFactoryUtil.canTarget(card, c));
+ }
+ });
+
+ return tmpList.getValidCards(Tgts);
+ }
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ if (NoRegen)
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ else
+ AllZone.GameAction.destroy(getTargetCard());
+
+ }
+ }; //SpDstryTgt
+
+ Input InGetTarget = new Input()
+ {
+ private static final long serialVersionUID = -142142142142L;
+
+ public void showMessage()
+ {
+ CardList allCards = new CardList();
+ allCards.addAll(AllZone.Human_Play.getCards());
+ allCards.addAll(AllZone.Computer_Play.getCards());
+ allCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (CardFactoryUtil.canTarget(card, c));
+ }
+ });
+
+ CardList choices = allCards.getValidCards(Tgts);
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spDstryTgt, choices, Selec, true));
+ }
+ };//InGetTarget
+
+ //card.clearSpellAbility();
+ spDstryTgt.setBeforePayMana(InGetTarget);
+ spDstryTgt.setDescription(card.getText());
+ card.setText("");
+ card.addSpellAbility(spDstryTgt);
+ }//spDestroyTgt
+
+ if (shouldSpDrawCards(card) != -1)
+ {
+ int n = shouldSpDrawCards(card);
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+
+ final boolean Tgt[] = {false};
+ Tgt[0] = k[0].contains("Tgt");
+
+ final int NumCards[] = {-1};
+ final String NumCardsType[] = {"none"};
+ final boolean NumCardsTypeYouCtrl[] = {false};
+ final boolean NumCardsTypeInPlay[] = {false};
+ final boolean NumCardsTypeInYourYard[] = {false};
+ final boolean NumCardsTypeInAllYards[] = {false};
+ final boolean NumCardsDomain[] = {false};
+ if (k[1].length() == 1)
+ NumCards[0] = Integer.parseInt(k[1]);
+ else
+ {
+ if (k[1].startsWith("NumCardsType"))
+ {
+ String kk[] = k[1].split("/");
+ NumCardsType[0] = kk[1];
+ NumCardsTypeYouCtrl[0] = kk[2].equals("YouCtrl");
+ NumCardsTypeInPlay[0] = kk[2].equals("InPlay");
+ NumCardsTypeInYourYard[0] = kk[2].equals("InYourYard");
+ NumCardsTypeInAllYards[0] = kk[2].equals("InAllYards");
+ }
+ NumCardsDomain[0] = k[1].equals("Domain");
+ }
+
+ final int NumDiscard[] = {0};
+ final String UnlessDiscardType[] = {"none"};
+ final boolean AtRandom[] = {false};
+
+ final int NumLoseLife[] = {0};
+
+ final int NumToLibrary[] = {0};
+ final String LibraryPosition[] = {"none"};
+
+ final int NumOppDraw[] = {0};
+
+ if (k.length > 2)
+ {
+ if (k[2].contains("Discard"))
+ {
+ String kk[] = k[2].split("/");
+ if (kk[1].equals("X"))
+ NumDiscard[0] = -1;
+ else
+ NumDiscard[0] = Integer.parseInt(kk[1]);
+
+ if (kk.length > 2)
+ {
+ if (kk[2].equals("UnlessDiscardType"))
+ UnlessDiscardType[0] = kk[3];
+
+ AtRandom[0] = kk[2].equals("AtRandom");
+ }
+ }
+
+ if (k[2].contains("LoseLife"))
+ {
+ String kk[] = k[2].split("/");
+ if (kk[1].equals("X"))
+ NumLoseLife[0] = -1;
+ else
+ NumLoseLife[0] = Integer.parseInt(kk[1]);
+ }
+
+ if (k[2].contains("NumToLibrary"))
+ {
+ String kk[] = k[2].split("/");
+ if (kk[1].equals("X"))
+ NumToLibrary[0] = -1;
+ else
+ NumToLibrary[0] = Integer.parseInt(kk[1]);
+ LibraryPosition[0] = kk[2];
+ }
+
+ if (k[2].contains("NumOppDraw"))
+ {
+ String kk[] = k[2].split("/");
+ if (kk[1].equals("X"))
+ NumOppDraw[0] = -1;
+ else
+ NumOppDraw[0] = Integer.parseInt(kk[1]);
+ }
+ }
+
+ final SpellAbility spDraw = new Spell(card)
+ {
+ private static final long serialVersionUID = -7049779241008089696L;
+
+ public int getNumCards()
+ {
+ if (NumCards[0] != -1)
+ return NumCards[0];
+
+ int n = 0;
+
+ String cardController = card.getController();
+ PlayerZone myPlay = AllZone.getZone(Constant.Zone.Play, cardController);
+ PlayerZone opPlay = AllZone.getZone(Constant.Zone.Play, AllZone.GameAction.getOpponent(cardController));
+
+ PlayerZone myYard = AllZone.getZone(Constant.Zone.Graveyard, cardController);
+ PlayerZone opYard = AllZone.getZone(Constant.Zone.Graveyard, AllZone.GameAction.getOpponent(cardController));
+
+ CardList AllCards = new CardList();
+
+ if (! NumCardsType[0].equals("none"))
+ {
+ if (NumCardsTypeInYourYard[0] == false)
+ AllCards.addAll(myYard.getCards());
+
+ if (NumCardsTypeInAllYards[0] == false)
+ {
+ AllCards.addAll(myYard.getCards());
+ AllCards.addAll(opYard.getCards());
+ }
+
+ if (NumCardsTypeYouCtrl[0] == true)
+ AllCards.addAll(myPlay.getCards());
+
+ if (NumCardsTypeInPlay[0] == true)
+ {
+ AllCards.addAll(myPlay.getCards());
+ AllCards.addAll(opPlay.getCards());
+ }
+
+ AllCards = AllCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if (c.getType().contains(NumCardsType[0]))
+ return true;
+
+ return false;
+ }
+ });
+
+ n = AllCards.size();
+ }
+ if (NumCardsDomain[0] == true)
+ {
+ AllCards.addAll(myPlay.getCards());
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+
+ for(int i = 0; i < basic.length; i++)
+ if (! AllCards.getType(basic[i]).isEmpty())
+ n++;
+ }
+
+ if (NumDiscard[0] == -1)
+ NumDiscard[0] = n;
+ if (NumLoseLife[0] == -1)
+ NumLoseLife[0] = n;
+ if (NumToLibrary[0] == -1)
+ NumToLibrary[0] = n;
+ if (NumOppDraw[0] == -1)
+ NumOppDraw[0] = n;
+
+ return n;
+ }
+
+ public boolean canPlayAI()
+ {
+ int n = getNumCards();
+ int h = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer).size();
+ Random r = new Random();
+
+ if (((h + n) - (NumDiscard[0] + NumToLibrary[0]) <= 7)
+ && (AllZone.GameAction.getPlayerLife(Constant.Player.Computer).getLife() - NumLoseLife[0]) >= 8
+ && (r.nextInt(10) > 4))
+ {
+ setTargetPlayer(Constant.Player.Computer);
+ return true;
+ }
+
+ return false;
+ }
+
+ public void resolve()
+ {
+ int n = getNumCards();
+
+ String TgtPlayer = card.getController();
+ if (Tgt[0])
+ TgtPlayer = getTargetPlayer();
+
+ for (int i=0; i < n; i++)
+ AllZone.GameAction.drawCard(TgtPlayer);
+
+ if (NumDiscard[0] > 0)
+ {
+ if (!UnlessDiscardType[0].equals("none"))
+ AllZone.GameAction.discardUnless(TgtPlayer, NumDiscard[0], UnlessDiscardType[0]);
+ else if (AtRandom[0] == true)
+ AllZone.GameAction.discardRandom(TgtPlayer, NumDiscard[0]);
+ else
+ AllZone.GameAction.discard(TgtPlayer, NumDiscard[0]);
+ }
+
+ if (NumLoseLife[0] > 0)
+ AllZone.GameAction.getPlayerLife(TgtPlayer).subtractLife(NumLoseLife[0]);
+
+ if (NumToLibrary[0] > 0)
+ AllZone.GameAction.handToLibrary(TgtPlayer, NumToLibrary[0], LibraryPosition[0]);
+
+ if (NumOppDraw[0] > 0)
+ for (int i = 0; i < NumOppDraw[0]; i++)
+ AllZone.GameAction.drawCard(AllZone.GameAction.getOpponent(TgtPlayer));
+ }
+ };
+
+ if (Tgt[0])
+ spDraw.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDraw));
+
+ spDraw.setDescription(card.getText());
+ card.setText("");
+ card.clearSpellAbility();
+ card.addSpellAbility(spDraw);
+ }//spDrawCards
+
+ //Spell gain life lose life cards (like Soul Feast)
+ if (shouldSpLoseLifeGainLife(card) != -1)
+ {
+ int n = shouldSpLoseLifeGainLife(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ card.clearSpellAbility();
+
+ String k[] = parse.split(":");
+ final String lfdmg = k[1];
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -8277174319360648715L;
+
+ public void resolve()
+ {
+ final int n = Integer.parseInt(lfdmg);
+
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(n);
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(n);
+ }//resolve()
+ };//SpellAbility
+
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ return card;
+ }
+ }// spLoseLifeGainLife
+
+ if (shouldRebelSearch(card) != -1)
+ {
+ int n = shouldRebelSearch(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.ability_Rebel_Search(card, manacost));
+ }
+ }//Rebel search
+
+ if (shouldMercSearch(card) != -1)
+ {
+ int n = shouldMercSearch(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.ability_Merc_Search(card, manacost));
+ }
+ }//Merc search
+
+ if (shouldMorph(card) != -1)
+ {
+ int n = shouldMorph(card);
+ if (n != -1)
+ {
+ card.setPrevIntrinsicKeyword(card.getIntrinsicKeyword());
+ card.setPrevType(card.getType());
+
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ int attack = card.getBaseAttack();
+ int defense = card.getBaseDefense();
+
+ String orgManaCost = card.getManaCost();
+
+ card.addSpellAbility(CardFactoryUtil.ability_Morph_Up(card, manacost, orgManaCost, attack, defense));
+ card.addSpellAbility(CardFactoryUtil.ability_Morph_Down(card));
+ }
+ }//Morph
+
+ if (shouldFlashback(card) != -1)
+ {
+ int n = shouldFlashback(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ //card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+
+ final String manacost = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, manacost,"0"));
+ }
+ }//flashback
+
+
+
+
+ if (shouldDevour(card) != -1)
+ {
+ int n = shouldDevour(card);
+ if (n != -1)
+ {
+
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String magnitude = k[1];
+
+
+ final int multiplier = Integer.parseInt(magnitude);
+ //final String player = card.getController();
+ final int[] numCreatures = new int[1];
+
+
+ final SpellAbility devour = new Spell(card)
+ {
+ private static final long serialVersionUID = 4888189840817163900L;
+
+ public void resolve()
+ {
+ int totalCounters = numCreatures[0] * multiplier;
+ card.addCounter(Counters.P1P1, totalCounters);
+
+ if(card.getName().equals("Skullmulcher"))
+ {
+ for(int i=0;i= 2)
+ {
+ attack[0] = Integer.parseInt(ptk[0].replace("+", ""));
+ defense[0] = Integer.parseInt(ptk[1].replace("+", ""));
+ }
+
+ if (ptk.length == 3)
+ keyword[0] = ptk[2];
+
+/* String Desc = new String();
+ Desc = "Target creature ";
+ if (attack[0] != 0 || defense[0] != 0)
+ {
+ Desc = Desc + "gets ";
+ if (attack[0] > 0)
+ Desc = Desc + "+" + attack[0];
+ else
+ Desc = Desc + attack[0];
+ Desc = Desc + "/";
+ if (defense[0] > 0)
+ Desc = Desc + "+" + defense[0];
+ else
+ Desc = Desc + defense[0];
+
+ if (! keyword[0].equals("none"))
+ Desc = Desc + " and ";
+ }
+ if (! keyword[0].equals("none"))
+ Desc = Desc + "gains " + keyword;
+
+ Desc = Desc + " until end of turn.";
+*/
+ SpellAbility spPump = new Spell(card)
+ {
+ private static final long serialVersionUID = 42244224L;
+
+ public boolean canPlayAI()
+ {
+ Card c = getAttacker();
+ if (c != null)
+ {
+ setTargetCard(c);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public Card getAttacker()
+ {
+ Combat c = ComputerUtil.getAttackers();
+
+ CardList list = new CardList(c.getAttackers());
+ CardListUtil.sortFlying(list);
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (CardFactoryUtil.canTarget(card, c)) &&
+ (! c.getKeyword().contains(keyword[0])) &&
+ (! c.hasSickness() && keyword[0].equals("Haste"));
+ }
+ });
+
+ if (list.size() > 0)
+ return list.get(0);
+ else
+ return null;
+ }
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -42244224L;
+
+ public void execute()
+ {
+ if (AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-attack[0]);
+ target[0].addTempDefenseBoost(-defense[0]);
+
+ if (!keyword[0].equals("none"))
+ target[0].removeExtrinsicKeyword(keyword[0]);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if (AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(attack[0]);
+ target[0].addTempDefenseBoost(defense[0]);
+ if (!keyword[0].equals("none"))
+ target[0].addExtrinsicKeyword(keyword[0]);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+ spPump.setBeforePayMana(CardFactoryUtil.input_targetCreature(spPump));
+ //spPump.setDescription(Desc);
+ card.clearSpellAbility();
+ card.addSpellAbility(spPump);
+ }
+
+
+ while (shouldManaAbility(card) != -1)
+ {
+ int n = shouldManaAbility(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+ final Ability_Mana ability = new Ability_Mana(card, parse)
+ {
+ private static final long serialVersionUID = -113811381138L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };
+ //ability.setDescription(parse);
+ card.addSpellAbility(ability);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////
+
+ if(card.getKeyword().contains("When this card comes into play, draw a card."))
+ {
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+
+ private static final long serialVersionUID = 1707519783018941582L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName() + " - " +card.getController() +" draws a card.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//end if
+
+
+ //*************** START *********** START **************************
+ if( cardName.equals("Burst of Speed") ||
+ cardName.equals("Chorus of Woe") ||
+ cardName.equals("Dance of Shadows") ||
+ cardName.equals("Desperate Charge") ||
+ cardName.equals("Glorious Charge") ||
+ cardName.equals("Kjeldoran War Cry") ||
+ cardName.equals("Magnify") ||
+ cardName.equals("Nature's Cloak") ||
+ cardName.equals("Nocturnal Raid") ||
+ cardName.equals("Overrun") ||
+ cardName.equals("Path of Anger's Flame") ||
+ cardName.equals("Resuscitate") ||
+ cardName.equals("Righteous Charge") ||
+ cardName.equals("Scare Tactics") ||
+ cardName.equals("Shield Wall") ||
+ cardName.equals("Solidarity") ||
+ cardName.equals("Steadfastness") ||
+ cardName.equals("Tortoise Formation") ||
+ cardName.equals("Tromp the Domains") ||
+ cardName.equals("Valorous Charge") ||
+ cardName.equals("Virtuous Charge") ||
+ cardName.equals("Vitalizing Wind") ||
+ cardName.equals("Warrior's Charge") ||
+ cardName.equals("Warrior's Honor"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5844664906503221006L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creatures that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(cardName.equals("Dance of Shadows") ||
+ cardName.equals("Overrun") ||
+ cardName.equals("Tromp the Domains"))
+ {
+ if (att.length > 2) // Effect best used with a few creatures
+ return att[0];
+ else
+ return null;
+ }
+ if(cardName.equals("Burst of Speed") ||
+ cardName.equals("Chorus of Woe") ||
+ cardName.equals("Desperate Charge") ||
+ cardName.equals("Glorious Charge") ||
+ cardName.equals("Kjeldoran War Cry") ||
+ cardName.equals("Magnify") ||
+ cardName.equals("Nature's Cloak") ||
+ cardName.equals("Nocturnal Raid") ||
+ cardName.equals("Path of Anger's Flame") ||
+ cardName.equals("Resuscitate") ||
+ cardName.equals("Righteous Charge") ||
+ cardName.equals("Scare Tactics") ||
+ cardName.equals("Shield Wall") ||
+ cardName.equals("Solidarity") ||
+ cardName.equals("Steadfastness") ||
+ cardName.equals("Tortoise Formation") ||
+ cardName.equals("Valorous Charge") ||
+ cardName.equals("Vitalizing Wind") ||
+ cardName.equals("Virtuous Charge") ||
+ cardName.equals("Warrior's Charge") ||
+ cardName.equals("Warrior's Honor"))
+ {
+ if (att.length > 1) // Effect best used on at least a couple creatures
+ return att[0];
+ else
+ return null;
+ }
+ return null;
+ }//getAttacker()
+
+ int getPowerBoost()
+ {
+ if(cardName.equals("Tromp the Domains"))
+ return getTtDBoost();
+
+ if(cardName.equals("Kjeldoran War Cry"))
+ return getKWCBoost();
+
+ if(cardName.equals("Chorus of Woe") ||
+ cardName.equals("Dance of Shadows") ||
+ cardName.equals("Glorious Charge") ||
+ cardName.equals("Magnify") ||
+ cardName.equals("Scare Tactics") ||
+ cardName.equals("Virtuous Charge") ||
+ cardName.equals("Warrior's Charge") ||
+ cardName.equals("Warrior's Honor"))
+ return 1;
+
+ if(cardName.equals("Desperate Charge") ||
+ cardName.equals("Nocturnal Raid") ||
+ cardName.equals("Path of Anger's Flame") ||
+ cardName.equals("Righteous Charge") ||
+ cardName.equals("Valorous Charge"))
+ return 2;
+
+ if(cardName.equals("Overrun"))
+ return 3;
+
+ if(cardName.equals("Vitalizing Wind"))
+ return 7;
+
+ return 0;
+ }//getPowerBoost()
+
+ int getToughBoost()
+ {
+ if(cardName.equals("Tromp the Domains"))
+ return getTtDBoost();
+
+ if(cardName.equals("Kjeldoran War Cry"))
+ return getKWCBoost();
+
+ if(cardName.equals("Glorious Charge") ||
+ cardName.equals("Magnify") ||
+ cardName.equals("Virtuous Charge") ||
+ cardName.equals("Warrior's Charge") ||
+ cardName.equals("Warrior's Honor"))
+ return 1;
+
+ if(cardName.equals("Righteous Charge") ||
+ cardName.equals("Shield Wall"))
+ return 2;
+
+ if(cardName.equals("Overrun") ||
+ cardName.equals("Steadfastness"))
+ return 3;
+
+ if(cardName.equals("Solidarity"))
+ return 5;
+
+ if(cardName.equals("Vitalizing Wind"))
+ return 7;
+
+ return 0;
+ }//getToughBoost()
+
+ String getKeywordBoost()
+ {
+ if(cardName.equals("Burst of Speed"))
+ return "Haste";
+
+ if(cardName.equals("Overrun") ||
+ cardName.equals("Tromp the Domains"))
+ return "Trample";
+
+ if(cardName.equals("Dance of Shadows"))
+ return "Fear";
+
+ if(cardName.equals("Nature's Cloak"))
+ return "Forestwalk";
+
+ if(cardName.equals("Resuscitate"))
+ return "RegenerateMe:1";
+
+ if(cardName.equals("Tortoise Formation"))
+ return "Shroud";
+
+ return "None";
+ }//getKeywordBoost()
+
+ int getTtDBoost() // Tromp the Domains - +1/+1 for each basic land you control
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList land = new CardList(play.getCards());
+
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+ int count = 0;
+
+ for (int i = 0; i < basic.length; i++)
+ {
+ CardList c = land.getType(basic[i]);
+ if (!c.isEmpty())
+ count++;
+ }
+ return count;
+ }//getTtDBoost
+
+ int getKWCBoost() // Kjeldoran War Cry - +X/+X, X = 1 + Num(KWC in All Graveyards)
+ {
+ PlayerZone hYard = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Human);
+ PlayerZone cYard = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Computer);
+ CardList allYards = new CardList();
+
+ allYards.addAll(hYard.getCards());
+ allYards.addAll(cYard.getCards());
+ allYards = allYards.getName("Kjeldoran War Cry");
+
+ return allYards.size() + 1;
+ }//getKWCBoost
+
+ public void resolve()
+ {
+
+ final int pboost = getPowerBoost();
+ final int tboost = getToughBoost();
+ final String kboost = getKeywordBoost();
+
+ CardList list = new CardList();
+
+ if (cardName.equals("Burst of Speed") || // Creatures "you" Control
+ cardName.equals("Chorus of Woe") ||
+ cardName.equals("Dance of Shadows") ||
+ cardName.equals("Desperate Charge") ||
+ cardName.equals("Glorious Charge") ||
+ cardName.equals("Kjeldoran War Cry") ||
+ cardName.equals("Nature's Cloak") ||
+ cardName.equals("Overrun") ||
+ cardName.equals("Path of Anger's Flame") ||
+ cardName.equals("Resuscitate") ||
+ cardName.equals("Righteous Charge") ||
+ cardName.equals("Scare Tactics") ||
+ cardName.equals("Shield Wall") ||
+ cardName.equals("Solidarity") ||
+ cardName.equals("Steadfastness") ||
+ cardName.equals("Tortoise Formation") ||
+ cardName.equals("Virtuous Charge") ||
+ cardName.equals("Vitalizing Wind") ||
+ cardName.equals("Warrior's Charge") ||
+ cardName.equals("Warrior's Honor"))
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ list.addAll(play.getCards());
+
+ if(cardName.equals("Nature's Cloak"))
+ list = list.getColor("G");
+ }
+
+ if (cardName.equals("Magnify") || // All Creatures in Play
+ cardName.equals("Nocturnal Raid") || // All Black Creatures in Play
+ cardName.equals("Valorous Charge")) // All White Creatures in Play
+ {
+ PlayerZone human = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+
+ list.addAll(human.getCards());
+ list.addAll(comp.getCards());
+
+ if(cardName.equals("Nocturnal Raid"))
+ list = list.getColor("B");
+
+ if(cardName.equals("Valorous Charge"))
+ list = list.getColor("W");
+ }
+
+ 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 = 5063161656920609389L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-pboost);
+ target[0].addTempDefenseBoost(-tboost);
+
+ if(!kboost.equals("None"))
+ target[0].removeExtrinsicKeyword(kboost);
+ }
+ }
+ };//Command
+
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(pboost);
+ target[0].addTempDefenseBoost(tboost);
+
+ if(!kboost.equals("None"))
+ target[0].addExtrinsicKeyword(kboost);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//if
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Elspeth, Knight-Errant"))
+ {
+ //computer only plays ability 1 and 3, gain life and put X\X token into play
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY, n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 4);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability2: target creature gets +3/+3 and flying until EOT
+ final SpellAbility ability2 = new Ability(card2, "0")
+ {
+
+ public void resolve()
+ {
+
+ card2.addCounter(Counters.LOYALTY, 1);
+
+ turn[0] = AllZone.Phase.getTurn();
+
+ final Command eot = new Command()
+ {
+ private static final long serialVersionUID = 94488363210770877L;
+
+ public void execute()
+ {
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ c.addTempAttackBoost(-3);
+ c.addTempDefenseBoost(-3);
+ c.removeExtrinsicKeyword("Flying");
+ }
+ }//execute()
+ };//Command
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card2, c))
+ {
+ c.addTempAttackBoost(3);
+ c.addTempDefenseBoost(3);
+ c.addExtrinsicKeyword("Flying");
+
+ AllZone.EndOfTurn.addUntil(eot);
+ }
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ @SuppressWarnings("unused") // library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ return 0 < card2.getCounters(Counters.LOYALTY) &&
+ AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 9062830120519820799L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+
+
+ AllZone.Stack.push(ability2);
+ }
+ stop();
+ }//showMessage()
+ });
+
+
+
+ //ability3
+ final SpellAbility ability3 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 8);
+ turn[0] = AllZone.Phase.getTurn();
+
+ //make all permanents in play/hand/library and graveyard
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+
+ CardList list = new CardList();
+ list.addAll(play.getCards());
+ list.addAll(hand.getCards());
+ list.addAll(library.getCards());
+ list.addAll(grave.getCards());
+
+
+ for (int i=0;i < list.size(); i++)
+ {
+ Card c = list.get(i);
+ if (c.isPermanent() && !c.isPlaneswalker())
+ {
+ c.addExtrinsicKeyword("Indestructible");
+ }
+
+ }
+
+ }
+ public boolean canPlay()
+ {
+ return 8 <= card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ public boolean canPlayAI()
+ {
+ return true;
+ }
+ };
+ ability3.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -2054686425541429389L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability3);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability 1: create white 1/1 token
+ final SpellAbility ability1 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.addCounter(Counters.LOYALTY, 1);
+ turn[0] = AllZone.Phase.getTurn();
+
+ Card c = new Card();
+
+ c.setOwner(card2.getController());
+ c.setController(card2.getController());
+
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.setImageName("W 1 1 Soldier");
+ c.setName("Soldier");
+ c.addType("Creature");
+ c.addType("Soldier");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ //AllZone.GameAction.getPlayerLife(card.getController()).addLife(2);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
+ play.add(c);
+ }
+ public boolean canPlayAI()
+ {
+ if(ability3.canPlay() && ability3.canPlayAI()) {
+ return false;
+ } else
+ {
+ return true;
+ }
+ }
+ public boolean canPlay()
+ {
+ return 0 < card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ };//SpellAbility ability1
+
+ ability1.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -7892114885686285881L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability1);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ ability1.setDescription("+1: Put a white 1/1 Soldier creature token into play.");
+ ability1.setStackDescription("Elspeth, Knight-Errant - put 1/1 token into play.");
+ card2.addSpellAbility(ability1);
+
+ ability2.setDescription("+1: Target creature gets +3/+3 and gains flying until end of turn.");
+ ability2.setStackDescription("Elspeth, Knight-Errant - creature gets +3/+3 and Flying until EOT.");
+ ability2.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability2));
+
+ card2.addSpellAbility(ability2);
+
+ ability3.setDescription("-8: For the rest of the game, artifacts, creatures, enchantments, and lands you control are indestructible.");
+ ability3.setStackDescription("Elspeth, Knight-Errant - Make everything indestructible.");
+ card2.addSpellAbility(ability3);
+
+ return card2;
+ }
+ //*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Nissa Revane"))
+ {
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY, n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 2);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability2: gain 2 life for each elf controlled
+ final SpellAbility ability2 = new Ability(card2, "0")
+ {
+
+ public void resolve()
+ {
+
+ card2.addCounter(Counters.LOYALTY, 1);
+
+ turn[0] = AllZone.Phase.getTurn();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
+ CardList elves = new CardList(play.getCards());
+ elves = elves.getType("Elf");
+
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(2*elves.size());
+
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer);
+
+ CardList chosens = new CardList(lib.getCards());
+ chosens = chosens.getName("Nissa's Chosen");
+
+ if (chosens.size() > 0)
+ return false;
+
+ return true;
+ }
+
+ public boolean canPlay()
+ {
+ @SuppressWarnings("unused") // library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ return 0 < card2.getCounters(Counters.LOYALTY) &&
+ AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+
+
+ private static final long serialVersionUID = 2828718386226165026L;
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+
+
+ AllZone.Stack.push(ability2);
+ }
+ stop();
+ }//showMessage()
+ });
+
+
+ //ability3
+ final SpellAbility ability3 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 7);
+ turn[0] = AllZone.Phase.getTurn();
+
+ //make all permanents in play/hand/library and graveyard
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ CardList list = new CardList();;
+ list.addAll(library.getCards());
+ list = list.getType("Elf");
+
+ //currently, just adds all elves into play.
+ for (int i=0;i < list.size(); i++)
+ {
+ Card c = list.get(i);
+ if (c.isCreature() )
+ {
+ library.remove(c);
+ play.add(c);
+ }
+ }
+ }
+ public boolean canPlay()
+ {
+ return 7 <= card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ public boolean canPlayAI()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer);
+
+ CardList elves = new CardList(lib.getCards());
+ elves = elves.getType("Elf");
+
+ return elves.size() > 3;
+ }
+ };
+ ability3.setBeforePayMana(new Input()
+ {
+
+ private static final long serialVersionUID = -7189927522150479572L;
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability3);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability 1: search for Nessa's Chosen
+ final SpellAbility ability1 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.addCounter(Counters.LOYALTY, 1);
+ turn[0] = AllZone.Phase.getTurn();
+
+ if (card2.getController().equals(Constant.Player.Human)){
+ Object check = AllZone.Display.getChoiceOptional("Search for Nissa's Chosen", AllZone.Human_Library.getCards());
+ if(check != null)
+ {
+ Card c = (Card)check;
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ if (c.getName().equals("Nissa's Chosen"))
+ {
+ lib.remove(c);
+ play.add(c);
+ }
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+ }//human
+ else
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card2.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
+ CardList nissas = new CardList(lib.getCards());
+ nissas = nissas.getName("Nissa's Chosen");
+
+ if (nissas.size() > 0)
+ {
+ Card nissa = nissas.get(0);
+ lib.remove(nissa);
+ play.add(nissa);
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Computer);
+ }
+
+ }
+ public boolean canPlayAI()
+ {
+ if(ability3.canPlay() && ability3.canPlayAI()) {
+ return false;
+ } else
+ {
+ return true;
+ }
+ }
+ public boolean canPlay()
+ {
+ return 0 < card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ };//SpellAbility ability1
+
+ ability1.setBeforePayMana(new Input()
+ {
+
+ private static final long serialVersionUID = 7668642820407492396L;
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability1);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ ability1.setDescription("+1: Search your library for a card named Nissa's Chosen and put it onto the battlefield. Then shuffle your library.");
+ ability1.setStackDescription("Nissa Revane - Search for a card named Nissa's Chosen and put it onto the battlefield.");
+ card2.addSpellAbility(ability1);
+
+ ability2.setDescription("+1: You gain 2 life for each Elf you control.");
+ ability2.setStackDescription("Nissa Revane - You gain 2 life for each Elf you control.");
+
+ card2.addSpellAbility(ability2);
+
+ ability3.setDescription("-7: Search your library for any number of Elf creature cards and put them onto the battlefield. Then shuffle your library.");
+ ability3.setStackDescription("Nissa Revane - Search your library for any number of Elf creature cards and put them onto the battlefield. Then shuffle your library.");
+ card2.addSpellAbility(ability3);
+
+ return card2;
+ }
+ //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Nicol Bolas, Planeswalker"))
+ {
+
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY, n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 5);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability3
+ final SpellAbility ability3 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 9);
+ turn[0] = AllZone.Phase.getTurn();
+
+ String player = card2.getController();
+ String opponent = AllZone.GameAction.getOpponent(player);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, opponent);
+ CardList oppPerms = new CardList(play.getCards());
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(opponent);
+ life.subtractLife(7);
+
+ for (int j=0; j<7; j++)
+ {
+ //will not actually let human choose which cards to discard
+ AllZone.GameAction.discardRandom(opponent);
+ }
+
+ CardList permsToSac = new CardList();
+ CardList oppPermTempList = new CardList(play.getCards());
+
+ if (player.equals("Human"))
+ {
+ for(int k=0; k < oppPerms.size(); k++)
+ {
+ Card c = oppPerms.get(k);
+
+ permsToSac.add(c);
+
+ if (k == 6)
+ break;
+ }
+ }
+
+ else //computer
+ {
+ Object o = null;
+ for(int k=0; k < oppPerms.size(); k++)
+ {
+ o = AllZone.Display.getChoiceOptional("Select Card to sacrifice", oppPermTempList.toArray());
+ Card c = (Card)o;
+ //AllZone.GameAction.sacrifice(c);
+ permsToSac.add(c);
+ oppPermTempList.remove(c);
+
+
+ if (k == 6)
+ break;
+ }
+ }
+ for(int m=0;m highestCost)
+ {
+ highestCost = CardUtil.getConvertedManaCost(nonCreaturePermanents.get(i).getManaCost());
+ bestCard = nonCreaturePermanents.get(i);
+ }
+ }
+ if (bestCard == null && nonCreaturePermanents.size() > 0)
+ {
+ bestCard = nonCreaturePermanents.get(0);
+ return bestCard;
+ }
+
+ return null;
+ }
+ };//SpellAbility ability1
+
+ ability1.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 9167121234861249451L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability1);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ ability1.setDescription("+3: Destroy target noncreature permanent.");
+ ability1.setStackDescription("Nicol Bolas - Destroy target noncreature permanent.");
+ ability1.setBeforePayMana(CardFactoryUtil.input_targetNonCreaturePermanent(ability1, Command.Blank));
+
+ card2.addSpellAbility(ability1);
+
+ ability2.setDescription("-2: Gain control of target creature.");
+ ability2.setStackDescription("Nicol Bolas - Gain control of target creature.");
+ ability2.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability2));
+
+ card2.addSpellAbility(ability2);
+
+ ability3.setDescription("-9: Nicol Bolas deals 7 damage to target player. That player discards 7 cards, then sacrifices 7 permanents.");
+ ability3.setStackDescription("Nicol Bolas - deals 7 damage to target player. That player discards 7 cards, then sacrifices 7 permanents.");
+ card2.addSpellAbility(ability3);
+
+ return card2;
+ }
+ //*************** END ************ END **************************
+
+
+
+
+
+//*************** START *********** START **************************
+ if(cardName.equals("Ajani Goldmane"))
+ {
+ //computer only plays ability 1 and 3, gain life and put X\X token into play
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY,n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 4);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability2: all controller's creatures get +1\+1 and vigilance until EOT
+ final SpellAbility ability2 = new Ability(card2, "0")
+ {
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -5436621445704076988L;
+
+ public void execute()
+ {
+ String player = card2.getController();
+ CardList creatures;
+ if(player.equals(Constant.Player.Human)) {
+ creatures = new CardList(AllZone.Human_Play.getCards());
+ } else {
+ creatures = new CardList(AllZone.Computer_Play.getCards());
+ }
+
+ creatures = creatures.getType("Creature");
+
+ for (int i = 0; i < creatures.size(); i++) {
+ Card card = creatures.get(i);
+ //card.setAttack(card.getAttack() - 1);
+ //card.setDefense(card.getDefense() - 1);
+ card.removeExtrinsicKeyword("Vigilance");
+ }
+ }
+ };
+
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY,1);
+ turn[0] = AllZone.Phase.getTurn();
+
+ String player = card2.getController();
+ CardList creatures;
+ if(player.equals(Constant.Player.Human)) {
+ creatures = new CardList(AllZone.Human_Play.getCards());
+ } else {
+ creatures = new CardList(AllZone.Computer_Play.getCards());
+ }
+
+ creatures = creatures.getType("Creature");
+
+ for (int i = 0; i < creatures.size(); i++) {
+ Card card = creatures.get(i);
+ card.addCounter(Counters.P1P1,1);
+ card.addExtrinsicKeyword("Vigilance");
+ }
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ @SuppressWarnings("unused") // library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ return 0 < card2.getCounters(Counters.LOYALTY) &&
+ AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 6373573398967821630L;
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability2);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability3
+ final SpellAbility ability3 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 6);
+ turn[0] = AllZone.Phase.getTurn();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ //Create token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setImageName("W N N Avatar");
+ c.setName("Avatar");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Avatar");
+ c.setBaseAttack(AllZone.GameAction.getPlayerLife(card.getController()).getLife());
+ c.setBaseDefense(AllZone.GameAction.getPlayerLife(card.getController()).getLife());
+
+ c.addIntrinsicKeyword("This creature's power and toughness are each equal to your life total.");
+
+ play.add(c);
+ }
+ public boolean canPlay()
+ {
+ return 6 <= card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ public boolean canPlayAI()
+ {
+ // may be it's better to put only if you have less than 5 life
+ return true;
+ }
+ };
+ ability3.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 7530960428366291386L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability3);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability 1: gain 2 life
+ final SpellAbility ability1 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.addCounter(Counters.LOYALTY, 1);
+ turn[0] = AllZone.Phase.getTurn();
+
+
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(2);
+ System.out.println("current phase: " +AllZone.Phase.getPhase());
+ }
+ public boolean canPlayAI()
+ {
+ if(ability3.canPlay() && ability3.canPlayAI()) {
+ return false;
+ } else
+ {
+ return true;
+ }
+ }
+ public boolean canPlay()
+ {
+ return 0 < card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ };//SpellAbility ability1
+
+ ability1.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -7969603493514210825L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability1);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ ability1.setDescription("+1: You gain 2 life.");
+ ability1.setStackDescription("Ajani Goldmane - " + card2.getController() + " gains 2 life");
+ card2.addSpellAbility(ability1);
+
+ ability2.setDescription("-1: Put a +1/+1 counter on each creature you control. Those creatures gain vigilance until end of turn.");
+ ability2.setStackDescription("Ajani Goldmane - Put a +1/+1 counter on each creature you control. They get vigilance.");
+ card2.addSpellAbility(ability2);
+
+ ability3.setDescription("-6: Put a white Avatar creature token into play with \"This creature's power and toughness are each equal to your life total.\"");
+ ability3.setStackDescription("Ajani Goldmane - Put X\\X white Avatar creature token into play.");
+ card2.addSpellAbility(ability3);
+
+ return card2;
+ }
+ //*************** END ************ END **************************
+
+
+ //contributed code
+ //*************** START *********** START **************************
+ if(cardName.equals("Dark Banishing"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5621665629586583879L;
+
+ Card check;
+
+ public boolean canPlayAI()
+ {
+ check = getNonBlackCreature();
+ return check != null;
+ }
+
+ public void chooseTargetAI()
+ {
+ Card c = getNonBlackCreature();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ Card getNonBlackCreature()
+ {
+ int maxAttack = 0;
+ Card bestCard = null;
+ CardList nonBlackCards = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ for(int i = 0; i < nonBlackCards.size(); i++)
+ if(!CardUtil.getColors(nonBlackCards.get(i)).contains(Constant.Color.Black))
+ if(nonBlackCards.get (i).getNetAttack() > maxAttack)
+ {
+ maxAttack = nonBlackCards.get(i).getNetAttack();
+ bestCard = nonBlackCards.get(i);
+ }
+
+ return bestCard;
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()))
+ {
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ //target
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -3155643868640376193L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-black creature for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if (!CardFactoryUtil.canTarget(card, c))
+ {
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if((!CardUtil.getColors(c).contains(Constant.Color.Black))
+ && c.isCreature()
+ && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(c);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//SpellAbility - target
+
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Filthy Cur"))
+ {
+ final Card newCard = new Card()
+ {
+ public void addDamage(final int n)
+ {
+ super.addDamage(n);
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(getController()).subtractLife(n);
+ }
+ };
+ ability.setStackDescription("Filthy Cur - causes " +n +" damage to " +getController());
+ AllZone.Stack.add(ability);
+ }//addDamage()
+ };//Card
+
+ newCard.setOwner(card.getOwner());
+ newCard.setController(card.getController());
+
+ newCard.setManaCost(card.getManaCost());
+ newCard.setName(card.getName());
+ newCard.addType("Creature");
+ newCard.addType("Hound");
+ newCard.setText(card.getSpellText());
+ newCard.setBaseAttack(card.getBaseAttack());
+ newCard.setBaseDefense(card.getBaseDefense());
+
+ newCard.addSpellAbility(new Spell_Permanent(newCard));
+
+ return newCard;
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Shinka Gatekeeper"))
+ {
+ final Card newCard = new Card()
+ {
+ public void addDamage(final int n)
+ {
+ super.addDamage(n);
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(getController()).subtractLife(n);
+ }
+ };
+ ability.setStackDescription("Shinka Gatekeeper - causes " +n +" damage to " +getController());
+ AllZone.Stack.add(ability);
+ }//addDamage()
+ };//Card
+
+ newCard.setOwner(card.getOwner());
+ newCard.setController(card.getController());
+
+ newCard.setManaCost(card.getManaCost());
+ newCard.setName(card.getName());
+ newCard.addType("Creature");
+ newCard.addType("Ogre");
+ newCard.addType("Warrior");
+ newCard.setText(card.getSpellText());
+ newCard.setBaseAttack(card.getBaseAttack());
+ newCard.setBaseDefense(card.getBaseDefense());
+
+ newCard.addSpellAbility(new Spell_Permanent(newCard));
+
+ return newCard;
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Jackal Pup"))
+ {
+ final Card newCard = new Card()
+ {
+ public void addDamage(final int n)
+ {
+ super.addDamage(n);
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(getController()).subtractLife(n);
+ }
+ };
+ ability.setStackDescription("Jackal Pup - causes " +n +" damage to " +getController());
+ AllZone.Stack.add(ability);
+ }//addDamage()
+ };//Card
+
+ newCard.setOwner(card.getOwner());
+ newCard.setController(card.getController());
+
+ newCard.setManaCost(card.getManaCost());
+ newCard.setName(card.getName());
+ newCard.addType("Creature");
+ newCard.addType("Hound");
+ newCard.setText(card.getSpellText());
+ newCard.setBaseAttack(card.getBaseAttack());
+ newCard.setBaseDefense(card.getBaseDefense());
+
+ newCard.addSpellAbility(new Spell_Permanent(newCard));
+
+ return newCard;
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Stuffy Doll"))
+ {
+ final Card newCard = new Card()
+ {
+ Card c = this;
+ public void addDamage(final int n)
+ {
+ super.addDamage(n);
+ final String opponent = AllZone.GameAction.getOpponent(owner);
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(n);
+
+ if (c.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(c,n);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(c, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(c, n);
+ }
+ };
+ ability.setStackDescription("Stuffy Doll - causes " +n +" damage to " +opponent);
+ AllZone.Stack.add(ability);
+ }//addDamage()
+ };//Card
+
+ newCard.setOwner(card.getOwner());
+ newCard.setController(card.getController());
+
+ newCard.setManaCost(card.getManaCost());
+ newCard.setName(card.getName());
+ newCard.addType("Artifact");
+ newCard.addType("Creature");
+ newCard.addType("Construct");
+ newCard.setText("Whenever damage is dealt to Stuffy Doll, it deals that much damage to your opponent.");
+ newCard.setBaseAttack(0);
+ newCard.setBaseDefense(1);
+
+ newCard.addIntrinsicKeyword("Indestructible");
+
+ final Ability_Tap ability = new Ability_Tap(newCard)
+ {
+ private static final long serialVersionUID = 577739727089395613L;
+
+ public void resolve()
+ {
+ newCard.addDamage(1);
+
+ if (newCard.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(newCard, 1);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(newCard, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(newCard, 1);
+ }
+ };//SpellAbility
+ ability.setDescription("tap: Stuffy Doll deals 1 damage to itself.");
+ ability.setStackDescription("Stuffy Doll - deals 1 damage to itself.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+
+// card.addSpellAbility(ability);
+// return card;
+///*
+ newCard.addSpellAbility(new Spell_Permanent(newCard));
+ newCard.addSpellAbility(ability);
+
+ return newCard;
+//*/
+ }//*************** END ************ END **************************
+
+
+// computer plays 2 land of these type instead of just 1 per turn
+
+ //*************** START *********** START **************************
+ //Ravinca Duel Lands
+ if(cardName.equals("Blood Crypt") || cardName.equals("Breeding Pool") || cardName.equals("Godless Shrine") || cardName.equals("Hallowed Fountain") || cardName.equals("Overgrown Tomb") || cardName.equals("Sacred Foundry") || cardName.equals("Steam Vents") || cardName.equals("Stomping Ground") || cardName.equals("Temple Garden") || cardName.equals("Watery Grave"))
+ {
+ //if this isn't done, computer plays more than 1 copy
+ //card.clearSpellAbility();
+ card.clearSpellKeepManaAbility();
+
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 7352127748114888255L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ humanExecute();
+ else
+ computerExecute();
+ }
+ public void computerExecute()
+ {
+ boolean pay = false;
+
+ if(AllZone.Computer_Life.getLife() > 9)
+ pay = MyRandom.random.nextBoolean();
+
+ if(pay)
+ AllZone.Computer_Life.subtractLife(2);
+ else
+ card.tap();
+ }
+ public void humanExecute()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ if(2 < life.getLife())
+ {
+ String[] choices = {"Yes", "No"};
+ Object o = AllZone.Display.getChoice("Pay 2 life?", choices);
+ if(o.equals("Yes"))
+ life.subtractLife(2);
+ else
+ tapCard();
+ }//if
+ else
+ tapCard();
+ }//execute()
+ private void tapCard()
+ {
+ card.tap();
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kabira Crossroads"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = card;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(c.getController());
+ life.addLife(2);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -4550013855602477643L;
+
+ public void execute()
+ {
+ card.tap();
+ ability.setStackDescription(card.getName() + " - " +card.getController() +" gains 2 life");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Graypelt Refuge")|| cardName.equals("Sejiri Refuge")|| cardName.equals("Jwar Isle Refuge") ||
+ cardName.equals("Akoum Refuge")|| cardName.equals("Kazandu Refuge"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = card;
+ c.tap();
+ PlayerLife life = AllZone.GameAction.getPlayerLife(c.getController());
+ life.addLife(1);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 5055232386220487221L;
+
+ public void execute()
+ {
+ card.tap();
+ ability.setStackDescription(card.getName() + " - " +card.getController() +" gains 1 life");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Faerie Conclave"))
+ {
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 2792041290726604698L;
+
+ public void execute()
+ {
+ card.tap();
+ }
+ });
+
+ final Command eot1 = new Command()
+ {
+ private static final long serialVersionUID = 5106629534549783845L;
+
+ public void execute()
+ {
+ Card c = card;
+
+ c.setBaseAttack(0);
+ c.setBaseDefense(0);
+ c.removeIntrinsicKeyword("Flying");
+ c.removeType("Creature");
+ c.removeType("Faerie");
+ }
+ };
+
+ final SpellAbility a1 = new Ability(card, "1 U")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ Card c = card;
+
+ c.setBaseAttack(2);
+ c.setBaseDefense(1);
+
+ //to prevent like duplication like "Flying Flying Creature Creature"
+ if(! c.getIntrinsicKeyword().contains("Flying"))
+ {
+ c.addIntrinsicKeyword("Flying");
+ c.addType("Creature");
+ c.addType("Faerie");
+ }
+ AllZone.EndOfTurn.addUntil(eot1);
+ }
+ };//SpellAbility
+ card.setManaCost("U");
+
+ card.clearSpellKeepManaAbility();
+ card.addSpellAbility(a1);
+ a1.setDescription("1U: Faerie Conclave becomes a 2/1 blue Faerie creature with flying until end of turn. It's still a land.");
+ a1.setStackDescription(card +" becomes a 2/1 creature with flying until EOT");
+
+ Command paid1 = new Command() {
+ private static final long serialVersionUID = -601119544294387668L;
+ public void execute() {AllZone.Stack.add(a1);}
+ };
+
+ a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Forbidding Watchtower"))
+ {
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 5212793782060828409L;
+
+ public void execute()
+ {
+ card.tap();
+ }
+ });
+
+ final Command eot1 = new Command()
+ {
+ private static final long serialVersionUID = 8806880921707550181L;
+
+ public void execute()
+ {
+ Card c = card;
+
+ c.setBaseAttack(0);
+ c.setBaseDefense(0);
+ c.removeType("Creature");
+ c.removeType("Soldier");
+ }
+ };
+
+ final SpellAbility a1 = new Ability(card, "1 W")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ Card c = card;
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(5);
+
+ //to prevent like duplication like "Creature Creature"
+ if(! c.getType().contains("Creature"))
+ {
+ c.addType("Creature");
+ c.addType("Soldier");
+ }
+ AllZone.EndOfTurn.addUntil(eot1);
+ }
+ };//SpellAbility
+
+ card.clearSpellKeepManaAbility();
+ card.addSpellAbility(a1);
+ a1.setStackDescription(card +" becomes a 1/5 creature until EOT");
+
+ Command paid1 = new Command() {
+ private static final long serialVersionUID = -7211256926392695778L;
+ public void execute() {AllZone.Stack.add(a1);}
+ };
+
+ a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Treetop Village"))
+ {
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = -2246560994818997231L;
+
+ public void execute()
+ {
+ card.tap();
+ }
+ });
+
+ final Command eot1 = new Command()
+ {
+ private static final long serialVersionUID = -8535770979347971863L;
+
+ public void execute()
+ {
+ Card c = card;
+
+ c.setBaseAttack(0);
+ c.setBaseDefense(0);
+ c.removeType("Creature");
+ c.removeType("Ape");
+ c.removeIntrinsicKeyword("Trample");
+ }
+ };
+
+ final SpellAbility a1 = new Ability(card, "1 G")
+ {
+ public boolean canPlayAI()
+ {
+ return ! card.getType().contains("Creature");
+ }
+ public void resolve()
+ {
+ Card c = card;
+
+ c.setBaseAttack(3);
+ c.setBaseDefense(3);
+
+ //to prevent like duplication like "Creature Creature"
+ if(! c.getIntrinsicKeyword().contains("Trample"))
+ {
+ c.addType("Creature");
+ c.addType("Ape");
+ c.addIntrinsicKeyword("Trample");
+ }
+ AllZone.EndOfTurn.addUntil(eot1);
+ }
+ };//SpellAbility
+
+ card.clearSpellKeepManaAbility();
+ card.addSpellAbility(a1);
+ a1.setStackDescription(card +" becomes a 3/3 creature with trample until EOT");
+
+ Command paid1 = new Command() {
+ private static final long serialVersionUID = -6800983290478844750L;
+
+ public void execute() {AllZone.Stack.add(a1);}
+ };
+
+ a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
+
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Serra Avenger"))
+ {
+ SpellAbility spell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -1148518222979323313L;
+
+ public boolean canPlay()
+ {
+ return super.canPlay() && 6 < AllZone.Phase.getTurn();
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }
+ //*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Force of Savagery"))
+ {
+ SpellAbility spell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 1603238129819160467L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+
+ return list.containsName("Glorious Anthem") || list.containsName("Gaea's Anthem");
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }
+ //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pyrohemia"))
+ {
+ SpellAbility ability = new Ability(card, "R")
+ {
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ return AllZone.Computer_Life.getLife() > 2 && !(human.size() == 0 && 0 < computer.size());
+ }
+ public void resolve()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++){
+ if (CardFactoryUtil.canDamage(card, list.get(i)))
+ list.get(i).addDamage(1);
+ }
+
+ AllZone.Human_Life.subtractLife(1);
+ AllZone.Computer_Life.subtractLife(1);
+ }//resolve()
+ };//SpellAbility
+ ability.setDescription("R: Pyrohemia deals 1 damage to each creature and each player.");
+ ability.setStackDescription(card +" deals 1 damage to each creature and each player.");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 5596915641671666843L;
+
+ public boolean canPlayAI()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ return 0 < list.size();
+ }
+ });
+
+ card.addSpellAbility(ability);
+ }
+ //*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pestilence"))
+ {
+ SpellAbility ability = new Ability(card, "B")
+ {
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ return AllZone.Computer_Life.getLife() > 2 && !(human.size() == 0 && 0 < computer.size());
+ }
+ public void resolve()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++) {
+ if (CardFactoryUtil.canDamage(card, list.get(i)))
+ list.get(i).addDamage(1);
+ }
+
+ AllZone.Human_Life.subtractLife(1);
+ AllZone.Computer_Life.subtractLife(1);
+ }//resolve()
+ };//SpellAbility
+ ability.setDescription("B: Pestilence deals 1 damage to each creature and each player.");
+ ability.setStackDescription(card +" deals 1 damage to each creature and each player.");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -4163089323122672307L;
+
+ public boolean canPlayAI()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ return 0 < list.size();
+ }
+ });
+
+ card.addSpellAbility(ability);
+ }
+ //*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Greater Forgeling"))
+ {
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -4569751606008597903L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addTempAttackBoost(-3);
+ card.addTempDefenseBoost(3);
+ }
+ }
+ };
+
+ SpellAbility ability = new Ability(card, "1 R")
+ {
+ public boolean canPlayAI()
+ {
+ return MyRandom.random.nextBoolean() && CardFactoryUtil.AI_doesCreatureAttack(card) &&
+ 3 < card.getNetDefense();
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addTempAttackBoost(3);
+ card.addTempDefenseBoost(-3);
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+ ability.setDescription("1 R: Greater Forgeling gets +3/-3 until end of turn.");
+ ability.setStackDescription(card +" gets +3/-3 until end of turn.");
+ card.addSpellAbility(ability);
+ }
+ //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Liliana Vess"))
+ {
+ //computer only plays ability 1 and 3, discard and return creature from graveyard to play
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY,n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 5);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability2
+ final SpellAbility ability2 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 2);
+ turn[0] = AllZone.Phase.getTurn();
+
+ String player = card2.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ CardList creature = new CardList(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ if(creature.size() != 0)
+ {
+ Card c = creature.get(0);
+ AllZone.GameAction.shuffle(card2.getController());
+
+ //move to top of library
+ AllZone.Computer_Library.remove(c);
+ AllZone.Computer_Library.add(c, 0);
+ }
+ }//computerResolve()
+ public void humanResolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ CardList list = new CardList(library.getCards());
+
+ if(list.size() != 0)
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select any card", list.toArray());
+
+ AllZone.GameAction.shuffle(card2.getController());
+ if(o != null)
+ {
+ //put creature on top of library
+ library.remove(o);
+ library.add((Card)o, 0);
+ }
+ }//if
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
+
+ return 2 <= card2.getCounters(Counters.LOYALTY) &&
+ AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ 1 < library.size() &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 5726590384281714755L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability2);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability3
+ final SpellAbility ability3 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.subtractCounter(Counters.LOYALTY, 8);
+ turn[0] = AllZone.Phase.getTurn();
+
+ //get all graveyard creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+ list = list.getType("Creature");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
+ PlayerZone grave = null;
+ Card c = null;
+ for(int i = 0; i < list.size(); i++)
+ {
+ //this is a rough hack, but no one will ever see this code anyways, lol ;+)
+ c = list.get(i);
+ c.setController(card.getController());
+
+ grave = AllZone.getZone(c);
+ if(grave != null)
+ grave.remove(c);
+
+ play.add(c);
+ }
+ }
+ public boolean canPlay()
+ {
+ return 8 <= card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+ list = list.getType("Creature");
+
+ return 3 < list.size();
+ }
+ };
+ ability3.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -3297439284172874241L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+ AllZone.Stack.push(ability3);
+ }
+ stop();
+ }//showMessage()
+ });
+
+ //ability 1
+ final SpellAbility ability1 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.addCounter(Counters.LOYALTY,1);
+ turn[0] = AllZone.Phase.getTurn();
+
+ String s = getTargetPlayer();
+ setStackDescription("Liliana Vess - " +s +" discards a card");
+
+ if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ else
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ public boolean canPlayAI()
+ {
+ if(ability3.canPlay() && ability3.canPlayAI())
+ return false;
+ else
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return true;
+ }
+ }
+ public boolean canPlay()
+ {
+ return 0 < card2.getCounters(Counters.LOYALTY) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
+ turn[0] != AllZone.Phase.getTurn() &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ };//SpellAbility ability1
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 4997055112713151705L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target player");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectPlayer(String player)
+ {
+ turn[0] = AllZone.Phase.getTurn();
+ ability1.setTargetPlayer(player);
+ AllZone.Stack.add(ability1);
+ stop();
+ }
+ };//Input target
+ ability1.setBeforePayMana(target);
+ ability1.setDescription("+1: Target player discards a card.");
+ card2.addSpellAbility(ability1);
+
+ ability2.setDescription("-2: Search your library for a card, then shuffle your library and put that card on top of it.");
+ ability2.setStackDescription("Liliana Vess - Search your library for a card, then shuffle your library and put that card on top of it.");
+ card2.addSpellAbility(ability2);
+
+ ability3.setDescription("-8: Put all creature cards in all graveyards into play under your control.");
+ ability3.setStackDescription("Liliana Vess - Put all creature cards in all graveyards into play under your control.");
+ card2.addSpellAbility(ability3);
+
+ return card2;
+ }
+ //*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Chandra Nalaar"))
+ {
+ //computer only plays ability 1 and 3, discard and return creature from graveyard to play
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Card card2 = new Card()
+ {
+ public void addDamage(int n)
+ {
+ subtractCounter(Counters.LOYALTY, n);
+ AllZone.GameAction.checkStateEffects();
+ }
+ };
+ card2.addCounter(Counters.LOYALTY, 6);
+
+ card2.setOwner(owner);
+ card2.setController(owner);
+
+ card2.setName(card.getName());
+ card2.setType(card.getType());
+ card2.setManaCost(card.getManaCost());
+ card2.addSpellAbility(new Spell_Permanent(card2));
+
+ //ability 1
+ final SpellAbility ability1 = new Ability(card2, "0")
+ {
+ public void resolve()
+ {
+ card2.addCounter(Counters.LOYALTY, 1);
+ turn[0] = AllZone.Phase.getTurn();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card2,getTargetCard()))
+ {
+ Card c = getTargetCard();
+ if (CardFactoryUtil.canDamage(card2, c))
+ c.addDamage(1);
+ }
+ }
+
+ else
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(getTargetPlayer());
+ life.subtractLife(1);
+ }
+ }
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i= 4 && AllZone.Phase.getPhase().equals(Constant.Phase.Main1) &&
+ AllZone.Phase.getActivePlayer().equals(card2.getController());
+ }
+ };//SpellAbility ability3
+ Input runtime3 = new Input()
+ {
+ private static final long serialVersionUID = 7697504647440222302L;
+
+ int check = -1;
+ public void showMessage()
+ {
+ if(check != AllZone.Phase.getTurn())
+ {
+ check = AllZone.Phase.getTurn();
+ turn[0] = AllZone.Phase.getTurn();
+
+ AllZone.Stack.push(ability3);
+ stop();
+ }
+ }
+ };//Input
+ ability3.setStackDescription(card2.getName() +" - Creatures you control get +3/+3 and trample until end of turn.");
+ ability3.setDescription("-4: Creatures you control get +3/+3 and trample until end of turn.");
+ ability3.setBeforePayMana(runtime3);
+ card2.addSpellAbility(ability3);
+ //end ability 3
+
+ return card2;
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Caller of the Claw"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ int stop = countGraveyard();
+ for(int i = 0; i < stop; i++)
+ makeToken();
+ }//resolve()
+ int countGraveyard()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList list = new CardList(grave.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && (c.getTurnInZone() == AllZone.Phase.getTurn());
+ }
+ });
+ return list.size();
+ }//countGraveyard()
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setImageName("G 2 2 Bear");
+ c.setName("Bear");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Bear");
+ c.setBaseAttack(2);
+ c.setBaseDefense(2);
+
+ play.add(c);
+ }//makeToken()
+ };//SpellAbility
+
+ Command comesIntoPlay = new Command()
+ {
+ private static final long serialVersionUID = 8485080996453793968L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+ }
+ };//Command
+ ability.setStackDescription("Caller of the Claw - Put a 2/2 green Bear creature token into play for each nontoken creature put into your graveyard from play this turn.");
+ card.addComesIntoPlayCommand(comesIntoPlay);
+
+ SpellAbility spell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 6946020026681536710L;
+
+ public boolean canPlayAI() {return super.canPlay();}
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kiki-Jiki, Mirror Breaker"))
+ {
+ final SpellAbility ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -943706942500499644L;
+
+ public boolean canPlayAI() {return getCreature().size() != 0;}
+ public void chooseTargetAI()
+ {
+ setTargetCard(getCreature().get(0));
+ }
+ CardList getCreature()
+ {
+ CardList list = null;
+ if(card.getController().equals(Constant.Player.Human)){
+ list = new CardList(AllZone.Human_Play.getCards());
+ }
+ else{
+ list = new CardList(AllZone.Computer_Play.getCards());
+ }
+
+ list = list.getType("Creature");
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (!c.getType().contains("Legendary") );
+ }
+ });
+ CardListUtil.sortAttack(list);
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && getTargetCard().getController().equals(card.getController())
+ && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ Card copy;
+ if (!getTargetCard().isToken())
+ {
+ //copy creature and put it into play
+ copy = getCard(getTargetCard().getName(), card.getController());
+ copy.setToken(true);
+
+ if (getTargetCard().isFaceDown()) {
+ copy.setIsFaceDown(true);
+ copy.setManaCost("");
+ copy.setBaseAttack(2);
+ copy.setBaseDefense(2);
+ copy.setIntrinsicKeyword(new ArrayList()); //remove all keywords
+ copy.setType(new ArrayList()); //remove all types
+ copy.addType("Creature");
+ copy.clearSpellAbility(); //disallow "morph_up"
+ }
+ copy.addIntrinsicKeyword("Haste");
+ }
+ else //isToken()
+ {
+ Card c = getTargetCard();
+ copy = new Card();
+
+ copy.setName(c.getName());
+
+ copy.setOwner(c.getController());
+ copy.setController(c.getController());
+
+ copy.setManaCost(c.getManaCost());
+ copy.setToken(true);
+
+ copy.setType(c.getType());
+
+ copy.setBaseAttack(c.getBaseAttack());
+ copy.setBaseDefense(c.getBaseDefense());
+ copy.addIntrinsicKeyword("Haste");
+ }
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(copy);
+
+
+ //have to do this since getTargetCard() might change
+ //if Kiki-Jiki somehow gets untapped again
+ final Card[] target = new Card[1];
+ target[0] = copy;
+ Command atEOT = new Command()
+ {
+ private static final long serialVersionUID = 7803915905490565557L;
+ public void execute()
+ {
+ //technically your opponent could steal the token
+ //and the token shouldn't be sacrificed
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ AllZone.GameAction.sacrifice(target[0]); //maybe do a setSacrificeAtEOT, but probably not.
+ }
+ };//Command
+ AllZone.EndOfTurn.addAt(atEOT);
+ }//is card in play?
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 7171284831370490875L;
+
+ public void showMessage()
+ {
+ //get all non-legendary creatures you control
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() &&
+ (!c.getType().contains("Legendary"));
+ }
+ });
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, list, "Select target creature to copy that is not legendary.", true));
+ }
+ };//Input
+ ability.setStackDescription("Kiki-Jiki - copy card.");
+ ability.setDescription("tap: Put a token into play that's a copy of target nonlegendary creature you control. That creature token has haste. Sacrifice it at end of turn.");
+ ability.setBeforePayMana(runtime);
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Nevinyrral's Disk"))
+ {
+ SpellAbility summoningSpell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -8859376851358601934L;
+
+ public boolean canPlayAI()
+ {
+ boolean nevinyrralInPlay = false;
+
+ CardList inPlay = new CardList();
+ inPlay.addAll(AllZone.Computer_Play.getCards());
+ for(int i=0; i 0 &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main2) || AllZone.Phase.getPhase().equals(Constant.Phase.Main1))
+ && AllZone.GameAction.isCardInPlay(card) && CardFactoryUtil.canUseAbility(card);
+ }
+ public void resolve()
+ {
+
+ String player = card.getController();
+
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+
+ CardList lands = new CardList(hand.getCards());
+ lands = lands.getType("Land");
+
+ if (lands.size() > 0)
+ {
+ if (player.equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select land to play", lands.toArray());
+ if (o!=null)
+ {
+ Card c = (Card)o;
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ else
+ {
+ Card c = lands.get(0);
+ hand.remove(c);
+ play.add(c);
+ }
+ card.setAbilityUsed(card.getAbilityUsed()+1);
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("You may play two additional lands on each of your turns.");
+ ability.setStackDescription(card.getName() + " - " + card.getController() + " plays an additional land.");
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Exploration"))
+ {
+ final int turn[] = new int[1];
+ turn[0] = -1;
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0 &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main2) || AllZone.Phase.getPhase().equals(Constant.Phase.Main1))
+ && AllZone.GameAction.isCardInPlay(card) && turn[0] != AllZone.Phase.getTurn();
+ }
+ public void resolve()
+ {
+ turn[0] = AllZone.Phase.getTurn();
+ String player = card.getController();
+
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+
+ CardList lands = new CardList(hand.getCards());
+ lands = lands.getType("Land");
+
+ if (lands.size() > 0)
+ {
+ if (player.equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select land to play", lands.toArray());
+ if (o!=null)
+ {
+ Card c = (Card)o;
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ else
+ {
+ Card c = lands.get(0);
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("You may play an additional land each of your turns.");
+ ability.setStackDescription(card.getName() + " - " + card.getController() + " plays an additional land.");
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Fastbond"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ if(AllZone.GameAction.getPlayerLife(Constant.Player.Computer).getLife() > 4)
+ return true;
+ else
+ return false;
+ }
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0 &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main2) || AllZone.Phase.getPhase().equals(Constant.Phase.Main1))
+ && AllZone.GameAction.isCardInPlay(card);
+ }
+ public void resolve()
+ {
+ String player = card.getController();
+
+
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList fastbonds = new CardList(play.getCards());
+ fastbonds = fastbonds.getName("Fastbond"); //do this, because if there are more in play, fastbond will deal more damage per land
+
+ AllZone.GameAction.getPlayerLife(player).subtractLife(fastbonds.size());
+
+ CardList lands = new CardList(hand.getCards());
+ lands = lands.getType("Land");
+
+ if (lands.size() > 0)
+ {
+ if (player.equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select land to play", lands.toArray());
+ if (o!=null)
+ {
+ Card c = (Card)o;
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ else
+ {
+ Card c = lands.get(0);
+ hand.remove(c);
+ play.add(c);
+
+ }
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("You may play as many lands as you choose on your turn. Whenever you play a land other than the first land of the turn, Fastbond deals 1 damage to you.");
+ ability.setStackDescription(card.getName() + " - deals damage to " + card.getController() + ", plays another land.");
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wellwisher"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = 1446529067071763247L;
+
+ public boolean canPlay()
+ {
+ setStackDescription(card.getName() +" - " +card.getController() +" gains " +countElf() +" life.");
+
+ return super.canPlay();
+ }
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(countElf());
+ }
+ int countElf()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Elf");
+ return list.size();
+ }
+ };//SpellAbility
+ ability.setDescription("tap: You gain 1 life for each Elf in play.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility((Ability_Tap) ability));
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sliver Overlord"))
+ {
+ //final String player = card.getController();
+ final SpellAbility ability = new Ability(card, "3")
+ {
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0)
+ return true;
+ else
+ return false;
+
+ }
+
+
+ public void resolve()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ String player = card.getController();
+
+ CardList list = new CardList(lib.getCards());
+ list = list.getType("Sliver");
+
+ if (list.size()==0)
+ return;
+
+ if (player.equals(Constant.Player.Computer))
+ {
+ Card sliver = CardFactoryUtil.AI_getBestCreature(list);
+ lib.remove(sliver);
+ hand.add(sliver);
+ }
+ else //human
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target Sliver", list.toArray());
+ Card sliver = (Card)o;
+ lib.remove(sliver);
+ hand.add(sliver);
+ }
+ AllZone.GameAction.shuffle(player);
+ }
+ };
+
+ final SpellAbility ability2 = new Ability(card, "3")
+ {
+
+ public void resolve()
+ {
+
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && (c.getType().contains("Sliver") || c.getKeyword().contains("Changeling") )
+ && CardFactoryUtil.canTarget(card,c) )
+ {
+ //set summoning sickness
+ if(c.getKeyword().contains("Haste")){
+ c.setSickness(false);
+ }
+ else{
+ c.setSickness(true);
+ }
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone from = AllZone.getZone(c);
+ from.remove(c);
+
+ c.setController(card.getController());
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController());
+ to.add(c);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }//if
+
+
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+
+ CardList c = CardFactoryUtil.AI_getHumanCreature(card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+ c = c.filter(new CardListFilter(){
+
+ public boolean addCard(Card c) {
+ return c.getType().contains("Sliver") || c.getKeyword().contains("Changeling");
+ }
+
+ });
+
+ if(c.isEmpty())
+ return false;
+
+ if(2 <= c.get(0).getNetAttack() && c.get(0).getKeyword().contains("Flying") &&
+ c.get(0).getKeyword().contains("Sliver"))
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ CardListUtil.sortAttack(c);
+ if(4 <= c.get(0).getNetAttack() && c.get(0).getKeyword().contains("Sliver"))
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ return false;
+ }//canPlayAI()
+
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card);
+
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = 1489433384490805477L;
+
+ public void showMessage()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ CardList slivers = new CardList(AllZone.getZone(Constant.Zone.Play, opponent).getCards());
+ slivers = slivers.getType("Sliver");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability2, slivers, "Select a Sliver", true));
+ }
+ });
+
+ ability.setDescription("3:Search your library for a Sliver card, reveal that card, and put it into your hand. Then shuffle your library.");
+ ability.setStackDescription(card.getName() +" - search for a Sliver card and put it into your hand.");
+
+ ability2.setDescription("3:Gain control of target Sliver.");
+ ability.setStackDescription(card.getName() +" - Gain control of target Sliver.");
+
+ card.addSpellAbility(ability);
+ card.addSpellAbility(ability2);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sliver Queen"))
+ {
+ final SpellAbility a1 = new Ability(card, "2")
+ {
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ //this is a hack, check the stack to see if this card has an ability on the stack
+ //if so, we can't use the ability
+ for (int i=0; i 0 && CardFactoryUtil.canTarget(card, c);
+ }
+ });
+ perms.shuffle();
+ setTargetCard(perms.get(0)); //TODO: improve this.
+ }
+
+ public boolean canPlayAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList perms = new CardList(play.getCards());
+ perms = perms.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.sumAllCounters() > 0;
+ }
+ });
+ return perms.size() > 0;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 1571239319226728848L;
+
+ public void showMessage()
+ {
+ PlayerZone human = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList perms = new CardList();
+ perms.addAll(human.getCards());
+ perms.addAll(comp.getCards());
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a1, perms, "Select target permanent.", true));
+ }
+ };
+
+ card.addSpellAbility(a1);
+ a1.setDescription("2 GU, Untap: For each counter on target permanent, put another of those counters on that permanent.");
+
+ a1.setBeforePayMana(runtime);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Order of Whiteclay"))
+ {
+ final SpellAbility a1 = new Ability(card,"1 W W")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList creats = new CardList(grave.getCards());
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return CardUtil.getConvertedManaCost(c.getManaCost()) <= 3;
+ }
+
+ });
+
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Choose a creature", creats.toArray());
+ if (o!=null)
+ {
+ Card c = (Card)o;
+ grave.remove(c);
+ play.add(c);
+ card.untap();
+ }
+ }
+ else //Computer
+ {
+ Card c = creats.get(0);
+ grave.remove(c);
+ play.add(c);
+ card.untap();
+ }
+
+ }
+
+ public boolean canPlay()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList creats = new CardList(grave.getCards());
+ creats = creats.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c)
+ {
+ return CardUtil.getConvertedManaCost(c.getManaCost()) <= 3;
+ }
+
+ });
+ if (card.isTapped() && !card.hasSickness() && creats.size() > 0)
+ return true;
+ else
+ return false;
+ }
+
+ public boolean canPlayAI()
+ {
+ return true;
+ }
+ };//SpellAbility
+ card.addSpellAbility(a1);
+ a1.setDescription("1 W W, Untap: Return target creature card with converted mana cost 3 or less from your graveyard to play.");
+ a1.setStackDescription(card.getName() + " - return target creature card with converted mana cost 3 or less from your graveyard to play.");
+
+ a1.setBeforePayMana(new Input_PayManaCost(a1));
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Patrol Signaler"))
+ {
+ final SpellAbility a1 = new Ability(card,"1 W")
+ {
+ public void resolve()
+ {
+ card.untap();
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+
+ c.setName("Kithkin Soldier");
+ c.setImageName("W 1 1 Kithkin Soldier");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Kithkin");
+ c.addType("Soldier");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i3;
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(summoningSpell);
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(3);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 2334517567512130479L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Serpent Warrior - "
+ +card.getController() +" loses 3 life");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Eviscerator"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(5);
+ }
+ public boolean canPlayAI()
+ {
+ return 8 < AllZone.Computer_Life.getLife();
+ }
+ };
+ Command intoPlay = new Command()
+ {
+
+ private static final long serialVersionUID = -221296021551561668L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Eviscerator - " +card.getController() +" loses 5 life");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Foul Imp"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+ }
+ public boolean canPlayAI()
+ {
+ return 4 < AllZone.Computer_Life.getLife();
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -5371716833341661084L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Foul Imp - " +card.getController() +" loses 2 life");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Drekavac"))
+ {
+ final Input discard = new Input()
+ {
+ private static final long serialVersionUID = -6392468000100283596L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Discard from your hand a non-creature card");
+ ButtonUtil.disableAll();
+ }
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Hand))
+ {
+ AllZone.GameAction.discard(c);
+ if(c.isCreature())
+ AllZone.GameAction.sacrifice(card);
+ stop();
+ }
+ }
+ };//Input
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ if(AllZone.Human_Hand.getCards().length == 0)
+ AllZone.GameAction.sacrifice(card);
+ else
+ AllZone.InputControl.setInput(discard);
+ }
+ else
+ {
+ CardList list = new CardList(AllZone.Computer_Hand.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (!c.isCreature());
+ }
+ });
+ AllZone.GameAction.discard(list.get(0));
+ }//else
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 9202753910259054021L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" sacrifices Drekavac unless he discards a non-creature card");
+ AllZone.Stack.add(ability);
+ }
+ };
+ SpellAbility spell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -2940969025405788931L;
+
+ //could never get the AI to work correctly
+ //it always played the same card 2 or 3 times
+ public boolean canPlayAI() {return false;}
+
+ public boolean canPlay()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ CardList list = new CardList(hand.getCards());
+ list.remove(card);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (!c.isCreature());
+ }
+ });
+ return list.size() != 0;
+ }//canPlay()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Minotaur Explorer"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ if(hand.getCards().length == 0)
+ AllZone.GameAction.sacrifice(card);
+ else
+ AllZone.GameAction.discardRandom(card.getController());
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 4986114285467649619L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" - discards at random or sacrifices Minotaur Explorer");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Goretusk Firebeast"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(4);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 2977308349468915040L;
+
+ public void execute()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ ability.setStackDescription("Goretusk Firebeast - deals 4 damage to " +opponent);
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Goblin Ringleader"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone libraryZone = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+
+ //get top 4 cards of the library
+ CardList top = new CardList();
+ Card[] library = libraryZone.getCards();
+ for(int i = 0; i < 4 && i < library.length; i++)
+ top.add(library[i]);
+
+ //put top 4 cards on bottom of library
+ for(int i = 0; i < top.size(); i++)
+ {
+ libraryZone.remove(top.get(i));
+ libraryZone.add(top.get(i));
+ }
+
+ CardList goblin = top.getType("Goblin");
+
+ for(int i = 0; i < goblin.size(); i++)
+ AllZone.GameAction.moveTo(hand, goblin.get(i));
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7538870520237796620L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+ }
+ };
+ ability.setStackDescription("Goblin Ringleader - reveal the top four cards of your library. Put all Goblin cards revealed this way into your hand and the rest on the bottom of your library.");
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sylvan Messenger"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone libraryZone = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+
+ //get top 4 cards of the library
+ CardList top = new CardList();
+ Card[] library = libraryZone.getCards();
+ for(int i = 0; i < 4 && i < library.length; i++)
+ top.add(library[i]);
+
+ //put top 4 cards on bottom of library
+ for(int i = 0; i < top.size(); i++)
+ {
+ libraryZone.remove(top.get(i));
+ libraryZone.add(top.get(i));
+ }
+
+ CardList goblin = top.getType("Elf");
+
+ for(int i = 0; i < goblin.size(); i++)
+ AllZone.GameAction.moveTo(hand, goblin.get(i));
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 4757054648163014149L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+ }
+ };
+ ability.setStackDescription("Sylvan Messenger - reveal the top four cards of your library. Put all Elf cards revealed this way into your hand and the rest on the bottom of your library.");
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Child of Alara"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+
+
+ for(int i = 0; i < list.size(); i++)
+ if(!list.get(i).getType().contains("Land"))
+ {
+ Card c = list.get(i);
+ AllZone.GameAction.destroyNoRegeneration(c);
+ }
+ }
+ };
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -2937565366066183385L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+ }
+ };
+ ability.setStackDescription("Child of Alara - Destroy all non-land permanents, they can't be regenerated");
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ryusei, the Falling Star"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+ for(int i = 0; i < list.size(); i++)
+ if(! list.get(i).getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card, list.get(i)))
+ list.get(i).addDamage(5);
+ }
+ };
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -6585074939675844265L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+ }
+ };
+ ability.setStackDescription("Ryusei, the Falling Star - deals 5 damage to each creature without flying");
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sleeper Agent"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve(){
+ @SuppressWarnings("unused") // opponent
+ String opponent = card.getController();
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone from = AllZone.getZone(card);
+ from.remove(card);
+
+ card.setController(AllZone.GameAction.getOpponent(card.getOwner()));
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, AllZone.GameAction.getOpponent(card.getOwner()));
+ to.add(card);
+ System.out.println("cards controller = " + card.getController());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ };
+
+ ability.setStackDescription("When Sleeper Agent comes into play, target opponent gains control of it.");
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -3934471871041458847L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(ability);
+
+ }//execute()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Flametongue Kavu"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ //get target card, may be null
+ public Object execute()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(4, card, true);
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ if(list.size() != 0)
+ {
+ Card c = list.get(0);
+ if(3 <= c.getNetAttack() ||
+ (2 <= c.getNetAttack() && c.getKeyword().contains("Flying")))
+ return c;
+ }
+ if((AllZone.Computer_Life.getLife() < 10) &&
+ (CardFactoryUtil.AI_getHumanCreature(card, true).size() != 0))
+ {
+ list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ return list.get(0);
+ }
+ return null;
+ }//execute()
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canDamage(card, getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ AllZone.GameAction.addDamage(getTargetCard(), 4);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -1920425335456952853L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ Object o = getCreature.execute();
+ if(o != null)//should never happen, but just in case
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ else {
+ ability.setTargetCard(card);
+ AllZone.Stack.add(ability);
+ }
+ }//else
+ }//execute()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 5741146386242415357L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+
+ return (o != null) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Shriekmaw"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ //get target card, may be null
+ public Object execute()
+ {
+ CardList nonblack = CardFactoryUtil.AI_getHumanCreature(card, true);
+ nonblack = nonblack.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return(!c.isArtifact() && !CardUtil.getColors(c).contains(Constant.Color.Black));
+ }
+ });
+
+ CardList list = new CardList(nonblack.toArray());
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ if(list.size() != 0)
+ {
+ Card c = list.get(0);
+ if(2 <= c.getNetAttack() && c.getKeyword().contains("Flying"))
+ return c;
+ }
+
+ if((AllZone.Computer_Life.getLife() < 10) && list.size() != 0)
+ {
+ CardListUtil.sortAttack(list);
+
+ if(MyRandom.percentTrue(50))
+ CardListUtil.sortFlying(list);
+
+ return list.get(0);
+ }
+ return null;
+ }//execute()
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c) &&
+ !CardUtil.getColors(c).contains(Constant.Color.Black) &&
+ !c.isArtifact())
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -70141932446179740L;
+
+ public void execute()
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 2634600975568025031L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target nonartifact, nonblack creature to destroy");
+ ButtonUtil.disableAll();
+ }
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(ability, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(card.isCreature() && zone.is(Constant.Zone.Play) &&
+ !card.isArtifact() && !CardUtil.getColors(card).contains(Constant.Color.Black))
+ {
+ ability.setTargetCard(card);
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }
+ };//Input target
+
+
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return(!c.isArtifact() && !CardUtil.getColors(c).contains(Constant.Color.Black));
+ }
+ });
+
+ if(list.size() != 0)
+ AllZone.InputControl.setInput(target);
+// AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ }
+ else//computer
+ {
+ Object o = getCreature.execute();
+ if(o != null)//should never happen, but just in case
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }//else
+ }//execute()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -7508374608705757486L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+
+ return (o != null) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ card.addSpellAbility(new Spell_Evoke(card, "1 B")
+ {
+ private static final long serialVersionUID = 6838065487515852527L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+
+ return (o != null) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Briarhorn"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ //get target card, may be null
+ public Object execute()
+ {
+ Combat combat = ComputerUtil.getAttackers();
+ Card[] c = combat.getAttackers();
+
+ if(c.length == 0)
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return(c.isCreature() && !c.hasSickness());
+ }
+ });
+
+ if(list.size() == 0)
+ return card;
+ else
+ {
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ for(int i = 0; i < list.size(); i++)
+ if(list.get(i).isUntapped())
+ return list.get(i);
+
+ return list.get(0);
+ }
+
+ }
+
+ return c[0];
+ }//execute()
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ final Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c))
+ {
+ c.addTempAttackBoost(3);
+ c.addTempDefenseBoost(3);
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = -5417966443737481535L;
+
+ public void execute()
+ {
+ c.addTempAttackBoost(-3);
+ c.addTempDefenseBoost(-3);
+ }
+ });
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -5497111036332352337L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ }
+ else//computer
+ {
+ Object o = getCreature.execute();
+ if(o != null)//should never happen, but just in case
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }//else
+ }//execute()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -681505091538444209L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+
+ return (o != null) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ card.addSpellAbility(new Spell_Evoke(card, "1 G")
+ {
+ private static final long serialVersionUID = 8565746177492779899L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ //because this card has Flash
+ public boolean canPlay()
+ {
+ if (!AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Inner-Flame Acolyte"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ //get target card, may be null
+ public Object execute()
+ {
+ Combat combat = ComputerUtil.getAttackers();
+ Card[] c = combat.getAttackers();
+ CardList list = new CardList();
+
+ if(c.length == 0)
+ {
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature();
+ }
+ });
+
+ if(list.size() == 0)
+ return card;
+ else
+ {
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ for(int i = 0; i < list.size(); i++)
+ if(list.get(i).isUntapped())
+ return list.get(i);
+
+ return list.get(0);
+ }
+ }
+
+ return c[0];
+ }//execute()
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ final Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c) )
+ {
+ c.addTempAttackBoost(2);
+ c.addExtrinsicKeyword("Haste");
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = -6478147896119509688L;
+
+ public void execute()
+ {
+ c.addTempAttackBoost(-2);
+ c.removeExtrinsicKeyword("Haste");
+ }
+ });
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -4514610171270596654L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ }
+ else//computer
+ {
+ Object o = getCreature.execute();
+ if(o != null)//should never happen, but just in case
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }//else
+ }//execute()
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 7153795935713327863L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+
+ return (o != null) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ card.addSpellAbility(new Spell_Evoke(card, "R")
+ {
+ private static final long serialVersionUID = 8173305091293824506L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Timetwister"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 505983020365091226L;
+
+ public void resolve()
+ {
+ discardDraw7(Constant.Player.Human);
+ discardDraw7(Constant.Player.Computer);
+ }//resolve()
+
+ void discardDraw7(String player)
+ {
+ // Discard hand into graveyard
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ Card[] c = hand.getCards();
+ for(int i = 0; i < c.length; i++)
+ AllZone.GameAction.discard(c[i]);
+
+ // Move graveyard into library
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
+ Card[] g = grave.getCards();
+ for (int i = 0; i < g.length; i++)
+ {
+ grave.remove(g[i]);
+ library.add(g[i],0);
+ }
+
+ // Shuffle library
+ AllZone.GameAction.shuffle(player);
+
+ // Draw seven cards
+ for(int i = 0; i < 7; i++)
+ AllZone.GameAction.drawCard(player);
+
+ library.remove(card);
+ grave.add(card);
+ }
+
+ // Simple, If computer has two or less playable cards remaining in hand play Timetwister
+ public boolean canPlayAI()
+ {
+ Card[] c = removeLand(AllZone.Computer_Hand.getCards());
+ return 2 >= c.length;
+ }
+ Card[] removeLand(Card[] in)
+ {
+ CardList c = new CardList(in);
+ c = c.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return !c.isLand();
+ }
+ });
+ return c.toArray();
+ }//removeLand()
+
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Slaughterhouse Bouncer"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canDamage(card, getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ getTargetCard().addDamage(3);
+ }
+ };
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = 1619442728548153928L;
+
+ public void execute()
+ {
+ //check to see if any other creatures in play
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ //check to see if any cards in hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ if(hand.getCards().length == 0 && list.size() != 0)
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ //1.try to get human creature with defense of 3
+ list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {return c.getNetDefense() == 3;}
+ });
+ //2.try to get human creature with defense of 2 or less
+ if(list.isEmpty())
+ list = CardFactoryUtil.AI_getHumanCreature(2, card, true);
+ //3.get any computer creature
+ if(list.isEmpty())
+ {
+ list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+ }
+ list.shuffle();
+ ability.setTargetCard(list.get(0));
+ AllZone.Stack.add(ability);
+ }
+ }//if ok to play
+ }//execute()
+ };//Command
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Undying Beast"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ card.setDamage(0);
+ card.setAssignedDamage(0);
+ card.untap();
+
+ //moves card to top of library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
+ library.add(card, 0);
+ }
+ };
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -318081458847722674L;
+
+ public void execute()
+ {
+ if(card.isToken())
+ return;
+
+ //remove from graveyard
+ PlayerZone grave = AllZone.getZone(card);
+ grave.remove(card);
+
+ ability.setStackDescription("Put Undying Beast on top of its owner's library.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Fire Imp") || cardName.equals("Corrupt Eunuchs"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canDamage(card, getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ getTargetCard().addDamage(2);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7639628386947162984L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(2, card, true);
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ if(list.isEmpty())
+ {
+ list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list.shuffle();
+ }
+
+ if (list.size() > 0)
+ ability.setTargetCard(list.get(0));
+ else
+ ability.setTargetCard(card);
+
+ AllZone.Stack.add(ability);
+ }//else
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 1731831041621831246L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ return (list.size() > 0) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Man-o'-War") || cardName.equals("Sun Ce, Young Conquerer"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ AllZone.getZone(c).remove(c);
+
+ if(! c.isToken())
+ {
+ Card newCard = AllZone.CardFactory.getCard(c.getName(), c.getOwner());
+ hand.add(newCard);
+ }
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7628289586347295144L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ Card human = CardFactoryUtil.AI_getBestCreature(CardFactoryUtil.AI_getHumanCreature(card, true));
+ ability.setTargetCard(human);
+
+
+ if (human == null)
+ ability.setTargetCard(card);
+
+ AllZone.Stack.add(ability);
+ }//else
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 2458286917800051358L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ return (list.size() > 0) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Keening Banshee"))
+ {
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+
+ public void resolve()
+ {
+ final Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c) )
+ {
+ c.addTempAttackBoost(-2);
+ c.addTempDefenseBoost(-2);
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = 8479364459667467780L;
+
+ public void execute()
+ {
+ c.addTempAttackBoost(2);
+ c.addTempDefenseBoost(2);
+ }
+ });
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 6283666887577455663L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetCreature(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(2, card, true);
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ if(list.isEmpty())
+ {
+ list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list.shuffle();
+ }
+
+ ability.setTargetCard(list.get(0));
+ AllZone.Stack.add(ability);
+ }//else
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -1893090545602255371L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ return (list.size() > 0) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Dragon Roost"))
+ {
+ final SpellAbility ability = new Ability(card, "5 R R")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setName("Dragon");
+ c.setImageName("R 5 5 Dragon");
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Dragon");
+ c.setBaseAttack(5);
+ c.setBaseDefense(5);
+ c.addIntrinsicKeyword("Flying");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };
+ ability.setDescription("5RR: Put a 5/5 red Dragon creature token with flying into play.");
+ ability.setStackDescription("Dragon Roost - Put a 5/5 red Dragon creature token with flying into play.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("The Hive"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "5")
+ {
+ private static final long serialVersionUID = -1091111822316858416L;
+
+ public void resolve()
+ {
+ Card c = new Card();
+ c.setName("Wasp");
+ c.setImageName("C 1 1 Wasp");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("");
+ c.setToken(true);
+
+ c.addType("Artifact");
+ c.addType("Creature");
+ c.addType("Insect");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Flying");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };
+ ability.setDescription("5, tap: Put a 1/1 Insect artifact creature token with flying named Wasp into play.");
+ ability.setStackDescription("The Hive - Put a 1/1 token with flying into play.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mobilization"))
+ {
+ final SpellAbility ability = new Ability(card, "2 W")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+ c.setName("Soldier");
+ c.setImageName("W 1 1 Soldier");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Soldier");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };
+ ability.setDescription("2W: Put a 1/1 white Soldier creature token into play.");
+ ability.setStackDescription("Mobilization - Put a 1/1 Soldier token into play.");
+ card.addSpellAbility(ability);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ant Queen"))
+ {
+ final SpellAbility ability = new Ability(card, "1 G")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+ c.setName("Insect");
+ c.setImageName("G 1 1 Insect");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Insect");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };
+ ability.setDescription("1 G: Put a 1/1 green Insect creature token onto the battlefield.");
+ ability.setStackDescription(card.getName() + " - Put a 1/1 green Insect token onto the battlefield.");
+ card.addSpellAbility(ability);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Centaur Glade"))
+ {
+ final SpellAbility ability = new Ability(card, "2 G G")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+ c.setName("Centaur");
+ c.setImageName("G 3 3 Centaur");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Centaur");
+
+ c.setBaseAttack(3);
+ c.setBaseDefense(3);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };
+ ability.setDescription("2GG: Put a 3/3 green Centaur creature token into play.");
+ ability.setStackDescription("Centaur Glade - Put a 3/3 token into play.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Eternal Witness"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 1658050744890095441L;
+
+ public void execute()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+
+ if(grave.getCards().length == 0)
+ return;
+
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target card", grave.getCards());
+ if(o != null)
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }
+ else//computer
+ {
+ CardList list = new CardList(grave.getCards());
+ Card best = CardFactoryUtil.AI_getBestCreature(list);
+
+ if(best == null)
+ {
+ list.shuffle();
+ best = list.get(0);
+ }
+ ability.setTargetCard(best);
+ AllZone.Stack.add(ability);
+ }
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Gravedigger"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7433708170033536384L;
+
+ public void execute()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList list = new CardList(grave.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return;
+
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target card", list.toArray());
+ if(o != null)
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }//if
+ else//computer
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(list);
+ ability.setTargetCard(best);
+ AllZone.Stack.add(ability);
+ }
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Strongarm Thug"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 4519970074391756730L;
+
+ public void execute()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList list = new CardList(grave.getCards());
+ list = list.getType("Mercenary");
+
+ if(list.isEmpty())
+ return;
+
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target card", list.toArray());
+ if(o != null)
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }//if
+ else//computer
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(list);
+ ability.setTargetCard(best);
+ AllZone.Stack.add(ability);
+ }
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START ************************
+ if (cardName.equals("Aedun Oakenshield"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "B R G")
+ {
+ private static final long serialVersionUID = -7913968639880781838L;
+ public boolean canPlayAI() {return getGraveCreatures().size() != 0;}
+
+ public void chooseTargetAI()
+ {
+ CardList grave = getGraveCreatures();
+ Card target = CardFactoryUtil.AI_getBestCreature(grave);
+ setTargetCard(target);
+ }
+
+ public void resolve()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ Card c = (Card) AllZone.Display.getChoice("Select card", getGraveCreatures().toArray());
+ setTargetCard(c);
+ }
+
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getGraveCreatures().size() != 0;
+ }
+ CardList getGraveCreatures()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList list = new CardList(grave.getCards());
+ list = list.getType("Creature");
+ return list;
+ }
+ };//SpellAbility
+ ability.setDescription("B R G, Tap: Return target creature card from your graveyard to your hand.");
+ ability.setStackDescription(cardName + " - return target creature from your graveyard to your hand.");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(ability);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Raise Dead") || cardName.equals("Disentomb") || cardName.equals("Return to Battle") ||
+ cardName.equals("Recover"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5822375745105110975L;
+ public boolean canPlayAI() {return getGraveCreatures().size() != 0;}
+
+ public void chooseTargetAI()
+ {
+ CardList grave = getGraveCreatures();
+ Card target = CardFactoryUtil.AI_getBestCreature(grave);
+ setTargetCard(target);
+ }
+
+ public void resolve()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ Card c = (Card) AllZone.Display.getChoice("Select card", getGraveCreatures().toArray());
+ setTargetCard(c);
+ }
+
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getGraveCreatures().size() != 0;
+ }
+ CardList getGraveCreatures()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList list = new CardList(grave.getCards());
+ list = list.getType("Creature");
+ return list;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Anarchist"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), grave))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7459412502903144952L;
+
+ public void execute()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ CardList sorcery = new CardList(grave.getCards());
+ sorcery = sorcery.getType("Sorcery");
+
+ String controller = card.getController();
+
+ if(sorcery.size() == 0)
+ return;
+
+ if(controller.equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target card", sorcery.toArray());
+ if(o != null)
+ {
+ ability.setTargetCard((Card)o);
+ AllZone.Stack.add(ability);
+ }
+ }
+ else //computer
+ {
+ sorcery.shuffle();
+ ability.setTargetCard(sorcery.get(0));
+ AllZone.Stack.add(ability);
+ }
+
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Penumbra Kavu"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Kavu");
+ c.setImageName("B 3 3 Kavu");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Kavu");
+ c.setBaseAttack(3);
+ c.setBaseDefense(3);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//Ability
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = 1281791927604583468L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" puts a 3/3 creature into play from Penumbra Kavu");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Penumbra Bobcat"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Cat");
+ c.setImageName("B 2 1 Cat");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Cat");
+ c.setBaseAttack(2);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//Ability
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -8057009255325020247L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" puts a 2/1 creature into play from Penumbra Bobcat");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Penumbra Spider"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Spider");
+ c.setImageName("B 2 4 Spider");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Spider");
+ c.setBaseAttack(2);
+ c.setBaseDefense(4);
+ c.addIntrinsicKeyword("Reach");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//Ability
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = 9186718803540678064L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" puts a 2/4 Black Spider creature into play from Penumbra Spider");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Penumbra Wurm"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Wurm");
+ c.setImageName("B 6 6 Wurm");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Wurm");
+ c.setBaseAttack(6);
+ c.setBaseDefense(6);
+ c.addIntrinsicKeyword("Trample");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//Ability
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -8819664543962631239L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" puts a 6/6 Black Wurm creature with trample into play from Penumbra Wurm");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Aven Fisher") || cardName.equals("Riptide Crab"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -2786138225183288814L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName() + " - " + card.getController() +" draws a card");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Peregrine Drake"))
+ {
+ final Input untap = new Input()
+ {
+ private static final long serialVersionUID = 2287264826189281795L;
+
+ int stop = 5;
+ int count = 0;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select a land to untap");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card.isLand() && zone.is(Constant.Zone.Play))
+ {
+ card.untap();
+ count++;
+ if(count == stop)
+ stop();
+ }
+ }//selectCard()
+ };
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(card.getController().equals("Human"))
+ AllZone.InputControl.setInput(untap);
+ else
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isLand() && c.isTapped();
+ }
+ });
+ for(int i = 0; i < 5 && i < list.size(); i++)
+ list.get(i).untap();
+ }//else
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 3208277692165539396L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" untaps up to 5 lands.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cloud of Faeries"))
+ {
+ final Input untap = new Input()
+ {
+ private static final long serialVersionUID = -2167059918040912025L;
+
+ int stop = 2;
+ int count = 0;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select a land to untap");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card.isLand() && zone.is(Constant.Zone.Play))
+ {
+ card.untap();
+ count++;
+ if(count == stop)
+ stop();
+ }
+ }//selectCard()
+ };
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(card.getController().equals("Human"))
+ AllZone.InputControl.setInput(untap);
+ else
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isLand() && c.isTapped();
+ }
+ });
+ for(int i = 0; i < 2 && i < list.size(); i++)
+ {
+ list.get(i).untap();
+ }
+ }//else
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 7222997838166323277L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" untaps up to 2 lands.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ //add cycling
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2"));
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Vodalian Merchant"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+
+ if(card.getController().equals("Human"))
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ else
+ AllZone.GameAction.discardRandom("Computer");
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -8924243774757009091L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" draws a card, then discards a card");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Whirlpool Rider"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //shuffle hand into library, then shuffle library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+ Card c[] = hand.getCards();
+ for(int i = 0; i < c.length; i++)
+ AllZone.GameAction.moveTo(library, c[i]);
+ AllZone.GameAction.shuffle(card.getController());
+
+ //draw same number of cards as before
+ for(int i = 0; i < c.length; i++)
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 6290392806910817877L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getController() +" shuffles the cards from his hand into his library, then draws that many cards.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sky Swallower"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ String opp = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone oppPlay = AllZone.getZone(Constant.Zone.Play, opp);
+ PlayerZone myPlay = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ CardList list = new CardList(myPlay.getCards());
+ list.remove(card);//doesn't move Sky Swallower
+ while(! list.isEmpty())
+ {
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+ //so "comes into play" abilities don't trigger
+ ///list.get(0).addComesIntoPlayCommand(Command.Blank);
+
+ oppPlay.add(list.get(0));
+ myPlay.remove(list.get(0));
+
+ list.get(0).setController(opp);
+ list.remove(0);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ }//resolve()
+ };
+
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -453410206437839334L;
+
+ public void execute()
+ {
+ ability.setStackDescription(AllZone.GameAction.getOpponent(card.getController()) +" gains control of all other permanents you control");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Terror"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8809370679594989382L;
+
+ public boolean canPlayAI()
+ {
+ return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(best);
+ }
+ CardList getCreature()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (! CardUtil.getColors(c).contains(Constant.Color.Black)) &&
+ (! c.getType().contains("Artifact")) &&
+ (2 < c.getNetAttack());
+ }
+ });
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }//resolve()
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -1750678113925588670L;
+
+ public void showMessage()
+ {
+ CardList choice = new CardList();
+ choice.addAll(AllZone.Human_Play.getCards());
+ choice.addAll(AllZone.Computer_Play.getCards());
+
+ choice = choice.getType("Creature");
+ choice = choice.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (! CardUtil.getColors(c).contains(Constant.Color.Black)) &&
+ (! c.getType().contains("Artifact"));
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, choice, "Select target non-artifact, non-black creature to destroy.", true));
+ }
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(runtime);
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Expunge"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5773953475935635628L;
+
+ public boolean canPlayAI()
+ {
+ return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(best);
+ }
+ CardList getCreature()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (! CardUtil.getColors(c).contains(Constant.Color.Black)) &&
+ (! c.getType().contains("Artifact")) &&
+ (2 < c.getNetAttack());
+ }
+ });
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }//resolve()
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 3015711791310250186L;
+
+ public void showMessage()
+ {
+ CardList choice = new CardList();
+ choice.addAll(AllZone.Human_Play.getCards());
+ choice.addAll(AllZone.Computer_Play.getCards());
+
+ choice = choice.getType("Creature");
+ choice = choice.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (! CardUtil.getColors(c).contains(Constant.Color.Black)) &&
+ (! c.getType().contains("Artifact"));
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, choice, "Select target non-artifact, non-black creature to destroy.", true));
+ }
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(runtime);
+
+ spell.setDescription(card.getText());
+ card.addSpellAbility(spell);
+
+
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2"));
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pongify"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7657135492744577568L;
+
+ public boolean canPlayAI()
+ {
+ return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(best);
+ }
+ CardList getCreature()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (3 < c.getNetAttack());
+ }
+ });
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ PlayerZone play = AllZone.getZone(getTargetCard());
+ makeToken(play, getTargetCard().getController());
+
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }
+ }//resolve()
+ void makeToken(PlayerZone play, String controller)
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(controller);
+
+ c.setName("Ape");
+ c.setImageName("G 3 3 Ape");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Ape");
+ c.setBaseAttack(3);
+ c.setBaseDefense(3);
+
+ play.add(c);
+ }
+ };//SpellAbility
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Devour in Shadow"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 215990562522519924L;
+
+ public boolean canPlayAI()
+ {
+ return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(best);
+
+ if(AllZone.Computer_Life.getLife() <= best.getNetDefense())
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(AllZone.Computer_Life.getLife() - 1, card, true);
+ CardListUtil.sortAttack(human);
+
+ if(0 < human.size())
+ setTargetCard(human.get(0));
+ }
+ }
+ CardList getCreature()
+ {
+ return CardFactoryUtil.AI_getHumanCreature(card, true);
+ }//getCreature()
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.subtractLife(getTargetCard().getNetDefense());
+ }
+ }//resolve()
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Terminate"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3334967250557638367L;
+
+ public boolean canPlayAI()
+ {
+ return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(best);
+
+ CardList human = CardFactoryUtil.AI_getHumanCreature(AllZone.Computer_Life.getLife() - 1, card, true);
+ CardListUtil.sortAttack(human);
+
+ if(0 < human.size())
+ setTargetCard(human.get(0));
+
+ }
+ CardList getCreature()
+ {
+ return CardFactoryUtil.AI_getHumanCreature(card, true);
+ }//getCreature()
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }//resolve()
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kinsbaile Borderguard"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ card.addCounter(Counters.P1P1, countKithkin());
+ //System.out.println("all counters: " +card.sumAllCounters());
+ }//resolve()
+
+ public int countKithkin()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList kithkin = new CardList(play.getCards());
+ kithkin = kithkin.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c)
+ {
+ return (c.getType().contains("Kithkin") || c.getKeyword().contains("Changeling"))&& !c.equals(card);
+ }
+
+ });
+ return kithkin.size();
+
+ }
+ @SuppressWarnings("unused") // makeToken
+ public void makeToken()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Kithkin Soldier");
+ c.setImageName("W 1 1 Kithkin Soldier");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Kithkin");
+ c.addType("Soldier");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7067218066522935060L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Kinsbaile Borderguard comes into play with a +1/+1 counter on it for each other Kithkin you control.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ final SpellAbility ability2 = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ for (int i=0;i 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wren's Run Packmaster"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ public Object execute()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ list.addAll(play.getCards());
+
+ list = list.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return c.getType().contains("Elf") || c.getKeyword().contains("Changeling");
+ }
+ });
+
+ return list;
+ }
+ };//CommandReturn
+
+ final SpellAbility abilityComes = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if (getTargetCard() == null || getTargetCard() == card)
+ AllZone.GameAction.sacrifice(card);
+
+ else if(AllZone.GameAction.isCardInPlay(getTargetCard()))
+ {
+ /*
+ PlayerZone play = AllZone.getZone(getTargetCard());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, getTargetCard().getController());
+ play.remove(getTargetCard());
+ removed.add(getTargetCard());
+ */
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ };
+
+ final Input inputComes = new Input()
+ {
+ private static final long serialVersionUID = 5210700665533271691L;
+
+ public void showMessage()
+ {
+ CardList choice = (CardList)getCreature.execute();
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(abilityComes, choice, "Select Elf to remove from the game", false));
+ ButtonUtil.disableAll(); //target this card means: sacrifice this card
+ }
+ };
+ Command commandComes = new Command()
+ {
+
+ private static final long serialVersionUID = -3580408066322945328L;
+
+ public void execute()
+ {
+ CardList creature = (CardList)getCreature.execute();
+ String s = card.getController();
+ if(creature.size() == 0) {
+ AllZone.GameAction.sacrifice(card);
+ return;
+ }
+ else if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(inputComes);
+ else //computer
+ {
+ Card target;
+ //must target computer creature
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+ computer = computer.getType("Elf");
+ computer.remove(card);
+
+ computer.shuffle();
+ if (computer.size()!= 0) {
+ target = computer.get(0);
+ abilityComes.setTargetCard(target);
+ AllZone.Stack.add(abilityComes);
+ }
+ }//else
+ }//execute()
+ };//CommandComes
+ Command commandLeavesPlay = new Command()
+ {
+
+ private static final long serialVersionUID = -5903638227914705191L;
+
+ public void execute()
+ {
+ //System.out.println(abilityComes.getTargetCard().getName());
+ Object o = abilityComes.getTargetCard();
+
+ if(o == null || ((Card)o).isToken()|| !AllZone.GameAction.isCardRemovedFromGame((Card)o) )
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = abilityComes.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner());
+ removed.remove(c);
+ play.add(c);
+
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription(card.getName() + " - returning creature to play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+
+
+ final SpellAbility a1 = new Ability(card, "2 G")
+ {
+ public boolean canPlayAI()
+ {
+ return MyRandom.random.nextBoolean();
+ }
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ //this is a hack, check the stack to see if this card has an ability on the stack
+ //if so, we can't use the ability
+ for (int i=0; i 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ card.addSpellAbility(a1);
+ a1.setBeforePayMana(new Input_PayManaCost(a1));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Changeling Berserker") || cardName.equals("Changeling Hero") || cardName.equals("Changeling Titan"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ public Object execute()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ list.addAll(play.getCards());
+
+ list = list.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return c.getType().contains("Creature");
+ }
+ });
+
+ return list;
+ }
+ };//CommandReturn
+
+ final SpellAbility abilityComes = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if (getTargetCard() == null || getTargetCard() == card)
+ AllZone.GameAction.sacrifice(card);
+
+ else if(AllZone.GameAction.isCardInPlay(getTargetCard()) )
+ {
+ /*
+ PlayerZone play = AllZone.getZone(getTargetCard());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, getTargetCard().getController());
+ play.remove(getTargetCard());
+ removed.add(getTargetCard());
+ */
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ };
+
+ final Input inputComes = new Input()
+ {
+
+ private static final long serialVersionUID = 5210700665533271691L;
+
+ public void showMessage()
+ {
+ CardList choice = (CardList)getCreature.execute();
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(abilityComes, choice, "Select creature to remove from the game", false));
+ ButtonUtil.disableAll();
+ }
+ };
+ Command commandComes = new Command()
+ {
+
+ private static final long serialVersionUID = -3580408066322945328L;
+
+ public void execute()
+ {
+ CardList creature = (CardList)getCreature.execute();
+ String s = card.getController();
+ if(creature.size() == 0) {
+ AllZone.GameAction.sacrifice(card);
+ return;
+ }
+ else if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(inputComes);
+ else //computer
+ {
+ Card target;
+ //must target computer creature
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+ computer = computer.getType("Creature");
+ computer.remove(card);
+
+ computer.shuffle();
+ if (computer.size()!= 0) {
+ target = computer.get(0);
+ abilityComes.setTargetCard(target);
+ AllZone.Stack.add(abilityComes);
+ }
+ }//else
+ }//execute()
+ };//CommandComes
+ Command commandLeavesPlay = new Command()
+ {
+
+ private static final long serialVersionUID = -5903638227914705191L;
+
+ public void execute()
+ {
+ //System.out.println(abilityComes.getTargetCard().getName());
+ Object o = abilityComes.getTargetCard();
+
+ if(o == null || ((Card)o).isToken()|| !AllZone.GameAction.isCardRemovedFromGame((Card)o) )
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = abilityComes.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner());
+ removed.remove(c);
+ play.add(c);
+
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription(card.getName() + " - returning creature to play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+
+ card.addComesIntoPlayCommand(commandComes);
+ card.addLeavesPlayCommand(commandLeavesPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+
+ private static final long serialVersionUID = 2583297503017070549L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+ if (o == null)
+ return false;
+
+ CardList cl = (CardList)getCreature.execute();
+ return (o != null) && cl.size() > 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Devout Lightcaster"))
+ {
+ final CommandReturn getBlackPerm = new CommandReturn()
+ {
+ public Object execute()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return c.isPermanent() && CardFactoryUtil.canTarget(card,c) && CardUtil.getColor(c).equals(Constant.Color.Black);
+ }
+ });
+
+ return list;
+ }
+ };//CommandReturn
+
+ final SpellAbility abilityComes = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ };
+
+ final Input inputComes = new Input()
+ {
+ private static final long serialVersionUID = 3762167908738465100L;
+
+ public void showMessage()
+ {
+ CardList choice = (CardList)getBlackPerm.execute();
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(abilityComes, choice, "Select target black permanent to remove from the game", true));
+ ButtonUtil.disableAll();//to disable the Cancel button
+ }
+ };
+ Command commandComes = new Command()
+ {
+
+ private static final long serialVersionUID = 3878683618127503416L;
+
+ public void execute()
+ {
+ CardList creature = (CardList)getBlackPerm.execute();
+ String s = card.getController();
+ if(creature.size() == 0)
+ return;
+ else if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(inputComes);
+ else //computer
+ {
+ Card target;
+
+ //try to target human permanent
+ PlayerZone hum = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList human = new CardList(hum.getCards());
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isPermanent() && CardUtil.getColor(c).equals(Constant.Color.Black);
+ }
+
+ });
+ //target = CardFactoryUtil.AI_getBestCreature(human);//returns null if list is empty
+ human.shuffle();
+ target = null;
+ if (human.size()!=0)
+ target = human.get(0);
+
+ if(target == null)
+ {
+ //must target computer creature
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+ computer = computer.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isPermanent() && CardUtil.getColor(c).equals(Constant.Color.Black);
+ }
+
+ });
+
+ computer.shuffle();
+ if (computer.size()!= 0)
+ target = computer.get(0);
+ }
+ abilityComes.setTargetCard(target);
+ AllZone.Stack.add(abilityComes);
+ }//else
+ }//execute()
+ };//CommandComes
+
+ card.addComesIntoPlayCommand(commandComes);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+
+ private static final long serialVersionUID = -9059177006257139430L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getBlackPerm.execute();
+ if (o == null)
+ return false;
+
+ CardList cl = (CardList)getBlackPerm.execute();
+ return (o != null) && cl.size() > 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Faceless Butcher"))
+ {
+ final CommandReturn getCreature = new CommandReturn()
+ {
+ public Object execute()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return c.isCreature() && CardFactoryUtil.canTarget(card,c);
+ }
+ });
+
+ //remove "this card"
+ list.remove(card);
+
+ return list;
+ }
+ };//CommandReturn
+
+ final SpellAbility abilityComes = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ /*
+ PlayerZone play = AllZone.getZone(getTargetCard());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, getTargetCard().getController());
+ play.remove(getTargetCard());
+ removed.add(getTargetCard());
+ */
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ };
+
+ final Input inputComes = new Input()
+ {
+ private static final long serialVersionUID = -1932054059769056049L;
+
+ public void showMessage()
+ {
+ CardList choice = (CardList)getCreature.execute();
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(abilityComes, choice, "Select target creature to remove from the game", true));
+ ButtonUtil.disableAll();//to disable the Cancel button
+ }
+ };
+ Command commandComes = new Command()
+ {
+ private static final long serialVersionUID = -5675532512302863456L;
+
+ public void execute()
+ {
+ CardList creature = (CardList)getCreature.execute();
+ String s = card.getController();
+ if(creature.size() == 0)
+ return;
+ else if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(inputComes);
+ else //computer
+ {
+ Card target;
+
+ //try to target human creature
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ target = CardFactoryUtil.AI_getBestCreature(human);//returns null if list is empty
+
+ if(target == null)
+ {
+ //must target computer creature
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+ computer = computer.getType("Creature");
+ computer.remove(card);
+
+ computer.shuffle();
+ if (computer.size()!= 0)
+ target = computer.get(0);
+ }
+ abilityComes.setTargetCard(target);
+ AllZone.Stack.add(abilityComes);
+ }//else
+ }//execute()
+ };//CommandComes
+ Command commandLeavesPlay = new Command()
+ {
+ private static final long serialVersionUID = 5518706316791622193L;
+
+ public void execute()
+ {
+ //System.out.println(abilityComes.getTargetCard().getName());
+ Object o = abilityComes.getTargetCard();
+
+ if(o == null || ((Card)o).isToken()|| !AllZone.GameAction.isCardRemovedFromGame((Card)o) )
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = abilityComes.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner());
+ removed.remove(c);
+ play.add(c);
+
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription("Faceless Butcher - returning creature to play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+
+ card.addComesIntoPlayCommand(commandComes);
+ card.addLeavesPlayCommand(commandLeavesPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+
+ private static final long serialVersionUID = -62128538015338896L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getCreature.execute();
+ if (o == null)
+ return false;
+
+ CardList cl = (CardList)getCreature.execute();
+ return (o != null) && cl.size() > 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Oblivion Ring"))
+ {
+ final CommandReturn getPerm = new CommandReturn()
+ {
+ public Object execute()
+ {
+ //get all creatures
+ CardList tempList = new CardList();
+ tempList.addAll(AllZone.Human_Play.getCards());
+ tempList.addAll(AllZone.Computer_Play.getCards());
+
+ CardList list = new CardList();
+
+ for(int i=0;i < tempList.size(); i++)
+ {
+ if(tempList.get(i).isPermanent() && !tempList.get(i).isLand() && CardFactoryUtil.canTarget(card, tempList.get(i)) )
+ list.add(tempList.get(i));
+ }
+
+ //remove "this card"
+ list.remove(card);
+
+ return list;
+ }
+ };//CommandReturn
+
+ final SpellAbility abilityComes = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ };
+
+ final Input inputComes = new Input()
+ {
+ private static final long serialVersionUID = -3613946694360326887L;
+
+ public void showMessage()
+ {
+ CardList choice = (CardList)getPerm.execute();
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(abilityComes, choice, "Select target permanent to remove from the game", true));
+ ButtonUtil.disableAll();//to disable the Cancel button
+ }
+ };
+ Command commandComes = new Command()
+ {
+ private static final long serialVersionUID = -6250376920501373535L;
+
+ public void execute()
+ {
+ CardList perm = (CardList)getPerm.execute();
+ String s = card.getController();
+ if(perm.size() == 0)
+ return;
+ else if(s.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(inputComes);
+ else //computer
+ {
+ Card target;
+
+ //try to target human creature
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ target = CardFactoryUtil.AI_getBestCreature(human);//returns null if list is empty
+
+ // try to target human permanent
+ if (target == null)
+ {
+ int convertedCost = 0;
+ CardList tempList = new CardList();
+ tempList.addAll(AllZone.Human_Play.getCards());
+
+ @SuppressWarnings("unused") // list
+ CardList list = new CardList();
+ for (int i=0;i convertedCost))
+ {
+ target = tempList.get(i);
+ convertedCost = CardUtil.getConvertedManaCost(tempList.get(i).getManaCost());
+ }
+ }
+ }
+
+ //target something cheaper (manacost 0?) instead:
+ if (target == null)
+ {
+ CardList humanPerms = new CardList();
+ humanPerms.addAll(AllZone.Human_Play.getCards());
+ humanPerms = humanPerms.filter(new CardListFilter() {
+ public boolean addCard(Card c) {
+ return c.isPermanent() && !c.isLand() && CardFactoryUtil.canTarget(card, c);
+ }
+ });
+
+ if (humanPerms.size()>0)
+ target = humanPerms.get(0);
+ }
+
+ if(target == null)
+ {
+ //must target computer creature
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+ computer = computer.getType("Creature");
+ computer.remove(card);
+
+ computer.shuffle();
+ if (computer.size() != 0)
+ target = computer.get(0);
+ else
+ target = card;
+ }
+ abilityComes.setTargetCard(target);
+ AllZone.Stack.add(abilityComes);
+ }//else
+ }//execute()
+ };//CommandComes
+ Command commandLeavesPlay = new Command()
+ {
+ private static final long serialVersionUID = 6997038208952910355L;
+
+ public void execute()
+ {
+ Object o = abilityComes.getTargetCard();
+ if(o == null || ((Card)o).isToken() || !AllZone.GameAction.isCardRemovedFromGame((Card)o) )
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = abilityComes.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ play.add(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription("Oblivion Ring - returning permanent to play.");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+
+ card.addComesIntoPlayCommand(commandComes);
+ card.addLeavesPlayCommand(commandLeavesPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -3250095291930182087L;
+
+ public boolean canPlayAI()
+ {
+ Object o = getPerm.execute();
+ if (o == null)
+ return false;
+
+ CardList cl = (CardList)getPerm.execute();
+ return (o != null) && cl.size() > 0 && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+
+ }//*************** END ************ END **************************
+
+
+
+ /*
+ //*************** START *********** START **************************
+ else if(cardName.equals("Oblivion Ring"))
+ {
+ final SpellAbility enchantment = new Spell(card)
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()))
+ {
+ PlayerZone play = AllZone.getZone(getTargetCard());
+ play.remove(getTargetCard());
+
+ //put permanent into play
+ Card c = getSourceCard();
+ AllZone.getZone(Constant.Zone.Play, c.getController()).add(c);
+ }
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ //try to target human creature
+ CardList human = CardFactoryUtil.AI_getHumanCreature();
+ Card target = CardFactoryUtil.AI_getBestCreature(human);//returns null if list is empty
+
+ if(target == null)
+ return false;
+ else
+ {
+ setTargetCard(target);
+ return true;
+ }
+ }//canPlayAI()
+ };//SpellAbility enchantment
+
+
+ final Input target = new Input()
+ {
+ //showMessage() is always the first method called
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select non-land to remove from the game.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play) && !c.isLand())
+ {
+ enchantment.setTargetCard(c);
+
+ stopSetNext(new Input_PayManaCost(enchantment));
+ }
+ }
+ };//Input target
+
+ Command commandDestroy = new Command()
+ {
+ public void execute()
+ {
+ Object o = enchantment.getTargetCard();
+ if(o == null || ((Card)o).isToken())
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = enchantment.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ play.add(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription(card.getName() +" - returning creature to play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+ card.setDestroy(commandDestroy);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(enchantment);
+
+ enchantment.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ */
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Oubliette"))
+ {
+ final SpellAbility enchantment = new Spell(card)
+ {
+ private static final long serialVersionUID = -6751177094537759827L;
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card,getTargetCard()))
+ {
+ AllZone.GameAction.removeFromGame(getTargetCard());
+
+ //put permanent into play
+ Card c = getSourceCard();
+ AllZone.getZone(Constant.Zone.Play, c.getController()).add(c);
+ }
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ //try to target human creature
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ Card target = CardFactoryUtil.AI_getBestCreature(human);//returns null if list is empty
+
+ if(target == null)
+ return false;
+ else
+ {
+ setTargetCard(target);
+ return true;
+ }
+ }//canPlayAI()
+ };//SpellAbility enchantment
+
+
+ @SuppressWarnings("unused") // target
+ final Input target = new Input()
+ {
+ private static final long serialVersionUID = -251660220889858176L;
+
+ //showMessage() is always the first method called
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select creature to remove from the game (sorry no phasing yet).");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(enchantment, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(zone.is(Constant.Zone.Play) && c.isCreature())
+ {
+ enchantment.setTargetCard(c);
+
+ stopSetNext(new Input_PayManaCost(enchantment));
+ }
+ }
+ };//Input target
+
+ Command commandLeavesPlay = new Command()
+ {
+ private static final long serialVersionUID = -2535098005246027777L;
+
+ public void execute()
+ {
+ Object o = enchantment.getTargetCard();
+ if(o == null || ((Card)o).isToken() || !AllZone.GameAction.isCardRemovedFromGame((Card)o) )
+ return;
+
+ SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //copy card to reset card attributes like attack and defense
+ Card c = enchantment.getTargetCard();
+ if(! c.isToken())
+ {
+ c = AllZone.CardFactory.copyCard(c);
+ c.setController(c.getOwner());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ play.add(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription(card.getName() +" - returning creature to play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+ card.addLeavesPlayCommand(commandLeavesPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(enchantment);
+
+ enchantment.setBeforePayMana(CardFactoryUtil.input_targetCreature(enchantment));
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Test Destroy"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6637283804612570910L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }//resolve()
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "All"));
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Take Possession"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7359291736123492910L;
+
+ public boolean canPlayAI() {return 0 < CardFactoryUtil.AI_getHumanCreature(card, true).size();}
+
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestCreature(CardFactoryUtil.AI_getHumanCreature(card, true));
+ setTargetCard(best);
+ }
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ c.setController(card.getController());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone from = AllZone.getZone(c);
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ from.remove(c);
+ to.add(c);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+
+ }//resolve()
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "All"));
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Night's Whisper"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -8594340516961923197L;
+
+ public boolean canPlayAI()
+ {
+ return AllZone.Computer_Life.getLife()>2;
+ }
+ public void resolve()
+ {
+ //draw 2 cards, subtract 2 life
+ String player = card.getController();
+ AllZone.GameAction.drawCard(player);
+ AllZone.GameAction.drawCard(player);
+
+ AllZone.GameAction.getPlayerLife(player).subtractLife(2);
+ }//resolve()
+ };
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Infest"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4970294125917784048L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ human = CardListUtil.filterToughness(human, 2);
+ computer = CardListUtil.filterToughness(computer, 2);
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1;
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addDamage(2);
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ember-Fist Zubera"))
+ {
+ //counts Zubera in all graveyards for this turn
+ final CommandReturn countZubera = new CommandReturn()
+ {
+ public Object execute()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.getTurnInZone() == AllZone.Phase.getTurn()) &&
+ (c.getType().contains("Zubera") || c.getKeyword().contains("Changeling") );
+ }
+ });//CardListFilter()
+
+ return new Integer(list.size());
+ }
+ };
+
+ final Input[] input = new Input[1];
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ //human chooses target on resolve,
+ //computer chooses target in Command destroy
+ if(Constant.Player.Human.equals(card.getController()))
+ AllZone.InputControl.setInput(input[0]);
+ else
+ {
+ int damage = ((Integer)countZubera.execute()).intValue();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canDamage(card, getTargetCard())
+ && CardFactoryUtil.canTarget(card,getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ input[0] = new Input()
+ {
+ private static final long serialVersionUID = 1899925898843297992L;
+
+ public void showMessage()
+ {
+ int damage = ((Integer)countZubera.execute()).intValue();
+ AllZone.Display.showMessage("Select target Creature, Planeswalker or Player - " + damage +" damage ");
+ ButtonUtil.disableAll();
+ }
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if((card.isCreature() || card.isPlaneswalker()) && zone.is(Constant.Zone.Play))
+ {
+ int damage = ((Integer)countZubera.execute()).intValue();
+ card.addDamage(damage);
+
+ //have to do this since state effects aren't checked
+ //after this "Input" class is done
+ //basically this makes everything work right
+ //Ember-Fist Zubera can destroy a 2/2 creature
+ AllZone.GameAction.checkStateEffects();
+ stop();
+ }
+ }//selectCard()
+ public void selectPlayer(String player)
+ {
+ int damage = ((Integer)countZubera.execute()).intValue();
+ AllZone.GameAction.getPlayerLife(player).subtractLife(damage);
+ stop();
+ }//selectPlayer()
+ };//Input
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -1889425992069348304L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card +" causes damage to creature or player");
+
+ @SuppressWarnings("unused") // damage
+ int damage = ((Integer)countZubera.execute()).intValue();
+
+ String con = card.getController();
+
+ //human chooses target on resolve,
+ //computer chooses target in Command destroy
+ if(con.equals(Constant.Player.Computer))
+ ability.setTargetPlayer(Constant.Player.Human);
+
+ AllZone.Stack.add(ability);
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ashen-Skin Zubera"))
+ {
+ //counts Zubera in all graveyards for this turn
+ final CommandReturn countZubera = new CommandReturn()
+ {
+ public Object execute()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.getTurnInZone() == AllZone.Phase.getTurn()) &&
+ (c.getType().contains("Zubera") || c.getKeyword().contains("Changeling") );
+ }
+ });//CardListFilter()
+ return new Integer(list.size());
+ }
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ int discard = ((Integer)countZubera.execute()).intValue();
+
+ if(Constant.Player.Human.equals(getTargetPlayer()))
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard(discard));
+ else
+ {
+ for(int i = 0; i < discard; i++)
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -7494691537986218546L;
+
+ public void execute()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ ability.setTargetPlayer(opponent);
+ ability.setStackDescription(card +" - " + opponent +" discards cards");
+
+ AllZone.Stack.add(ability);
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Floating-Dream Zubera"))
+ {
+ //counts Zubera in all graveyards for this turn
+ final CommandReturn countZubera = new CommandReturn()
+ {
+ public Object execute()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.getTurnInZone() == AllZone.Phase.getTurn()) &&
+ (c.getType().contains("Zubera") || c.getKeyword().contains("Changeling") );
+ }
+ });//CardListFilter()
+ return new Integer(list.size());
+ }
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ int number = ((Integer)countZubera.execute()).intValue();
+
+ for(int i = 0; i < number; i++)
+ AllZone.GameAction.drawCard(getTargetPlayer());
+ }//resolve()
+ };//SpellAbility
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -5814070329854975419L;
+
+ public void execute()
+ {
+ ability.setTargetPlayer(card.getController());
+ ability.setStackDescription(card +" - " +card.getController() +" draws cards");
+ AllZone.Stack.add(ability);
+
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Silent-Chant Zubera"))
+ {
+ //counts Zubera in all graveyards for this turn
+ final CommandReturn countZubera = new CommandReturn()
+ {
+ public Object execute()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.getTurnInZone() == AllZone.Phase.getTurn()) &&
+ (c.getType().contains("Zubera") || c.getKeyword().contains("Changeling") );
+ }
+ });//CardListFilter()
+ return new Integer(list.size());
+ }
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ int number = ((Integer)countZubera.execute()).intValue();
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(getTargetPlayer());
+ life.addLife(number * 2);
+ }//resolve()
+ };//SpellAbility
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -2327085948421343657L;
+
+ public void execute()
+ {
+ ability.setTargetPlayer(card.getController());
+ ability.setStackDescription(card +" - " +card.getController() +" gains life");
+ AllZone.Stack.add(ability);
+
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Dripping-Tongue Zubera"))
+ {
+ //counts Zubera in all graveyards for this turn
+ final CommandReturn countZubera = new CommandReturn()
+ {
+ public Object execute()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.getTurnInZone() == AllZone.Phase.getTurn()) &&
+ (c.getType().contains("Zubera") || c.getKeyword().contains("Changeling") );
+ }
+ });//CardListFilter()
+ return new Integer(list.size());
+ }
+ };//CommandReturn
+
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ int count = ((Integer)countZubera.execute()).intValue();
+ for(int i = 0; i < count; i++)
+ makeToken();
+ }//resolve()
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Spirit");
+ c.setImageName("C 1 1 Spirit");
+ c.setManaCost("");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Spirit");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }//makeToken()
+
+ };//SpellAbility
+
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = 8362692868619919330L;
+ public void execute()
+ {
+ ability.setTargetPlayer(card.getController());
+ ability.setStackDescription(card +" - " +card.getController() +" puts tokens into play");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Keiga, the Tide Star"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone oldPlay = AllZone.getZone(getTargetCard());
+
+ //so "comes into play" abilities don't trigger
+ //getTargetCard().addComesIntoPlayCommand(Command.Blank);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ play.add(getTargetCard());
+ oldPlay.remove(getTargetCard());
+
+ getTargetCard().setController(card.getController());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ }//resolve()
+ };
+
+ final Input targetInput = new Input()
+ {
+ private static final long serialVersionUID = -8727869672234802473L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(card, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(c.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ ability.setTargetCard(c);
+ ability.setStackDescription("Gain control of " +ability.getTargetCard());
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }
+ };//Input
+ Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -3868616119471172026L;
+
+ public void execute()
+ {
+ String con = card.getController();
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ if(con.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(targetInput);
+ else if(list.size() != 0)
+ {
+ Card target = CardFactoryUtil.AI_getBestCreature(list);
+ ability.setTargetCard(target);
+ AllZone.Stack.add(ability);
+ }
+ }//execute()
+ };
+ card.addDestroyCommand(destroy);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Angelic Blessing"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6906094867912276636L;
+
+ public void resolve()
+ {
+ final Command eot = new Command()
+ {
+ private static final long serialVersionUID = 4672991308703961180L;
+
+ public void execute()
+ {
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) )
+ {
+ c.addTempAttackBoost(-3);
+ c.addTempDefenseBoost(-3);
+ c.removeExtrinsicKeyword("Flying");
+ }
+ }//execute()
+ };//Command
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ c.addTempAttackBoost(3);
+ c.addTempDefenseBoost(3);
+ c.addExtrinsicKeyword("Flying");
+
+ AllZone.EndOfTurn.addUntil(eot);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ Combat combat = ComputerUtil.getAttackers();
+ return (0 != combat.getAttackers().length);
+ }
+ public void chooseTargetAI()
+ {
+ Combat combat = ComputerUtil.getAttackers();
+ Card[] attacker = combat.getAttackers();
+ if(attacker.length != 0)
+ setTargetCard(attacker[0]);
+ else
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+ Card best = CardFactoryUtil.AI_getBestCreature(list);
+ setTargetCard(best);
+ }
+ }//chooseTargetAI()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+/*
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Molten Rain"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ public boolean canPlayAI()
+ {
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Basic");
+ return land.size() != 0;
+ }
+
+ public void chooseTargetAI()
+ {
+ //target basic land that Human only has 1 or 2 in play
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Basic");
+
+ Card target = null;
+
+ String[] name = {"Forest", "Swamp", "Plains", "Mountain", "Island"};
+ for(int i = 0; i < name.length; i++)
+ if(land.getName(name[i]).size() == 1)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+
+ //see if there are only 2 lands of the same type
+ if(target == null)
+ {
+ for(int i = 0; i < name.length; i++)
+ if(land.getName(name[i]).size() == 2)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+ }//if
+ if(target == null)
+ {
+ land.shuffle();
+ target = land.get(0);
+ }
+ setTargetCard(target);
+ }//chooseTargetAI()
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ AllZone.GameAction.destroy(c);
+
+ if(! c.getType().contains("Basic"))
+ AllZone.GameAction.getPlayerLife(c.getController()).subtractLife(2);
+ }
+ }//resolve()
+
+ };//Spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target Land");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card.isLand() && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectCard()
+ };
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+*/
+
+
+//*************** START *********** START **************************
+ if (cardName.equals("Molten Rain"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8855786097956610090L;
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ if (AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
+ if(! c.getType().contains("Basic"))
+ AllZone.GameAction.getPlayerLife(c.getController()).subtractLife(2);
+ AllZone.GameAction.destroy(c);
+ }
+
+ }// resolve()
+
+ };// Spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetType("Land", AllZone.Human_Play));
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell,"Land"));
+ }// *************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Elvish Piper"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "G")
+ {
+ private static final long serialVersionUID = 8788555124182810249L;
+
+ public boolean canPlayAI() {return getCreature().size() != 0;}
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Hand.getCards());
+ list = list.getType("Creature");
+ return list;
+ }
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(c, hand))
+ {
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("G, tap: Put a creature card from your hand into play.");
+
+ final Command paid = new Command()
+ {
+ private static final long serialVersionUID = 6859737530872573139L;
+ public void execute()
+ {
+ AllZone.InputControl.resetInput();
+ AllZone.Stack.add(ability);
+ }
+ };
+ final Command unpaid = new Command()
+ {
+ private static final long serialVersionUID = -257927480355704167L;
+
+ public void execute()
+ {
+ card.untap();
+ }
+ };
+ final Input target = new Input()
+ {
+ private static final long serialVersionUID = -1041198540673942649L;
+
+ public void showMessage()
+ {
+ ButtonUtil.enableOnlyCancel();
+ AllZone.Display.showMessage("Select creature from your hand to put into play");
+ }
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isCreature() && zone.is(Constant.Zone.Hand, Constant.Player.Human))
+ {
+ card.tap();
+
+ ability.setTargetCard(c);//since setTargetCard() changes stack description
+ ability.setStackDescription("Put into play " +c);
+
+ AllZone.InputControl.setInput(new Input_PayManaCost_Ability(ability.getManaCost(), paid, unpaid));
+ }
+ }
+ public void selectButtonCancel()
+ {
+ card.untap();
+ stop();
+ }
+ };//Input target
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Belbe's Portal"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "3")
+ {
+ private static final long serialVersionUID = 3790805878629855813L;
+
+ public boolean canPlayAI() {return getCreature().size() != 0;}
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Hand.getCards());
+ list = list.getType(card.getChosenType());
+ return list;
+ }
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(c, hand))
+ {
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("3, tap: Put a creature card of the chosen type from your hand into play.");
+
+ final Command paid = new Command()
+ {
+ private static final long serialVersionUID = 4258139342966165260L;
+
+ public void execute()
+ {
+ AllZone.InputControl.resetInput();
+ AllZone.Stack.add(ability);
+ }
+ };
+ final Command unpaid = new Command()
+ {
+ private static final long serialVersionUID = 5792270994683837097L;
+
+ public void execute()
+ {
+ card.untap();
+ }
+ };
+ final Input target = new Input()
+ {
+ private static final long serialVersionUID = -3180364352114242238L;
+
+ public void showMessage()
+ {
+ ButtonUtil.enableOnlyCancel();
+ AllZone.Display.showMessage("Select creature from your hand to put into play");
+ }
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isCreature() && zone.is(Constant.Zone.Hand, Constant.Player.Human) && c.getType().contains(card.getChosenType()))
+ {
+ card.tap();
+
+ ability.setTargetCard(c);//since setTargetCard() changes stack description
+ ability.setStackDescription("Put into play " +c);
+
+ AllZone.InputControl.setInput(new Input_PayManaCost_Ability(ability.getManaCost(), paid, unpaid));
+ }
+ }
+ public void selectButtonCancel()
+ {
+ card.untap();
+ stop();
+ }
+ };//Input target
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Weathered Wayfarer"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "W")
+ {
+ private static final long serialVersionUID = 2902408879239353813L;
+
+ public void resolve()
+ {
+ //getTargetCard() will NEVER be null
+
+ //checks to see if card is still in the library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), library))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ String oppPlayer = AllZone.GameAction.getOpponent(card.getController());
+
+ PlayerZone selfZone = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone oppZone = AllZone.getZone(Constant.Zone.Play, oppPlayer);
+
+ CardList self = new CardList(selfZone.getCards());
+ CardList opp = new CardList(oppZone.getCards());
+
+ self = self.getType("Land");
+ opp = opp.getType("Land");
+
+ //checks to see if any land in library
+ PlayerZone selfLibrary = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList library = new CardList(selfLibrary.getCards());
+ library = library.getType("Land");
+
+ return (self.size() < opp.size()) && (library.size() != 0) && super.canPlay();
+ }
+ public void chooseTargetAI()
+ {
+ PlayerZone selfLibrary = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList library = new CardList(selfLibrary.getCards());
+ library = library.getType("Land");
+
+ setTargetCard(library.get(0));
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 3492362297282622857L;
+
+ public void showMessage()
+ {
+ CardList land = new CardList(AllZone.Human_Library.getCards());
+ land = land.getType("Land");
+ Object o = AllZone.Display.getChoiceOptional("Select a Land", land.toArray());
+
+ //techincally not correct, but correct enough
+ //this allows players to look at their decks without paying anything
+ if(o == null)
+ stop();
+ else
+ {
+ AllZone.GameAction.shuffle("Human");
+ ability.setTargetCard((Card)o);
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ }//showMessage()
+ };//Input - target
+
+ card.addSpellAbility(ability);
+ ability.setDescription("W, tap: Search your library for a land card, reveal it, and put it into your hand. Then shuffle your library. Play this ability only if an opponent controls more lands than you.");
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Disciple of Kangee"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "U")
+ {
+ private static final long serialVersionUID = -5169389637917649036L;
+ public boolean canPlayAI()
+ {
+ if(CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+
+ return CardFactoryUtil.AI_getHumanCreature("Flying", card, false).isEmpty() &&
+ (getCreature().size() != 0);
+ }
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
+ (! c.getKeyword().contains("Flying")) && CardFactoryUtil.canTarget(card, c);
+ }
+ });
+ list.remove(card);
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ final Card[] creature = new Card[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = -1899153704584793548L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ creature[0].removeExtrinsicKeyword("Flying");
+ }
+ };
+ creature[0] = getTargetCard();
+ creature[0].addExtrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(EOT);
+ }//if (card is in play)
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("U, tap: Target creature gains flying.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Puppeteer"))
+ {
+ //tap - target creature
+ final SpellAbility ability = new Ability_Tap(card, "U")
+ {
+ private static final long serialVersionUID = 7698358771800336470L;
+ public boolean canPlayAI() {return getTapped().size() != 0;}
+ public void chooseTargetAI()
+ {
+ card.tap();
+ Card target = CardFactoryUtil.AI_getBestCreature(getTapped());
+ setTargetCard(target);
+ }
+ CardList getTapped()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && c.isTapped();
+ }
+ });
+ return list;
+ }//getTapped()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ if(c.isTapped())
+ c.untap();
+ else
+ c.tap();
+ }
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("U, tap: Tap or untap target creature.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sorceress Queen"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -6853184726011448677L;
+ public boolean canPlayAI()
+ {
+ Card c = getCreature();
+ if(c == null)
+ return false;
+ else
+ {
+ setTargetCard(c);
+ return true;
+ }
+ }//canPlayAI()
+ //may return null
+ public Card getCreature()
+ {
+ CardList untapped = CardFactoryUtil.AI_getHumanCreature(card, true);
+ untapped = untapped.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isUntapped() && 2 < c.getNetDefense() && c != card;
+ }
+ });
+ if(untapped.isEmpty())
+ return null;
+
+ Card big = CardFactoryUtil.AI_getBestCreature(untapped);
+ return big;
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ final Card[] creature = new Card[1];
+
+ creature[0] = getTargetCard();
+ final int[] originalAttack = {creature[0].getBaseAttack()};
+ final int[] originalDefense = {creature[0].getBaseDefense()};
+
+ creature[0].setBaseAttack(0);
+ creature[0].setBaseDefense(2);
+
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = 6437463765161964445L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].setBaseAttack(originalAttack[0]);
+ creature[0].setBaseDefense(originalDefense[0]);
+ }
+ }
+ };
+ AllZone.EndOfTurn.addUntil(EOT);
+ }//is card in play?
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Target creature other than Sorceress Queen becomes 0/2 until end of turn.");
+ //this ability can target "this card" when it shouldn't be able to
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature_NoCost_TapAbility_NoTargetSelf(ability));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Immaculate Magistrate"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 8976980151320100343L;
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(zone.getCards());
+ int nElf = list.getType("Elf").size();
+
+ Card c = getTargetCard();
+ c.addCounter(Counters.P1P1, nElf);
+
+ }//is card in play?
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isUntapped() && !c.equals(card) && c.isCreature();
+ }
+ });
+
+ if(list.isEmpty())
+ return false;
+
+ list.shuffle();
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Put a +1/+1 counter on target creature for each Elf you control.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+ /*
+ //*************** START *********** START **************************
+ if(cardName.equals("Prodigal Sorcerer") || cardName.equals("Prodigal Pyromancer")
+ || cardName.equals("Razorfin Hunter") || cardName.equals("Vulshok Sorcerer")
+ || cardName.equals("Viashino Fangtail") || cardName.equals("Jeska, Warrior Adept"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -7560349014757367722L;
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5)
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(1);
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(1);
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: " +card.getName() +" deals 1 damage to target creature or player.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Anaba Shaman"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "R")
+ {
+ private static final long serialVersionUID = -3954988810589187088L;
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5)
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(1);
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(1);
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("R, tap: " +card.getName() +" deals 1 damage to target creature or player.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kamahl, Pit Fighter"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 6922727343642792543L;
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ boolean b = true;
+
+ //use ability only if no human creatures can block
+ for(int i = 0; i < list.size(); i++)
+ if(list.get(i).isUntapped())
+ b = false;
+
+ return b || AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(3, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 17)
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(3);
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(3);
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: " +card.getName() +" deals 3 damage to target creature or player.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ }//*************** END ************ END **************************
+
+ */
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mawcor"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 6238678956434079L;
+ public boolean canPlayAI()
+ {
+ return AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+
+ public void chooseTargetAI()
+ {
+ setTargetPlayer(Constant.Player.Human);
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(1);
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(1);
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Mawcor deals 1 damage to target creature or player.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Orcish Artillery") || cardName.equals("Goblin Artillery")
+ || cardName.equals("Orcish Cannoneers"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -305363091630642003L;
+ public boolean canPlayAI()
+ {
+ return AllZone.Computer_Life.getLife() > 6;
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(2, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5)
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addDamage(2);
+ //3 damage to self
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(3);
+
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, 5);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, 5);
+
+ }
+ }
+ else
+ {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(2);
+ //3 damage to self
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(3);
+
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, 5);
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, 5);
+ }
+
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: " +cardName + " deals 2 damage to target creature or player and 3 damage to you.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability,true));
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sparksmith"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 681102636956052363L;
+ public boolean canPlayAI()
+ {
+ int n = countGoblins();
+ return (AllZone.Computer_Life.getLife() > n) &&
+ (CardFactoryUtil.AI_getHumanCreature(n, card, true).size() != 0);
+ }
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(countGoblins(), card, true);
+ list.shuffle();
+ setTargetCard(list.get(0));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.subtractLife(countGoblins());
+
+ getTargetCard().addDamage(countGoblins());
+
+ if (card.getKeyword().contains("Lifelink"))
+ GameActionUtil.executeLifeLinkEffects(card, 2*countGoblins());
+ for(int i=0; i < CardFactoryUtil.hasNumberEnchantments(card, "Guilty Conscience"); i++)
+ GameActionUtil.executeGuiltyConscienceEffects(card, 2*countGoblins());
+ }
+ }//resolve()
+ int countGoblins()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Goblin");
+ return list.size();
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Sparksmith deals X damage to target creature and X damage to you, where X is the number of Goblins in play.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Rathi Assassin"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1 B B")
+ {
+ private static final long serialVersionUID = 1117792059002738977L;
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card) && !card.isTapped() && !card.hasSickness();
+ }
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {return c.isTapped() && !CardUtil.getColor(c).equals(Constant.Color.Black);}
+ });
+
+ CardListUtil.sortAttack(human);
+ CardListUtil.sortFlying(human);
+
+ if(0 < human.size())
+ setTargetCard(human.get(0));
+
+ return 0 < human.size();
+ }
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && c.isTapped() && CardFactoryUtil.canTarget(card, c) && !CardUtil.getColor(c).equals(Constant.Color.Black) )
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ /*
+ Input target = new Input()
+ {
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target tapped nonblack creature to destroy");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isCreature() && zone.is(Constant.Zone.Play) && c.isTapped() && ! CardUtil.getColor(c).equals(Constant.Color.Black) )
+ {
+ //tap ability
+ card.tap();
+
+ ability.setTargetCard(c);
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }//selectCard()
+ };//Input
+ */
+
+ ability.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -7903295056497483023L;
+
+ public void showMessage()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ CardList slivers = new CardList(AllZone.getZone(Constant.Zone.Play, opponent).getCards());
+ slivers = slivers.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c)
+ {
+ PlayerZone zone = AllZone.getZone(c);
+ return c.isCreature() && zone.is(Constant.Zone.Play) && c.isTapped() && ! CardUtil.getColor(c).equals(Constant.Color.Black);
+ }
+
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, slivers, "Select a tapped non-black creature", true));
+ }
+ });
+
+ card.addSpellAbility(ability);
+ ability.setDescription("1 B B, tap: Destroy target tapped nonblack creature.");
+ //ability.setBeforePayMana(target);
+ //ability.setAfterPayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Royal Assassin"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 1974437552336643722L;
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {return c.isTapped();}
+ });
+
+ CardListUtil.sortAttack(human);
+ CardListUtil.sortFlying(human);
+
+ if(0 < human.size())
+ setTargetCard(human.get(0));
+
+ return 0 < human.size();
+ }
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && c.isTapped() && CardFactoryUtil.canTarget(card, c) )
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -5894703805950364923L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target tapped creature to destroy");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(card, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(c.isCreature() && zone.is(Constant.Zone.Play) && c.isTapped())
+ {
+ //tap ability
+ card.tap();
+
+ ability.setTargetCard(c);
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }//selectCard()
+ };//Input
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Destroy target tapped creature.");
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Giltspire Avenger"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -1117719063688165635L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ System.out.println("phase =" + AllZone.Phase.getPhase());
+ if ((AllZone.Phase.getPhase().equals(Constant.Phase.Main2) ||
+ AllZone.Phase.getPhase().equals(Constant.Phase.End_Of_Turn)) &&
+ !card.hasSickness() && card.isUntapped())
+ return true;
+ else
+ return false;
+
+ }
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && (c.getDealtCombatDmgToOppThisTurn() || c.getDealtDmgToOppThisTurn())
+ && CardFactoryUtil.canTarget(card, c) )
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -4946540988877576202L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature to destroy");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(card, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(c.isCreature() && zone.is(Constant.Zone.Play) && (c.getDealtCombatDmgToOppThisTurn() ||
+ c.getDealtDmgToOppThisTurn()) )
+ {
+ //tap ability
+ card.tap();
+
+ ability.setTargetCard(c);
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }//selectCard()
+ };//Input
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Destroy target creature that dealt damage to you this turn.");
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Hex"))
+ {
+ final Card[] target = new Card[6];
+ final int[] index = new int[1];
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1880229743741157304L;
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ CardListUtil.sortAttack(human);
+ CardListUtil.sortFlying(human);
+
+ if(6 <= human.size())
+ {
+ for(int i = 0; i < 6; i++) //should check to make sure none of these creatures have protection or cannot be the target of spells.
+ target[i] = human.get(i);
+ }
+
+ return 6 <= human.size();
+ }
+ public void resolve()
+ {
+ for(int i = 0; i < target.length; i++)
+ if(AllZone.GameAction.isCardInPlay(target[i]) && CardFactoryUtil.canTarget(card, target[i]) )
+ AllZone.GameAction.destroy(target[i]);
+ }//resolve()
+ };//SpellAbility
+
+
+ final Input input = new Input()
+ {
+ private static final long serialVersionUID = 5792813689927185739L;
+ public void showMessage()
+ {
+ int count = 6 - index[0];
+ AllZone.Display.showMessage("Select target " + count +" creatures to destroy");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ for(int i=0;i 0){
+ Card target = CardFactoryUtil.AI_getBestCreature(creature);
+ setTargetCard(target);
+ }
+ else
+ {
+ CardList enchantment = CardFactoryUtil.AI_getHumanEnchantment(card, true);
+ if (enchantment.size() > 0)
+ {
+ Card target = CardFactoryUtil.AI_getBestEnchantment(enchantment, card, true);
+ setTargetCard(target);
+ }
+ }
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap, 1 W B: Destroy target creature or enchantment.");
+
+ //ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -8099713981623158814L;
+
+ public void showMessage()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return (c.isEnchantment() || c.isCreature() ) && CardFactoryUtil.canTarget(card, c);
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, all, "Destroy target creature or enchantment.", true));
+ }
+ };
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wojek Embermage"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -1208482961653326721L;
+ public boolean canPlayAI()
+ {
+ return (CardFactoryUtil.AI_getHumanCreature(1, card, true).size() != 0) &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main2));
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list.shuffle();
+ setTargetCard(list.get(0));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ CardList list = getRadiance(getTargetCard());
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addDamage(1);
+ }
+ }//resolve()
+ //parameter Card c, is included in CardList
+ //no multi-colored cards
+ CardList getRadiance(Card c)
+ {
+ String color = CardUtil.getColor(c);
+ if(color.equals(Constant.Color.Colorless))
+ {
+ CardList list = new CardList();
+ list.add(c);
+ return list;
+ }
+
+ CardList sameColor = new CardList();
+
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++)
+ if(CardUtil.getColor(list.get(i)).equals(color))
+ sameColor.add(list.get(i));
+
+ return sameColor;
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("Radiance - tap: Wojek Embermage deals 1 damage to target creature and each other creature that shares a color with it.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Timberwatch Elf"))
+ {
+ final Card[] creature = new Card[1];
+ final int[] pump = new int[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = -2764970883655205904L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].addTempAttackBoost(-pump[0]);
+ creature[0].addTempDefenseBoost(-pump[0]);
+ }
+ }
+ };
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -7536296719726210357L;
+ public boolean canPlayAI()
+ {
+ CardList c = getAttackers();
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+ CardList getAttackers()
+ {
+ Card[] c = ComputerUtil.getAttackers().getAttackers();
+ CardList list = new CardList(c);
+ list = list.filter(new CardListFilter(){
+
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(card, c);
+ }
+
+ });
+
+ //remove "this card" from attackers, if it is there
+ list.remove(card);
+ list.shuffle();
+ return list;
+ }//getAttackers()
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ creature[0] = getTargetCard();
+ pump[0] = countElves();
+
+ creature[0].addTempAttackBoost(pump[0]);
+ creature[0].addTempDefenseBoost(pump[0]);
+
+ AllZone.EndOfTurn.addUntil(EOT);
+ }
+ }//resolve()
+ int countElves()
+ {
+ CardList elf = new CardList();
+ elf.addAll(AllZone.Human_Play.getCards());
+ elf.addAll(AllZone.Computer_Play.getCards());
+
+ elf = elf.getType("Elf");
+ return elf.size();
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Target creature gets +X/+X until end of turn, where X is the number of Elves in play.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mad Auntie"))
+ {
+ final Card[] creature = new Card[1];
+ final Command EOT = new Command()
+ {
+ private static final long serialVersionUID = -5143708900761432510L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(creature[0]))
+ {
+ creature[0].setShield(0);
+ }
+ }
+ };
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -1280855188535819509L;
+ public boolean canPlayAI()
+ {
+ return false;
+ }//canPlayAI()
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addShield();
+ AllZone.EndOfTurn.addUntil(EOT);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Regenerate another target Goblin.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Intrepid Hero"))
+ {
+ //tap ability - no cost - target creature
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -7825416464364928117L;
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) &&
+ getTargetCard().getNetAttack() >= 4)
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return getHumanCreatures().size() != 0;
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = getHumanCreatures();
+ human.shuffle();
+ setTargetCard(human.get(0));
+ }
+ CardList getHumanCreatures()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && 3 < c.getNetAttack();
+ }
+ });
+ return list;
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7024383930124942288L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature with power 4 or greater");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && 3 < card.getNetAttack())
+ {
+ ability.setTargetCard(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Destroy target creature with power 4 or greater.");
+
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tetsuo Umezawa"))
+ {
+ //tap ability - no cost - target creature
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+
+ private static final long serialVersionUID = -8034678094689484203L;
+ public void resolve()
+ {
+ CardList blockers = AllZone.Combat.getAllBlockers();
+
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) &&
+ (blockers.contains(getTargetCard()) || getTargetCard().isTapped()) )
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = -1939019440028116051L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target tapped or blocking creature.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ CardList blockers = AllZone.Combat.getAllBlockers();
+ if(card.isCreature() && zone.is(Constant.Zone.Play) &&
+ (blockers.contains(card) || card.isTapped()) )
+ {
+ ability.setTargetCard(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("U B B R, Tap: Destroy target tapped or blocking creature.");
+
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tor Wauki"))
+ {
+ //tap ability - no cost - target creature
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+
+ private static final long serialVersionUID = -8034678094689484203L;
+ public void resolve()
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+ CardList blockers = AllZone.Combat.getAllBlockers();
+
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) &&
+ (attackers.contains(getTargetCard()) || blockers.contains(getTargetCard()) ) )
+ {
+ getTargetCard().addDamage(2);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = -1939019440028116051L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target attacking or blocking creature.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+ CardList blockers = AllZone.Combat.getAllBlockers();
+ if(card.isCreature() && zone.is(Constant.Zone.Play) &&
+ (attackers.contains(card) || blockers.contains(card) ) )
+ {
+ ability.setTargetCard(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Tor Wauki deals 2 damage to target attacking or blocking creature.");
+
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Lady Caleria"))
+ {
+ //tap ability - no cost - target creature
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+
+ private static final long serialVersionUID = -8034678094689484203L;
+ public void resolve()
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+ CardList blockers = AllZone.Combat.getAllBlockers();
+
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) &&
+ (attackers.contains(getTargetCard()) || blockers.contains(getTargetCard()) ) )
+ {
+ getTargetCard().addDamage(3);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = -1939019440028116051L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target attacking or blocking creature.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+ CardList blockers = AllZone.Combat.getAllBlockers();
+ if(card.isCreature() && zone.is(Constant.Zone.Play) &&
+ (attackers.contains(card) || blockers.contains(card) ) )
+ {
+ ability.setTargetCard(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Lady Caleria deals 3 damage to target attacking or blocking creature.");
+
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Femeref Archers"))
+ {
+ //tap ability - no cost - target creature
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+
+ private static final long serialVersionUID = -4369831076920644547L;
+ public void resolve()
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) &&
+ attackers.contains(getTargetCard()) && getTargetCard().getKeyword().contains("Flying"))
+ {
+ getTargetCard().addDamage(4);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = 3455890565752527632L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target attacking creature with flying.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ CardList attackers = new CardList(AllZone.Combat.getAttackers());
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && card.getKeyword().contains("Flying") &&
+ attackers.contains(card))
+ {
+ ability.setTargetCard(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Femeref Archers deals 4 damage to target attacking creature with flying.");
+
+ ability.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Adarkar Valkyrie"))
+ {
+ //tap ability - no cost - target creature - EOT
+
+ final Card[] target = new Card[1];
+
+ final Command destroy = new Command()
+ {
+ private static final long serialVersionUID = -2433442359225521472L;
+
+ public void execute()
+ {
+ AllZone.Stack.add(new Ability(card, "0", "Return " +target[0] +" from graveyard to play")
+ {
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(target[0]);
+ //checks to see if card is still in the graveyard
+ if(AllZone.GameAction.isCardInZone(target[0], grave))
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ AllZone.GameAction.moveTo(play, target[0]);
+ target[0].setController(card.getController());
+ }
+ }
+ });
+ }//execute()
+ };
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 2777978927867867610L;
+
+ public void execute()
+ {
+ //resets the Card destroy Command
+ //target[0].addDestroy(Command.Blank);
+ target[0].removeDestroyCommand(destroy);
+
+ }
+ };
+
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -8454685126878522607L;
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()))
+ {
+ target[0] = getTargetCard();
+ AllZone.EndOfTurn.addUntil(untilEOT);
+
+ //when destroyed, return to play
+ //add triggered ability to target card
+ target[0].addDestroyCommand(destroy);
+ }//if
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input targetInput = new Input()
+ {
+ private static final long serialVersionUID = 913860087744941946L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-token creature other than this card");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ //must target non-token creature, and cannot target itself
+ if(c.isCreature() && (!c.isToken()) && (!c.equals(card)))
+ {
+ ability.setTargetCard(c);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: When target creature other than Adarkar Valkyrie is put into a graveyard this turn, return that card to play under your control.");
+
+ ability.setBeforePayMana(targetInput);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Imperious Perfect"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "G")
+ {
+ private static final long serialVersionUID = -3266607637871879336L;
+
+ public boolean canPlayAI()
+ {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+ public void chooseTargetAI() {card.tap();}
+
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Elf Warrior");
+ c.setImageName("G 1 1 Elf Warrior");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elf");
+ c.addType("Warrior");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+
+ ability.setDescription("G, tap: Put a 1/1 green Elf Warrior creature token into play.");
+ ability.setStackDescription("Imperious Perfect - Put a 1/1 green Elf Warrior creature token into play.");
+ ability.setBeforePayMana(new Input_PayManaCost(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wall of Kelp"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "U U")
+ {
+ private static final long serialVersionUID = 2893813929304858905L;
+
+ public boolean canPlayAI()
+ {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+ public void chooseTargetAI() {card.tap();}
+
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Kelp");
+ c.setManaCost("U");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Plant");
+ c.addType("Wall");
+ c.addIntrinsicKeyword("Defender");
+
+ c.setBaseAttack(0);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+
+ ability.setDescription("UU, tap: Put a 0/1 blue Kelp Wall creature token with defender into play.");
+ ability.setStackDescription("Wall of Kelp - Put a 0/1 blue Kelp Wall creature token with defender into play");
+ ability.setBeforePayMana(new Input_PayManaCost(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Vedalken Mastermind"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "U")
+ {
+ private static final long serialVersionUID = -6131368241135911606L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+
+ if (getTargetCard().isToken())
+ hand.remove(getTargetCard());
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -5218098811060156481L;
+
+ public void showMessage()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList choice = new CardList(play.getCards());
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, choice, "Select a permanent you control.", true));
+ }
+ };
+ card.addSpellAbility(ability);
+ ability.setDescription("U, tap: Return target permanent you control to its owner's hand.");
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Helldozer"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "B B B")
+ {
+ private static final long serialVersionUID = 6426884086364885861L;
+
+ public boolean canPlayAI()
+ {
+ if(CardFactoryUtil.AI_doesCreatureAttack(card))
+ return false;
+
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Land");
+ return land.size() != 0;
+ }
+
+ public void chooseTargetAI()
+ {
+ card.tap();
+
+ //target basic land that Human only has 1 or 2 in play
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Land");
+
+ Card target = null;
+
+ String[] name = {"Forest", "Swamp", "Plains", "Mountain", "Island"};
+ for(int i = 0; i < name.length; i++)
+ if(land.getName(name[i]).size() == 1)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+
+ //see if there are only 2 lands of the same type
+ if(target == null)
+ {
+ for(int i = 0; i < name.length; i++)
+ if(land.getName(name[i]).size() == 2)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+ }//if
+ if(target == null)
+ {
+ land.shuffle();
+ target = land.get(0);
+ }
+ setTargetCard(target);
+ }//chooseTargetAI()
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+
+ //if non-basic, untap Helldozer
+ if(! getTargetCard().getType().contains("Basic"))
+ card.untap();
+ }
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("BBB, tap: Destroy target land. If that land is nonbasic, untap Helldozer.");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetType(ability, "Land"));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cao Cao, Lord of Wei"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = 6760838700101179614L;
+ public void chooseTargetAI() {card.tap();}
+ public boolean canPlayAI()
+ {
+ int hand = AllZone.Human_Hand.getCards().length;
+ if((! CardFactoryUtil.AI_doesCreatureAttack(card)) && hand != 0)
+ return true;
+
+ return 2 <= hand;
+ }
+
+ public void resolve()
+ {
+ String player = AllZone.GameAction.getOpponent(card.getController());
+
+ if(player.equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard(2));
+ else
+ {
+ AllZone.GameAction.discardRandom(player);
+ AllZone.GameAction.discardRandom(player);
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ String opp = AllZone.GameAction.getOpponent(card.getController());
+ setStackDescription(card.getName() +" - " +opp +" discards 2 cards");
+
+ String phase = AllZone.Phase.getPhase();
+ String activePlayer = AllZone.Phase.getActivePlayer();
+
+ return super.canPlay() &&
+ phase.equals(Constant.Phase.Main1) &&
+ card.getController().equals(activePlayer);
+ }
+ };//SpellAbility
+
+ ability.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ ability.setDescription("tap: Target opponent discards two cards. Play this ability only during your turn, before the combat phase.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Gwendlyn Di Corci"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "0")
+ {
+
+ private static final long serialVersionUID = -4211234606012596777L;
+ public void chooseTargetAI() {setTargetPlayer(Constant.Player.Human); }
+ public boolean canPlayAI()
+ {
+ int hand = AllZone.Human_Hand.getCards().length;
+ return hand > 0;
+ }
+
+ public void resolve()
+ {
+ String player = getTargetPlayer();
+
+ AllZone.GameAction.discardRandom(player);
+
+ }//resolve()
+ public boolean canPlay()
+ {
+ setStackDescription(card.getName() +" - " +getTargetPlayer() +" discards a card at random.");
+
+ String activePlayer = AllZone.Phase.getActivePlayer();
+
+ return super.canPlay() &&
+ card.getController().equals(activePlayer);
+ }
+ };//SpellAbility
+
+ Input input = new Input()
+ {
+ private static final long serialVersionUID = 3312693459353844120L;
+
+ public void showMessage()
+ {
+ //prevents this from running multiple times, which it is for some reason
+ if(ability.getSourceCard().isUntapped())
+ {
+ ability.getSourceCard().tap();
+ stopSetNext(CardFactoryUtil.input_targetPlayer(ability));
+ }
+ }
+ };
+
+ ability.setDescription("Tap: Target player discards a card at random. Activate this ability only during your turn.");
+ ability.setBeforePayMana(input);
+ //ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Xira Arien"))
+ {
+ //mana tap ability
+ final Ability_Tap ability = new Ability_Tap(card, "G R B")
+ {
+
+ private static final long serialVersionUID = 5373361883064666451L;
+ public void chooseTargetAI() {setTargetPlayer(Constant.Player.Computer);}
+ public boolean canPlayAI()
+ {
+ int hand = AllZone.Computer_Hand.getCards().length;
+ int lib = AllZone.Computer_Library.getCards().length;
+ return hand < 6 && lib > 0;
+ }
+
+ public void resolve()
+ {
+ String player = getTargetPlayer();
+
+ AllZone.GameAction.drawCard(player);
+
+ }//resolve()
+ public boolean canPlay()
+ {
+
+ setStackDescription(card.getName() +" - " +getTargetPlayer() +" discards a card at random.");
+
+ return super.canPlay();
+ }
+ };//SpellAbility
+
+ ability.setDescription("Tap: Target player draws a card.");
+ //ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wayward Soul"))
+ {
+ //mana ability
+ final Ability ability = new Ability(card, "U")
+ {
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card) )
+ {
+ card.setBaseAttack(3);
+ card.setBaseDefense(2);
+ card.setIntrinsicKeyword(new ArrayList());
+ card.addIntrinsicKeyword("Flying");
+
+ card.setAssignedDamage(0);
+ card.setDamage(0);
+ card.untap();
+ AllZone.getZone(card).remove(card);
+
+ //put card on top of library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
+ library.add(card, 0);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 1469011418219527227L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription("Put " +card +" on top of its owner's library");
+
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ };
+ ability.setDescription("U: Put Wayward Soul on top of its owner's library.");
+ ability.setStackDescription("Put Wayward Soul on top of its owner's library.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Coastal Hornclaw"))
+ {
+ //sacrifice ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 7538741250040204529L;
+
+ public void execute()
+ {
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ CardList land = new CardList(AllZone.Computer_Play.getCards());
+ land = land.getType("Land");
+
+ CardList canBlock = CardFactoryUtil.AI_getHumanCreature(card, true);
+ canBlock = canBlock.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isUntapped();
+ }
+ });
+
+ return (land.size() != 0) &&
+ (! card.getKeyword().contains("Flying")) &&
+ CardFactoryUtil.AI_getHumanCreature("Flying", card, false).isEmpty() &&
+ (! card.hasSickness()) &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main1));
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList land = new CardList(AllZone.Computer_Play.getCards());
+ land = land.getType("Land");
+ land.shuffle();
+ AllZone.GameAction.sacrifice(land.get(0));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 4874019210748846864L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gains flying until EOT.");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList choice = new CardList(play.getCards());
+ choice = choice.getType("Land");
+ stopSetNext(CardFactoryUtil.input_sacrifice(ability, choice, "Select a land to sacrifice."));
+ }
+ };
+ ability.setStackDescription(card +" gains flying until end of turn.");
+ ability.setDescription("Sacrifice a land: Coastal Hornclaw gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Spitting Spider"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && c.getKeyword().contains("Flying");
+ }
+ });
+
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addDamage(1);
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 2004031367305867525L;
+
+ public void showMessage()
+ {
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList choice = new CardList(play.getCards());
+ choice = choice.getType("Land");
+ stopSetNext(CardFactoryUtil.input_sacrifice(ability, choice, "Select a land to sacrifice."));
+ }
+ };
+ ability.setStackDescription(card +" deals 1 damage to each creature with flying.");
+ ability.setDescription("Sacrifice a land: Spitting Spider deals 1 damage to each creature with flying.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Killer Whale"))
+ {
+ final Ability ability = new Ability(card, "U")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -8494294720368074013L;
+
+ public void execute()
+ {
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ ability.setStackDescription(card +" gains flying until end of turn.");
+ ability.setDescription("U: Killer Whale gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ // *************** START *********** START **************************
+ if (cardName.equals("Lay Waste") || cardName.equals("Stone Rain")
+ || cardName.equals("Ice Storm") || cardName.equals("Sinkhole"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4973311759179228894L;
+ public boolean canPlayAI()
+ {
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Basic");
+ return land.size() != 0;
+ }
+ public void chooseTargetAI()
+ {
+ // target basic land that Human only has 1 or 2 in play
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ land = land.getType("Basic");
+ Card target = null;
+ String[] name =
+ { "Forest", "Swamp", "Plains", "Mountain", "Island" };
+ for (int i = 0; i < name.length; i++)
+ if (land.getName(name[i]).size() == 1)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+ // see if there are only 2 lands of the same type
+ if (target == null)
+ {
+ for (int i = 0; i < name.length; i++)
+ if (land.getName(name[i]).size() == 2)
+ {
+ target = land.getName(name[i]).get(0);
+ break;
+ }
+ }// if
+ if (target == null)
+ {
+ land.shuffle();
+ target = land.get(0);
+ }
+ setTargetCard(target);
+ }// chooseTargetAI()
+ public void resolve()
+ {
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ AllZone.GameAction.destroy(getTargetCard());
+ }// resolve()
+ };// SpellAbility
+ card.clearSpellAbility();
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell,
+ "Land"));
+ card.addSpellAbility(spell);
+ if (cardName.equals("Lay Waste"))
+ {
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2"));
+ spell.setDescription("Destroy target land");
+ }
+ return card;
+ }// *************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Obsidian Fireheart"))
+ {
+ final Ability ability = new Ability(card, "1 R R")
+ {
+ public void resolve() {
+ Card c = getTargetCard();
+
+ if (AllZone.GameAction.isCardInPlay(c) && c.isLand() && (c.getCounters(Counters.BLAZE)==0) )
+ c.addCounter(Counters.BLAZE, 1);
+
+ }
+ public boolean canPlayAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList land = new CardList(play.getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isLand() && c.getCounters(Counters.BLAZE) < 1;
+ }
+ });
+
+ if (land.size() > 0)
+ setTargetCard(land.get(0));
+
+ return land.size() > 0;
+ }
+
+ };
+
+ ability.setDescription("1 R R: Put a blaze counter on target land without a blaze counter on it. For as long as that land has a blaze counter on it, it has \"At the beginning of your upkeep, this land deals 1 damage to you.\" (The land continues to burn after Obsidian Fireheart has left the battlefield.)");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetType(ability, "Land"));
+ card.addSpellAbility(ability);
+
+ }// *************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Glint-Eye Nephilim"))
+ {
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 5790680475821014099L;
+
+ public void execute()
+ {
+ card.addTempAttackBoost(-1);
+ card.addTempDefenseBoost(-1);
+ }
+ };
+
+ final Ability ability = new Ability(card, "1")
+ {
+ public boolean canPlayAI()
+ {
+ Card[] hand = AllZone.Computer_Hand.getCards();
+ return CardFactoryUtil.AI_doesCreatureAttack(card) && (hand.length != 0);
+ }
+ public void chooseTargetAI() {AllZone.GameAction.discardRandom(Constant.Player.Computer);}
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card) )
+ {
+ card.addTempAttackBoost(1);
+ card.addTempDefenseBoost(1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4302110760957471033L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gets +1/+1 until EOT.");
+ //stopSetNext(CardFactoryUtil.input_sacrifice(ability, choice, "Select a card to discard."));
+ stopSetNext(CardFactoryUtil.input_discard(ability, 1));
+
+ }
+ };
+ ability.setStackDescription(card +" gets +1/+1 until end of turn.");
+ ability.setDescription("1, Discard a card: Glint-Eye Nephilim gets +1/+1 until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wild Mongrel"))
+ {
+ //sacrifice ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -5563743272875711445L;
+
+ public void execute()
+ {
+ card.addTempAttackBoost(-1);
+ card.addTempDefenseBoost(-1);
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ Card[] hand = AllZone.Computer_Hand.getCards();
+ return CardFactoryUtil.AI_doesCreatureAttack(card) && (hand.length > 3);
+ }
+ public void chooseTargetAI() {AllZone.GameAction.discardRandom(Constant.Player.Computer);}
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addTempAttackBoost(1);
+ card.addTempDefenseBoost(1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4209163355325441624L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gets +1/+1 until EOT.");
+ //stopSetNext(CardFactoryUtil.input_sacrifice(ability, choice, "Select a card to discard."));
+ stopSetNext(CardFactoryUtil.input_discard(ability, 1));
+ //AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ }
+ };
+ ability.setStackDescription(card +" gets +1/+1 until end of turn.");
+ ability.setDescription("Discard a card: Wild Mongrel gets +1/+1 until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Hell-Bent Raider"))
+ {
+ final Command untilEOT = new Command()
+ {
+
+ private static final long serialVersionUID = -2693050198371979012L;
+
+ public void execute()
+ {
+ card.removeIntrinsicKeyword("Protection from white");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public void resolve()
+ {
+ AllZone.GameAction.discardRandom(card.getController());
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Protection from white");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ ability.setStackDescription(card +" gets Protection from white until end of turn.");
+ ability.setDescription("Discard a card at random: Hell-Bent Raider gets protection from white until end of turn.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Whiptongue Frog"))
+ {
+ //mana ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -2693050198371979012L;
+
+ public void execute()
+ {
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "U")
+ {
+ public boolean canPlayAI()
+ {
+ return (! card.hasSickness()) &&
+ (! card.getKeyword().contains("Flying")) &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main1));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 1268037036474796569L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gains flying until EOT.");
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ };
+ ability.setStackDescription("Whiptongue Frog gains flying until EOT.");
+ ability.setDescription("U: Whiptongue Frog gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sarcomite Myr"))
+ {
+ //mana ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -1726670429352834671L;
+
+ public void execute()
+ {
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "2")
+ {
+ public boolean canPlayAI()
+ {
+ return (! card.hasSickness()) &&
+ (! card.getKeyword().contains("Flying")) &&
+ (AllZone.Phase.getPhase().equals(Constant.Phase.Main1));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -685958984421033465L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gains flying until EOT.");
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ };
+ ability.setStackDescription(card +" - gains flying until EOT.");
+ ability.setDescription("2: Sarcomite Myr gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+
+ //ability 2
+ final Ability ability2 = new Ability(card, "2")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability2);
+ ability2.setDescription("2, Sacrifice Sarcomite Myr: Draw a card.");
+ ability2.setStackDescription("Sarcomite Myr - draw a card");
+ ability2.setBeforePayMana(new Input_PayManaCost_Ability(ability2.getManaCost(), new Command()
+ {
+ private static final long serialVersionUID = -4357239016463815380L;
+
+ public void execute()
+ {
+ AllZone.GameAction.sacrifice(card);
+ AllZone.Stack.add(ability2);
+ }
+ }));
+
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Goblin Balloon Brigade"))
+ {
+ //mana ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 3574792977266468264L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "R")
+ {
+ public boolean canPlayAI()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, false);
+ return flying.isEmpty() &&
+ (! card.hasSickness()) &&
+ (! card.getKeyword().contains("Flying")) &&
+ (! CardFactoryUtil.AI_getHumanCreature(card, true).isEmpty());
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 7757347395564372034L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gains flying until EOT.");
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ };
+ ability.setStackDescription("Goblin Balloon Brigade gains flying until EOT.");
+ ability.setDescription("R: Goblin Balloon Brigade gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Manta Riders"))
+ {
+ //mana ability - targets itself - until EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -8732007889935536106L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ card.removeIntrinsicKeyword("Flying");
+ }
+ };
+
+ //mana tap ability
+ final Ability ability = new Ability(card, "U")
+ {
+ public boolean canPlayAI()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, false);
+ return flying.isEmpty() &&
+ (! card.hasSickness()) &&
+ (! card.getKeyword().contains("Flying")) &&
+ (! CardFactoryUtil.AI_getHumanCreature(card, true).isEmpty());
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.addIntrinsicKeyword("Flying");
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -3889041123558196949L;
+
+ public void showMessage()
+ {
+ ability.setStackDescription(card +" gains flying until EOT.");
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ };
+ ability.setStackDescription(card.getName() +" gains flying until EOT.");
+ ability.setDescription("U: Manta Riders gains flying until end of turn.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Turtleshell Changeling"))
+ {
+ //mana ability - targets itself - until EOT
+ //mana ability
+ final Ability ability = new Ability(card, "1 U")
+ {
+ public boolean canPlayAI()
+ {
+ return CardFactoryUtil.AI_doesCreatureAttack(card) && card.getNetAttack() == 1;
+ }
+ public void resolve()
+ {
+ //in case ability is played twice
+ final int[] oldAttack = new int[1];
+ final int[] oldDefense = new int[1];
+
+ oldAttack[0] = card.getBaseAttack();
+ oldDefense[0] = card.getBaseDefense();
+
+ card.setBaseAttack(oldDefense[0]);
+ card.setBaseDefense(oldAttack[0]);
+
+ //EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -5494886974452901728L;
+
+ public void execute()
+ {
+ card.setBaseAttack(oldAttack[0]);
+ card.setBaseDefense(oldDefense[0]);
+ }
+ };
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//resolve()
+ };//SpellAbility
+
+
+ ability.setStackDescription(card +" - switch power and toughness until EOT.");
+ ability.setDescription("1 U: Switch Turtleshell Changeling's power and toughness until end of turn.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wings of Velis Vel"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5744842090293912606L;
+ public boolean canPlayAI()
+ {
+ Combat combat = ComputerUtil.getAttackers();
+ @SuppressWarnings("unused") // attack
+ Card[] attack = combat.getAttackers();
+
+ CardList small = new CardList(AllZone.Computer_Play.getCards());
+ small = small.getType("Creature");
+
+ //try to make a good attacker
+ if(0 < small.size())
+ {
+ CardListUtil.sortAttackLowFirst(small);
+ setTargetCard(small.get(0));
+
+ return true && AllZone.Phase.getPhase().equals(Constant.Phase.Main1);
+ }
+
+ return false;
+ }//canPlayAI()
+ public void resolve()
+ {
+ //in case ability is played twice
+ final int[] oldAttack = new int[1];
+ final int[] oldDefense = new int[1];
+
+ final Card card[] = new Card[1];
+ card[0] = getTargetCard();
+
+ oldAttack[0] = card[0].getBaseAttack();
+ oldDefense[0] = card[0].getBaseDefense();
+
+ card[0].setBaseAttack(4);
+ card[0].setBaseDefense(4);
+ card[0].addExtrinsicKeyword("Flying");
+
+ //EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 7236360479349324099L;
+
+ public void execute()
+ {
+ card[0].setBaseAttack(oldAttack[0]);
+ card[0].setBaseDefense(oldDefense[0]);
+
+ card[0].removeExtrinsicKeyword("Flying");
+ }
+ };
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+
+/*
+ //*************** START *********** START **************************
+if(cardName.equals("Epic Proportions"))
+{
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 358340213887424783L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ c.addSemiPermanentAttackBoost(5);
+ c.addSemiPermanentDefenseBoost(5);
+ c.addExtrinsicKeyword("Trample");
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+}//*************** END ************ END **************************
+
+*/
+
+
+
+
+//*************** START *********** START **************************
+if(cardName.equals("Epic Proportions"))
+{
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 358340213887424783L;
+
+ public boolean canPlay()
+ {
+ return true; // for flash, which is not working through the keyword for some reason
+ }
+
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ card.enchantCard(c);
+ System.out.println("Enchanted: " +getTargetCard());
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Command onEnchant = new Command()
+ {
+ private static final long serialVersionUID = 5133552158526053493L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ crd.addExtrinsicKeyword("Trample");
+ crd.addSemiPermanentAttackBoost(5);
+ crd.addSemiPermanentDefenseBoost(5);
+ }
+ }//execute()
+ };//Command
+
+
+ Command onUnEnchant = new Command()
+ {
+ private static final long serialVersionUID = -2404250578944336031L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ crd.removeExtrinsicKeyword("Trample");
+ crd.addSemiPermanentAttackBoost(-5);
+ crd.addSemiPermanentDefenseBoost(-5);
+ }
+
+ }//execute()
+ };//Command
+
+ Command onLeavesPlay = new Command()
+ {
+ private static final long serialVersionUID = -6076263565995301138L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ card.unEnchantCard(crd);
+ }
+ }
+ };
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+}//*************** END ************ END **************************
+
+//*************** START *********** START **************************
+if(cardName.equals("Mythic Proportions"))
+{
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 4227124619270545652L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ card.enchantCard(c);
+ System.out.println("Enchanted: " +getTargetCard());
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Command onEnchant = new Command()
+ {
+ private static final long serialVersionUID = -6642467768059387172L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ crd.addExtrinsicKeyword("Trample");
+ crd.addSemiPermanentAttackBoost(8);
+ crd.addSemiPermanentDefenseBoost(8);
+ }
+ }//execute()
+ };//Command
+
+
+ Command onUnEnchant = new Command()
+ {
+
+ private static final long serialVersionUID = 3550678810412528973L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ crd.removeExtrinsicKeyword("Trample");
+ crd.addSemiPermanentAttackBoost(-8);
+ crd.addSemiPermanentDefenseBoost(-8);
+ }
+
+ }//execute()
+ };//Command
+
+ Command onLeavesPlay = new Command()
+ {
+ private static final long serialVersionUID = -8590925715809196436L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ card.unEnchantCard(crd);
+ }
+ }
+ };
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+}//*************** END ************ END **************************
+
+//*************** START *********** START **************************
+if(cardName.equals("Nimbus Wings"))
+{
+ final SpellAbility spell = new Spell(card)
+ {
+
+
+ private static final long serialVersionUID = -4759884801420518565L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ for (int i=0;i 0)
+ {
+ setTargetCard(stuffy.get(0));
+ return true;
+ }
+ else
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ for (int i=0;i= list.get(i).getNetDefense()) && list.get(i).getNetAttack() >= 3)
+ {
+ setTargetCard(list.get(i));
+ return true;
+ }
+ }
+ }
+ return false;
+
+ }//canPlayAI()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ card.enchantCard(c);
+
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+}//*************** END ************ END **************************
+
+//*************** START *********** START **************************
+if(cardName.equals("Cessation"))
+{
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 3681531440398159146L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Creature");
+
+ if(list.isEmpty())
+ return false;
+
+ //else
+ CardListUtil.sortAttack(list);
+ CardListUtil.sortFlying(list);
+
+ for (int i=0;i());
+ c.addType("Creature");
+ c.addType("Treefolk");
+
+ c.setIntrinsicKeyword(new ArrayList());
+
+ c.clearSpellAbility();
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Control Magic"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7359753772138233155L;
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+
+ if(2 <= c.get(0).getNetAttack() && c.get(0).getKeyword().contains("Flying"))
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ CardListUtil.sortAttack(c);
+ if(4 <= c.get(0).getNetAttack())
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ return false;
+ }//canPlayAI()
+ public void resolve()
+ {
+
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ card.enchantCard(c);
+
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Command onEnchant = new Command()
+ {
+
+ private static final long serialVersionUID = -3423649303706656587L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ //set summoning sickness
+ if(crd.getKeyword().contains("Haste")){
+ crd.setSickness(false);
+ }
+ else{
+ crd.setSickness(true);
+ }
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone from = AllZone.getZone(crd);
+ from.remove(crd);
+
+ crd.setController(card.getController());
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController());
+ to.add(crd);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ }//execute()
+ };//Command
+
+ Command onUnEnchant = new Command()
+ {
+
+ private static final long serialVersionUID = -2365466450520529652L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ if (AllZone.GameAction.isCardInPlay(crd))
+ {
+ if(crd.getKeyword().contains("Haste")){
+ crd.setSickness(false);
+ }
+ else{
+ crd.setSickness(true);
+ }
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone from = AllZone.getZone(crd);
+ from.remove(crd);
+
+ String opp = AllZone.GameAction.getOpponent(crd.getController());
+ crd.setController(opp);
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, opp);
+ to.add(crd);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ }
+
+ }//execute()
+ };//Command
+
+ Command onLeavesPlay = new Command()
+ {
+
+
+ private static final long serialVersionUID = 8144460293841806556L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ card.unEnchantCard(crd);
+ }
+ }
+ };
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ //destroy doesn't work
+ if(cardName.equals("Sower of Temptation"))
+ {
+ final Card moveCreature[] = new Card[1];
+
+ final SpellAbility spell = new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -6432280175218503718L;
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+
+ if(2 <= c.get(0).getNetAttack() && c.get(0).getKeyword().contains("Flying"))
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ CardListUtil.sortAttack(c);
+ if(4 <= c.get(0).getNetAttack())
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+
+ return false;
+ }//canPlayAI()
+ public void resolve()
+ {
+ super.resolve();
+
+ Card c = getTargetCard();
+ moveCreature[0] = c;
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+
+ //set summoning sickness
+ if(c.getKeyword().contains("Haste")){
+ c.setSickness(false);
+ }
+ else{
+ c.setSickness(true);
+ }
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ c.setSickness(true);
+ c.setController(card.getController());
+
+ PlayerZone from = AllZone.getZone(c);
+ from.remove(c);
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController());
+ to.add(c);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+
+ card.addLeavesPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = -8961588142846220965L;
+
+ public void execute()
+ {
+ Card c = moveCreature[0];
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ c.setSickness(true);
+ c.setController(AllZone.GameAction.getOpponent(c.getController()));
+
+ PlayerZone from = AllZone.getZone(c);
+ from.remove(c);
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, c.getOwner());
+ to.add(c);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }//if
+ }//execute()
+ });//Command
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Terramorphic Expanse"))
+ {
+ //tap sacrifice
+ final Ability_Tap ability = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = 5441740362881917927L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ /*
+ //sacrifice Sakura-Tribe Elder if Human has any creatures
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Creature");
+ return list.size() != 0 && card.isUntapped();
+ */
+ }
+ public void chooseTargetAI()
+ {
+ AllZone.GameAction.sacrifice(card);
+ }
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList list = new CardList(library.getCards());
+ list = list.getType("Basic");
+ if (list.size() > 0 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+
+ }//canPlay()
+ public void resolve()
+ {
+ if(owner.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ CardList play = new CardList(AllZone.Computer_Play.getCards());
+ play = play.getType("Basic");
+
+ CardList library = new CardList(AllZone.Computer_Library.getCards());
+ library = library.getType("Basic");
+
+ //this shouldn't happen, but it is defensive programming, haha
+ if(library.isEmpty())
+ return;
+
+ Card land = null;
+
+ //try to find a basic land that isn't in play
+ for(int i = 0; i < library.size(); i++)
+ if(! play.containsName(library.get(i)))
+ {
+ land = library.get(i);
+ break;
+ }
+
+ //if not found
+ //library will have at least 1 basic land because canPlay() checks that
+ if(land == null)
+ land = library.get(0);
+
+ land.tap();
+ AllZone.Computer_Library.remove(land);
+ AllZone.Computer_Play.add(land);
+
+ AllZone.GameAction.shuffle(Constant.Player.Computer);
+ }//computerResolve()
+
+ public void humanResolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play , card.getController());
+
+ CardList basicLand = new CardList(library.getCards());
+ basicLand = basicLand.getType("Basic");
+
+ Object o = AllZone.Display.getChoiceOptional("Choose a basic land", basicLand.toArray());
+ if(o != null)
+ {
+ Card land = (Card)o;
+ land.tap();
+
+ library.remove(land);
+ play.add(land);
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4379321114820908030L;
+ boolean once = true;
+ public void showMessage()
+ {
+ //this is necessary in order not to have a StackOverflowException
+ //because this updates a card, it creates a circular loop of observers
+ if(once)
+ {
+ once = false;
+ AllZone.GameAction.sacrifice(card);
+
+ ability.setStackDescription(card.getController() +" - Search your library for a basic land card and put it into play tapped. Then shuffle your library.");
+ AllZone.Stack.add(ability);
+
+ stop();
+ }
+ }//showMessage()
+ };
+ card.addSpellAbility(ability);
+ ability.setDescription("tap, Sacrifice Terramorphic Expanse: Search your library for a basic land card and put it into play tapped. Then shuffle your library.");
+ ability.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Frostling"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI() {return getCreature().size() != 0;}
+
+ public void chooseTargetAI()
+ {
+ CardList list = getCreature();
+ list.shuffle();
+ setTargetCard(list.get(0));
+
+ AllZone.GameAction.sacrifice(card);
+ }
+ CardList getCreature()
+ {
+ //toughness of 1
+ CardList list = CardFactoryUtil.AI_getHumanCreature(1, card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ //only get 1/1 flyers or 2/1 creatures
+ return (2 <= c.getNetAttack()) || c.getKeyword().contains("Flying");
+ }
+ });
+ return list;
+ }//getCreature()
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(1);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("Sacrifice Frostling: Frostling deals 1 damage to target creature.");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability, new Command()
+ {
+ private static final long serialVersionUID = 3482118508536148313L;
+
+ public void execute()
+ {
+ AllZone.GameAction.sacrifice(card);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Bottle Gnomes"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ return AllZone.Computer_Life.getLife() < 3;
+
+ }
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0 && super.canPlay();
+ }//canPlay()
+ public void resolve()
+ {
+ if(owner.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ CardList play = new CardList(AllZone.Computer_Play.getCards());
+ play = play.getType("Basic");
+
+ CardList library = new CardList(AllZone.Computer_Library.getCards());
+ library = library.getType("Basic");
+
+ //this shouldn't happen, but it is defensive programming, haha
+ if(library.isEmpty())
+ return;
+
+ Card land = null;
+
+ //try to find a basic land that isn't in play
+ for(int i = 0; i < library.size(); i++)
+ if(! play.containsName(library.get(i)))
+ {
+ land = library.get(i);
+ break;
+ }
+
+ //if not found
+ //library will have at least 1 basic land because canPlay() checks that
+ if(land == null)
+ land = library.get(0);
+
+ land.tap();
+ AllZone.Computer_Library.remove(land);
+ AllZone.Computer_Play.add(land);
+
+ AllZone.GameAction.shuffle(Constant.Player.Computer);
+ }//computerResolve()
+ public void humanResolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play , card.getController());
+
+ CardList basicLand = new CardList(library.getCards());
+ basicLand = basicLand.getType("Basic");
+ if(basicLand.isEmpty())
+ return;
+
+ Object o = AllZone.Display.getChoiceOptional("Choose a basic land", basicLand.toArray());
+ if(o != null)
+ {
+ Card land = (Card)o;
+ land.tap();
+
+ library.remove(land);
+ play.add(land);
+ }
+
+ AllZone.GameAction.shuffle(card.getController());
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 1959709104655340395L;
+ boolean once = true;
+ public void showMessage()
+ {
+ //this is necessary in order not to have a StackOverflowException
+ //because this updates a card, it creates a circular loop of observers
+ if(once)
+ {
+ once = false;
+ AllZone.GameAction.sacrifice(card);
+ AllZone.Stack.add(ability);
+
+ stop();
+ }
+ }//showMessage()
+ };
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+ ability.setDescription("Sacrifice Sakura-Tribe Elder: Search your library for a basic land card, put that card into play tapped, then shuffle your library.");
+ ability.setStackDescription("Search your library for a basic land card, put that card into play tapped, then shuffle your library.");
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Transluminant"))
+ {
+ final Command atEOT = new Command()
+ {
+ private static final long serialVersionUID = -5126793112740563180L;
+
+ public void execute()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Spirit");
+ c.setImageName("W 1 1 Spirit");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Spirit");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Flying");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play , card.getController());
+ play.add(c);
+ }//execute()
+ };//Command
+
+ final Ability ability = new Ability(card, "W")
+ {
+ public boolean canPlayAI()
+ { /*
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Creature");
+
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2) && list.size() != 0;
+ */
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ AllZone.GameAction.sacrifice(card);
+ }
+
+ public void resolve()
+ {
+ AllZone.EndOfTurn.addAt(atEOT);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("W, Sacrifice Transluminant: Put a 1/1 white Spirit creature token with flying into play at end of turn.");
+ ability.setStackDescription("Put a 1/1 white Spirit creature token with flying into play at end of turn.");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability(ability.getManaCost(), new Command()
+ {
+ private static final long serialVersionUID = -6553009833190713980L;
+
+ public void execute()
+ {
+ AllZone.GameAction.sacrifice(card);
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Llanowar Behemoth"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public boolean canPlayAI()
+ {
+ return (getUntapped().size() != 0) && CardFactoryUtil.AI_doesCreatureAttack(card);
+ }
+ public void chooseTargetAI()
+ {
+ Card c = getUntapped().get(0);
+ c.tap();
+ setTargetCard(c);
+ }
+ CardList getUntapped()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && c.isUntapped() && (!CardFactoryUtil.AI_doesCreatureAttack(c));
+ }
+ });
+ return list;
+ }//getUntapped()
+
+ public void resolve()
+ {
+ card.addTempAttackBoost(1);
+ card.addTempDefenseBoost(1);
+
+ Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 6445782721494547172L;
+
+ public void execute()
+ {
+ card.addTempAttackBoost(-1);
+ card.addTempDefenseBoost(-1);
+ }//execute()
+ };//Command
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 7721637420366357272L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select an untapped creature you control");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isCreature() && zone.is(Constant.Zone.Play, card.getController()) && c.isUntapped())
+ {
+ ability.setStackDescription(card +" gets +1/+1 until end of turn.");
+ c.tap();
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }
+ };//Input
+ ability.setBeforePayMana(target);
+ ability.setDescription("Tap an untapped creature you control: Llanowar Behemoth gets +1/+1 until end of turn.");
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Memnarch"))
+ {
+ //has 2 non-tap abilities that effects itself
+ final SpellAbility ability1 = new Ability(card, "1 U U")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addType("Artifact");
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList list = getCreature();
+ return list.size() != 0;
+ }
+ public void chooseTargetAI()
+ {
+ Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
+ setTargetCard(target);
+ }//chooseTargetAI()
+ CardList getCreature()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && (!c.isArtifact());
+ }
+ });
+ return list;
+ }//getCreature()
+ };//SpellAbility
+
+ //**** start of ability2
+ final SpellAbility ability2 = new Ability(card, "3 U")
+ {
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ //gain control of target artifact
+ PlayerZone from = AllZone.getZone(Constant.Zone.Play, getTargetCard().getController());
+ from.remove(getTargetCard());
+
+
+ getTargetCard().setController(card.getController());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController());
+ to.add(getTargetCard());
+ to.setUpdate(true);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+
+
+// AllZone.GameAction.moveTo(play, getTargetCard());
+
+ //TODO: controller probably is not set correctly
+ //TODO: when you take control, the creature looses type "Artifact" since
+ // GameAction.moveTo() makes a new card object
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList list = getArtifactCreatures();
+ return list.size() != 0;
+ }
+ public void chooseTargetAI()
+ {
+ CardList list = getArtifactCreatures();
+ Card target = CardFactoryUtil.AI_getBestCreature(list);
+ if(target == null)
+ target = AllZone.Human_Play.get(0);
+
+ setTargetCard(target);
+ }
+ CardList getArtifactCreatures()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Artifact");
+ list = list.getType("Creature");
+ return list;
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability1);
+ card.addSpellAbility(ability2);
+
+ ability1.setDescription("1UU: Target permanent becomes an artifact in addition to its other types.(This effect doesn't end at end of turn.)");
+ ability2.setDescription("3U: Gain control of target artifact.(This effect doesn't end at end of turn.)");
+
+ ability1.setBeforePayMana(CardFactoryUtil.input_targetType(ability1, "All"));
+ ability2.setBeforePayMana(CardFactoryUtil.input_targetType(ability2, "Artifact"));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Meloku the Clouded Mirror"))
+ {
+ final SpellAbility ability = new Ability(card, "1")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+ c.setToken(true);
+ c.setImageName("U 1 1 Illusion");
+ c.setName("Illusion");
+
+ c.setManaCost("U");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Flying");
+ c.addType("Creature");
+ c.addType("Illusion");
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ //TODO: the "bounced" land should be chosen by the user
+ //instead of "automatically" done for him
+ CardList island = new CardList(play.getCards());
+ island = island.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.getType().contains("Land") && c.isTapped();
+ }
+ });
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ if(! island.isEmpty())
+ AllZone.GameAction.moveTo(hand, island.get(0));
+ }//resolve()
+
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("1, Return a land you control to its owner's hand: Put a 1/1 blue Illusion creature token with flying into play.");
+ ability.setStackDescription("Put 1/1 token with flying into play");
+ ability.setBeforePayMana(new Input_PayManaCost(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Squall Drifter"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "W")
+ {
+ private static final long serialVersionUID = 3862705592994953819L;
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ c.tap();
+ }
+ public boolean canPlayAI() {return false;}
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("W, tap: Tap target creature.");
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("That Which Was Taken"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "4")
+ {
+ private static final long serialVersionUID = -8996435083734446340L;
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ c.addExtrinsicKeyword("Indestructible");
+ }
+ public boolean canPlayAI()
+ {
+ CardList creatures = getCreatures();
+
+ for (int i = 0; i < creatures.size(); i++)
+ {
+ if (!creatures.get(i).getKeyword().contains("Indestructible"))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ //Card c = CardFactoryUtil.AI_getBestCreature(getCreatures());
+ CardList a = getCreatures();
+ CardListUtil.sortAttack(a);
+ CardListUtil.sortFlying(a);
+
+ Card c = null;
+
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (!a.get(i).getKeyword().contains("Indestructible"))
+ {
+ c = a.get(i);
+ break;
+ }
+ }
+
+ setTargetCard(c);
+ }
+ CardList getCreatures()
+ {
+ CardList list = new CardList();
+ list.addAll(AllZone.Computer_Play.getCards());
+ return list.getType("Creature");
+ }
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 137806881250205274L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target permanent");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play) && c != card)//cannot target self
+ {
+ ability.setTargetCard(c);
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ }
+ };//Input -- target
+
+ ability.setBeforePayMana(target);
+ ability.setDescription("4, tap: Tap a divinity counter on target permanent other than That Which Was Taken.");
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Stern Judge"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 3059547795996737707L;
+ public void resolve()
+ {
+ AllZone.Human_Life.subtractLife(countSwamps("Human"));
+ AllZone.Computer_Life.subtractLife(countSwamps("Computer"));
+ }
+ int countSwamps(String player)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+ CardList swamps = new CardList(play.getCards());
+ swamps = swamps.getType("Swamp");
+ return swamps.size();
+ }
+ public boolean canPlayAI()
+ {
+ int computer = countSwamps(Constant.Player.Computer);
+ int human = countSwamps(Constant.Player.Human);
+
+ if((computer >= AllZone.Computer_Life.getLife()) || (human == 0))
+ return false;
+
+ return computer <= human;
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Each player loses 1 life for each Swamp he or she controls.");
+ ability.setStackDescription("Stern Judge - Each player loses 1 life for each Swamp he or she controls");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cackling Imp") || cardName.equals("Blightspeaker"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -8034678094689484203L;
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(1);
+ }
+ public boolean canPlayAI()
+ {
+ //computer should play ability if this creature doesn't attack
+ Combat c = ComputerUtil.getAttackers();
+ CardList list = new CardList(c.getAttackers());
+
+ //could this creature attack?, if attacks, do not use ability
+ return (! list.contains(card));
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Target player loses 1 life.");
+ ability.setStackDescription(card.getName() + " - Opponent loses 1 life.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sea Gate Loremaster"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+
+ private static final long serialVersionUID = -1701216509507402535L;
+ public boolean canPlayAI() {return false;}
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(play.getCards());
+ list = list.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c) {
+ return c.getType().contains("Ally") || c.getKeyword().contains("Changeling");
+ }
+
+ });
+
+ for (int i=0;i 3 && 6 < AllZone.Computer_Life.getLife();
+ }//canPlayAI()
+ public void resolve()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return ! c.getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card, c);
+ }
+ });
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addDamage(4);
+
+ AllZone.Human_Life.subtractLife(4);
+ AllZone.Computer_Life.subtractLife(4);
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Hammerfist Giant deals 4 damage to each creature without flying and each player.");
+ ability.setStackDescription("Hammerfist Giant - deals 4 damage to each creature without flying and each player.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Urborg Syphon-Mage"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "2 B")
+ {
+ private static final long serialVersionUID = -1965170715774280112L;
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(2);
+
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(2);
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ public boolean canPlay()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ return super.canPlay() && hand.getCards().length != 0;
+ }
+ public boolean canPlayAI()
+ {
+ int life = AllZone.Human_Life.getLife();
+ Card[] hand = AllZone.Computer_Hand.getCards();
+ return ((life < 11) || (5 < AllZone.Phase.getTurn())) &&
+ hand.length > 0;
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("2B, tap, Discard a card: Each other player loses 2 life. You gain life equal to the life lost this way.");
+ ability.setStackDescription("Urborg Syphon-Mage - Opponent loses 2 life, and you gain 2 life");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("2 B", new Command()
+ {
+ private static final long serialVersionUID = 1186455545951390853L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Spectral Procession"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6118842682065463016L;
+ public void resolve()
+ {
+ makeToken();
+ makeToken();
+ makeToken();
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Spirit");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Flying");
+
+ c.setName("Spirit");
+ c.setImageName("W 1 1 Spirit");
+
+ play.add(c);
+ }
+ };
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Stangg")){
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setName("Stangg Twin");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("R G");
+ c.setToken(true);
+
+ c.addType("Legendary");
+ c.addType("Creature");
+ c.addType("Human");
+ c.addType("Warrior");
+ c.setBaseAttack(3);
+ c.setBaseDefense(4);
+
+ c.addLeavesPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 3367390368512271319L;
+
+ public void execute() {
+ if (AllZone.GameAction.isCardInPlay(card))
+ AllZone.GameAction.sacrifice(card);
+ }
+
+ });
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ }
+ };
+ ability.setStackDescription("When Stangg enters the battlefield, if Stangg is on the battlefield, put a legendary 3/4 red and green Human Warrior creature token named Stangg Twin onto the battlefield.");
+
+ card.addComesIntoPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 6667896040611028600L;
+
+ public void execute() {
+ AllZone.Stack.add(ability);
+ }
+ });
+
+ card.addLeavesPlayCommand(new Command()
+ {
+ private static final long serialVersionUID = 1786900359843939456L;
+
+ public void execute() {
+ CardList list = new CardList();
+ list.addAll(AllZone.Computer_Play.getCards());
+ list.addAll(AllZone.Human_Play.getCards());
+ list = list.getName("Stangg Twin");
+
+ if (list.size() == 1)
+ AllZone.GameAction.removeFromGame(list.get(0));
+ }
+ });
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Llanowar Mentor"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "G")
+ {
+ private static final long serialVersionUID = 752280918226277729L;
+
+ public void resolve()
+ {
+ makeToken();
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elf");
+ c.addType("Druid");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+
+ //custom settings
+ c.setName("Llanowar Elves");
+ c.setImageName("G 1 1 Llanowar Elves");
+ //c.addIntrinsicKeyword("tap: add G");
+ c.addSpellAbility(new Ability_Mana(card, "tap: add G")
+ {
+ private static final long serialVersionUID = 7871036527184588884L;
+ });
+
+
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlay()
+ {
+ Card c[] = AllZone.getZone(Constant.Zone.Hand, card.getController()).getCards();
+
+ return super.canPlay() && (0 < c.length);
+ }
+
+ public boolean canPlayAI()
+ {
+ boolean canDiscard = 0 < AllZone.Computer_Hand.getCards().length;
+ return canPlay() && canDiscard && AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("G, tap, Discard a card: Put a 1/1 green Elf Druid creature token named Llanowar Elves into play with \"tap: add G\" ");
+ ability.setStackDescription("Llanowar Mentor - Put a 1/1 token into play");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("G", new Command()
+ {
+ private static final long serialVersionUID = -8140640118045101485L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sparkspitter"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "R")
+ {
+ private static final long serialVersionUID = -6381252527344512333L;
+
+ public void resolve()
+ {
+ makeToken();
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = CardFactory.this.getCard("Spark Elemental", card.getController());
+ c.setToken(true);
+ c.setImageName("R 3 1 Spark Elemental");
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlay()
+ {
+ Card c[] = AllZone.getZone(Constant.Zone.Hand, card.getController()).getCards();
+
+ return super.canPlay() && (0 < c.length);
+ }
+
+ public boolean canPlayAI()
+ {
+ boolean canDiscard = 0 < AllZone.Computer_Hand.getCards().length;
+ return canPlay() && canDiscard;
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("R, tap, Discard a card: Put a 3/1 red Elemental creature token named Spark Elemental into play with trample, haste, and \"At end of turn, sacrifice Spark Elemental.\" ");
+ ability.setStackDescription("Sparkspitter - Put a 3/1 token into play");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("R", new Command()
+ {
+ private static final long serialVersionUID = 4717424466422508064L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sliversmith"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1")
+ {
+ private static final long serialVersionUID = -901356795848120643L;
+
+ public void resolve()
+ {
+ makeToken();
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("1");
+ c.setToken(true);
+
+ c.addType("Artifact");
+ c.addType("Creature");
+ c.addType("Sliver");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+
+ //custom settings
+ c.setName("Metallic Sliver");
+ c.setImageName("C 1 1 Metallic Sliver");
+
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlay()
+ {
+ Card c[] = AllZone.getZone(Constant.Zone.Hand, card.getController()).getCards();
+
+ return super.canPlay() && (0 < c.length);
+ }
+
+ public boolean canPlayAI()
+ {
+ boolean canDiscard = 0 < AllZone.Computer_Hand.getCards().length;
+ return canPlay() && canDiscard && AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("1, tap, Discard a card: Put a 1/1 Sliver artifact creature token named Metallic Sliver into play.");
+ ability.setStackDescription(card +" - Put a 1/1 token into play");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("1", new Command()
+ {
+ private static final long serialVersionUID = 7980998398222481323L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cloudseeder"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "U")
+ {
+ private static final long serialVersionUID = -4685908556244137496L;
+
+ public void resolve()
+ {
+ makeToken();
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("U");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Faerie");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+
+ //custom settings
+ c.setName("Cloud Sprite");
+ c.setImageName("U 1 1 Cloud Sprite");
+ c.addIntrinsicKeyword("Flying");
+ c.addIntrinsicKeyword("This creature can block only creatures with flying");
+
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlay()
+ {
+ Card c[] = AllZone.getZone(Constant.Zone.Hand, card.getController()).getCards();
+
+ return super.canPlay() && (0 < c.length);
+ }
+
+ public boolean canPlayAI()
+ {
+ boolean canDiscard = 0 < AllZone.Computer_Hand.getCards().length;
+ return canPlay() && canDiscard && AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("U, tap, Discard a card: Put a 1/1 blue Sprite creature token named Cloud Sprite into play with flying and \"this creature can block only creatures with flying\".");
+ ability.setStackDescription("Cloudseeker - Put a 1/1 token into play");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("U", new Command()
+ {
+ private static final long serialVersionUID = 7707504858274558816L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Goldmeadow Lookout"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "G")
+ {
+ private static final long serialVersionUID = -8413409735529340094L;
+
+ public void resolve()
+ {
+ makeToken();
+
+ //computer discards here, todo: should discard when ability put on stack
+ if(card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+ }
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Kithkin");
+ c.addType("Soldier");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+
+ //custom settings
+ c.setName("Goldmeadow Harrier");
+ c.setImageName("W 1 1 Goldmeadow Harrier");
+ final SpellAbility ability = new Ability_Tap(c, "W")
+ {
+ private static final long serialVersionUID = -7327585136675896817L;
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ c.tap();
+ }
+ public boolean canPlayAI() {return false;}
+ };//SpellAbility
+ c.addSpellAbility(new Spell_Permanent(c));
+ c.addSpellAbility(ability);
+ ability.setDescription("W, tap: Tap target creature.");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+
+
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlay()
+ {
+ Card c[] = AllZone.getZone(Constant.Zone.Hand, card.getController()).getCards();
+
+ return super.canPlay() && (0 < c.length);
+ }
+
+ public boolean canPlayAI()
+ {
+ boolean canDiscard = 0 < AllZone.Computer_Hand.getCards().length;
+ return canPlay() && canDiscard && AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
+ }
+ };//SpellAbility
+
+ card.addSpellAbility(ability);
+ ability.setDescription("W, tap, Discard a card: Put a 1/1 white Kithkin Soldier creature token named Goldmeadow Harrier into play with \"W, tap target creature.\"");
+ ability.setStackDescription("Goldmeadow Lookout - Put a 1/1 token into play");
+ ability.setBeforePayMana(new Input_PayManaCost_Ability("W", new Command()
+ {
+ private static final long serialVersionUID = 8621733943286161557L;
+
+ public void execute()
+ {
+ card.tap();
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.Stack.add(ability);
+ }
+ }));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Goldmeadow Harrier") || cardName.equals("Loxodon Mystic")
+ || cardName.equals("Master Decoy"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "W")
+ {
+
+ private static final long serialVersionUID = 4424848120984319655L;
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ c.tap();
+ }
+ public boolean canPlayAI() {return false;}
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("W, tap: Tap target creature.");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Silent Attendant"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2602340080268657851L;
+ public void resolve()
+ {
+
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(1);
+ }
+ public boolean canPlayAI()
+ {
+ //computer should play ability if this creature doesn't attack
+ Combat c = ComputerUtil.getAttackers();
+ CardList list = new CardList(c.getAttackers());
+
+ //could this creature attack?, if attacks, do not use ability
+ return (! list.contains(card));
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: You gain 1 life.");
+ ability.setStackDescription(card.getName() + " - you gain 1 life.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ghost-Lit Redeemer"))
+ {
+ final SpellAbility ability = new Ability_Tap(card, "W")
+ {
+ private static final long serialVersionUID = -7119153679100849498L;
+
+ public boolean canPlayAI() {return AllZone.Phase.getPhase().equals(Constant.Phase.Main2);}
+
+ public void resolve()
+ {
+ Card c = card;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(c.getController());
+ life.addLife(2);
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("W, tap: You gain 2 life");
+ ability.setStackDescription("Computer gains 2 life");
+
+ final Command paid = new Command()
+ {
+ private static final long serialVersionUID = 3649597692883194760L;
+
+ public void execute()
+ {
+ Card c = card;
+ c.tap();
+ AllZone.Human_Play.updateObservers();//so the card will tap at the correct time
+
+ ability.setStackDescription(c.getController()+" gains 2 life");
+ AllZone.Stack.add(ability);
+ AllZone.InputControl.resetInput();
+ }
+ };
+ ability.setBeforePayMana(new Input_PayManaCost_Ability(ability.getManaCost(), paid, Command.Blank));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tremor"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3451888160398198322L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c) {
+ return !c.getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card, c) &&
+ c.getNetDefense() == 1;
+ }
+ });
+ computer = computer.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return !c.getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card, c) &&
+ c.getNetDefense() == 1;
+ }
+ });
+
+ // the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size() - 1;
+ }
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ if(! all.get(i).getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card,all.get(i)))
+ all.get(i).addDamage(1);
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Reviving Dose"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3239301336328919121L;
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(3);
+
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Swords to Plowshares"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4752934806606319269L;
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ //add life
+ String player = getTargetCard().getController();
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.addLife(getTargetCard().getNetAttack());
+
+ //remove card from play
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.getType("Creature");
+ creature = creature.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(card,c);
+ }
+ });
+ return creature.size() != 0 && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ CardList play = new CardList(AllZone.Human_Play.getCards());
+ Card target = CardFactoryUtil.AI_getBestCreature(play, card);
+ setTargetCard(target);
+ }
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Unmake"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -9194035528349589512L;
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ //remove card from play
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.getType("Creature");
+ creature = creature.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(card,c);
+ }
+ });
+ return creature.size() != 0 && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ CardList play = new CardList(AllZone.Human_Play.getCards());
+ Card target = CardFactoryUtil.AI_getBestCreature(play);
+ setTargetCard(target);
+ }
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Crib Swap"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4567382566960071562L;
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ String player = getTargetCard().getController();
+ makeToken(player);
+
+ //remove card from play
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.getType("Creature");
+ return creature.size() != 0 && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ CardList play = new CardList(AllZone.Human_Play.getCards());
+ Card target = CardFactoryUtil.AI_getBestCreature(play);
+ setTargetCard(target);
+ }
+ void makeToken(String player)
+ {
+ Card c = new Card();
+
+ c.setName("Shapeshifter");
+ c.setName("C 1 1 Shapeshifter");
+
+ c.setOwner(player);
+ c.setController(player);
+
+ c.setManaCost("");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Shapeshifter");
+ c.addIntrinsicKeyword("Changeling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+ play.add(c);
+ }//makeToken()
+
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Demonic Tutor") || cardName.equals("Diabolic Tutor") || cardName.equals("Grim Tutor"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 1481169060428051519L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ Object check = AllZone.Display.getChoiceOptional("Select card", AllZone.Human_Library.getCards());
+ if(check != null)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, (Card)check);
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+
+ //lose 3 life
+ if(cardName.equals("Grim Tutor"))
+ {
+ String player = Constant.Player.Human;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.subtractLife(3);
+ }
+ }
+ public void computerResolve()
+ {
+ Card[] library = AllZone.Computer_Library.getCards();
+ CardList list = new CardList(library);
+
+ //pick best creature
+ Card c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null)
+ c = library[0];
+ //System.out.println("comptuer picked - " +c);
+ AllZone.Computer_Library.remove(c);
+ AllZone.Computer_Hand.add(c);
+
+ //lose 3 life
+ if(cardName.equals("Grim Tutor"))
+ {
+ String player = Constant.Player.Computer;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.subtractLife(3);
+ }
+ }
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ return library.getCards().length != 0 && AllZone.Phase.getActivePlayer().equals(card.getController())
+ && !AllZone.Phase.getPhase().equals("End of Turn");
+ }
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList();
+ creature.addAll(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ return creature.size() != 0;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Entomb"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4724906962713222211L;
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ Object check = AllZone.Display.getChoiceOptional("Select card", AllZone.Human_Library.getCards());
+ if(check != null)
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ AllZone.GameAction.moveTo(grave, (Card)check);
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+ }
+ public void computerResolve()
+ {
+ Card[] library = AllZone.Computer_Library.getCards();
+ CardList list = new CardList(library);
+
+
+ //pick best creature
+ Card c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null)
+ c = library[0];
+ //System.out.println("comptuer picked - " +c);
+ AllZone.Computer_Library.remove(c);
+ AllZone.Computer_Graveyard.add(c);
+ }
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ return library.getCards().length != 0;
+ }
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList();
+ creature.addAll(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ return creature.size() != 0;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Do or Die"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8241241003478388362L;
+
+ public boolean canPlayAI()
+ {
+ return 4 <= CardFactoryUtil.AI_getHumanCreature(card, true).size() && 4 < AllZone.Phase.getTurn();
+ }
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, getTargetPlayer());
+ CardList list = new CardList(play.getCards());
+ list = list.getType("Creature");
+
+ list.shuffle();
+
+ for(int i = 0; i < list.size() / 2; i++)
+ AllZone.GameAction.destroyNoRegeneration(list.get(i));
+ }
+ };//SpellAbility
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Hymn to Tourach"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 42470566751344693L;
+
+ public boolean canPlayAI()
+ {
+ return AllZone.Human_Hand.size() > 0;
+ }
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.discardRandom(opponent);
+ AllZone.GameAction.discardRandom(opponent);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Beacon of Destruction"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6653675303299939465L;
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addDamage(5);
+ done();
+ }
+ else
+ AllZone.GameAction.moveToGraveyard(card);
+ }
+ else
+ {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(5);
+ done();
+ }
+ }//resolve()
+ void done()
+ {
+ //shuffle card back into the library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ library.add(card);
+ AllZone.GameAction.shuffle(card.getController());
+ }
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHumanCreatureOrPlayer());
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell, true));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Capsize"))
+ {
+ final SpellAbility spell_one = new Spell(card)
+ {
+ private static final long serialVersionUID = 7688777028599839669L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ target[0] = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, target[0].getController());
+
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ if (!target[0].isToken())
+ AllZone.GameAction.moveTo(hand ,target[0]);
+ else
+ AllZone.GameAction.removeFromGame(target[0]);
+
+ }
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility spell_two = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -2399079881132655853L;
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 3 < AllZone.Phase.getTurn() && 0 < human.size();
+
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+
+ public void resolve()
+ {
+
+ final Card[] target = new Card[1];
+ target[0] = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, target[0].getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ if (!target[0].isToken())
+ AllZone.GameAction.moveTo(hand ,target[0]);
+ else
+ AllZone.GameAction.removeFromGame(target[0]);
+ }
+ done();
+ }//resolve()
+ void done()
+ {
+ //return card to the hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+ };//SpellAbility
+ spell_two.setManaCost("4 U U");
+
+ spell_one.setDescription("Return target permanent to its owner's hand.");
+ spell_two.setDescription("Buyback 3 - Pay 4 U U, put this card into your hand as it resolves.");
+ spell_two.setIsBuyBackAbility(true);
+
+ Input runtime1 = new Input()
+ {
+
+ private static final long serialVersionUID = 6884105724632382299L;
+
+ public void showMessage()
+ {
+ PlayerZone human = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList perms = new CardList();
+ perms.addAll(human.getCards());
+ perms.addAll(comp.getCards());
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell_one, perms, "Select target permanent.", true));
+ }
+ };
+
+ Input runtime2 = new Input()
+ {
+ private static final long serialVersionUID = 8564956495965504679L;
+
+ public void showMessage()
+ {
+ PlayerZone human = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList perms = new CardList();
+ perms.addAll(human.getCards());
+ perms.addAll(comp.getCards());
+
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell_two, perms, "Select target permanent.", true));
+ }
+ };
+
+ spell_one.setBeforePayMana(runtime1);
+ spell_two.setBeforePayMana(runtime2);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Whispers of the Muse"))
+ {
+ final SpellAbility spell_one = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 8341386638247535343L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility spell_two = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -131686114078716307L;
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ done();
+ }//resolve()
+ void done()
+ {
+ //return card to the hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+ };//SpellAbility
+ spell_two.setManaCost("5 U");
+
+ spell_one.setDescription("Draw a card.");
+ spell_one.setStackDescription(cardName + " - " +card.getController() + " draws a card.");
+ spell_two.setDescription("Buyback 5 - Pay 5 U , put this card into your hand as it resolves.");
+ spell_two.setStackDescription(cardName + " - (Buyback) " +card.getController() + " draws a card.");
+ spell_two.setIsBuyBackAbility(true);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Elvish Fury"))
+ {
+ final SpellAbility spell_one = new Spell(card)
+ {
+ private static final long serialVersionUID = 3356401944678089378L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 7120352016188545025L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-2);
+ target[0].addTempDefenseBoost(-2);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ target[0].addTempAttackBoost(2);
+ target[0].addTempDefenseBoost(2);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility spell_two = new Spell(card)
+ {
+ private static final long serialVersionUID = 3898017438147188882L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+
+ CardList list = new CardList(c.getAttackers());
+ CardListUtil.sortFlying(list);
+
+ Card[] att = list.toArray();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 280295105716586978L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-2);
+ target[0].addTempDefenseBoost(-2);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ target[0].addTempAttackBoost(2);
+ target[0].addTempDefenseBoost(2);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ done();
+ }
+ }//resolve()
+ void done()
+ {
+ //return card to the hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+ };//SpellAbility
+ spell_two.setManaCost("4 G");
+
+ spell_one.setDescription("Target creature gets +2/+2 until end of turn.");
+ spell_two.setDescription("Buyback 4 - Pay 4G, put this card into your hand as it resolves.");
+
+ spell_one.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell_one));
+ spell_two.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell_two));
+
+ spell_two.setIsBuyBackAbility(true);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ramosian Revivalist"))
+ {
+ @SuppressWarnings("unused") // costMinusOne
+ String costMinusOne = "";
+ int a = Integer.parseInt("6");
+ a--;
+ costMinusOne = Integer.toString(a);
+ final int converted = a;
+ final String player = card.getController();
+
+ final SpellAbility ability = new Ability_Tap(card, "6")
+ {
+ private static final long serialVersionUID = 2675327938055139432L;
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i0)
+ return true;
+ else
+ return false;
+
+ }
+
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList rebels = new CardList();
+ CardList list = new CardList(grave.getCards());
+ list = list.getType("Rebel");
+
+ if (list.size()>0)
+ {
+ for (int i=0;i < list.size(); i++)
+ {
+ if (CardUtil.getConvertedManaCost(list.get(i).getManaCost()) <= converted)
+ {
+ rebels.add(list.get(i));
+ }
+
+ }
+
+ if (rebels.size() > 0)
+ {
+ if (player.equals(Constant.Player.Computer))
+ {
+ Card rebel = CardFactoryUtil.AI_getBestCreature(rebels);
+ grave.remove(rebel);
+ play.add(rebel);
+ }
+ else //human
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target Rebel", rebels.toArray());
+ Card rebel = (Card)o;
+ grave.remove(rebel);
+ play.add(rebel);
+ }
+ }//rebels.size() >0
+ }//list.size() > 0
+ }//resolve
+ };
+ ability.setDescription("6: Return target Rebel permanent card with converted mana cost 5 or less from your graveyard to play.");
+ ability.setStackDescription(card.getName() +" - return Rebel from graveyard to play.");
+ card.addSpellAbility(ability);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Marrow-Gnawer"))
+ {
+ final String player = card.getController();
+
+ final SpellAbility ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 447190529377334168L;
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+ CardList cards = new CardList(play.getCards());
+
+ Card c = getTargetCard();
+ if (c != null)
+ {
+ AllZone.GameAction.sacrifice(c);
+
+ CardList rats = new CardList();
+
+ for (int i=0;i < cards.size(); i++)
+ {
+ if (cards.get(i).getType().contains("Rat") || cards.get(i).getKeyword().contains("Changeling")){
+ Card k = cards.get(i);
+ rats.add(k);
+ }
+ }
+
+ if (!c.getName().equals("Marrow-Gnawer"))
+ {
+ for (int j=0; j < rats.size()-1; j++)
+ {
+ makeToken();
+ }
+ }
+ else //some weird thing when targeting marrow himself, number of rats is different... so here's a hack:
+ {
+ for (int k=0; k < rats.size(); k++)
+ {
+ makeToken();
+ }
+ }
+ }
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Rat");
+
+ for (int i=0;i < list.size(); i++)
+ {
+ String name = list.get(i).getName();
+ if (!name.equals("Marrow-Gnawer") && !name.equals("Relentless Rats"))
+ setTargetCard(list.get(i));
+ if (name.equals("B 1 1 Rat"))
+ {
+ setTargetCard(list.get(i));
+ break;
+ }
+
+ }
+
+ if (getTargetCard() == null)
+ System.out.println("getTargetCard null");
+ if(getTargetCard() != null && list.size() > 3)
+ return true;
+ else
+ return false;
+ }
+
+
+ public void makeToken()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Rat");
+ c.setImageName("B 1 1 Rat");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Rat");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }
+
+
+ };//ability
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 8552290582665041908L;
+
+ public void showMessage()
+ {
+ CardList rats = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ rats = rats.getType("Rat");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, rats, "Select a Rat to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(ability);
+ ability.setDescription("Tap, Sacrifice a rat: Put X 1/1 black Rat creature tokens into play, where X is the number of Rats you control.");
+ ability.setStackDescription(card.getName() + " - Put X 1/1 black Rat creature tokens into play, where X is the number of Rats you control.");
+ ability.setBeforePayMana(runtime);
+
+
+ }//*************** END ************ END **************************
+ //*************** START *********** START **************************
+ if(cardName.equals("Arcanis the Omnipotent"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 4743686230518855738L;
+
+ public boolean canPlayAI()
+ {
+ return true;
+ }
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };//SpellAbility
+
+ final SpellAbility ability2 = new Ability(card,"2 U U")
+ {
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getOwner());
+
+ card.untap();
+ AllZone.getZone(card).remove(card);
+ if (!card.isToken())
+ hand.add(card);
+
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ }; //ability2
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Draw three cards.");
+ ability.setStackDescription("Arcanis - " + card.getController() + " draws three cards.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+
+ card.addSpellAbility(ability2);
+ ability2.setStackDescription(card.getController() + " returns Arcanis back to owner's hand.");
+ ability2.setDescription("2 U U: Return Arcanis the Omnipotent to its owner's hand.");
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Lab Rats"))
+ {
+ final Command makeToken = new Command()
+ {
+ private static final long serialVersionUID = -6979735250385389139L;
+
+ public void execute()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Rat");
+ c.setImageName("B 1 1 Rat");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Rat");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//execute()
+ };//Command
+
+ final SpellAbility spell_one = new Spell(card)
+ {
+ private static final long serialVersionUID = -8112024383172056976L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ makeToken.execute();
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility spell_two = new Spell(card)
+ {
+ private static final long serialVersionUID = -7503701530510847636L;
+
+ public void resolve()
+ {
+ makeToken.execute();
+
+ //return card to the hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+
+ public boolean canPlayAI()
+ {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+ };//SpellAbility
+
+ spell_one.setManaCost("B");
+ spell_two.setManaCost("4 B");
+
+ spell_one.setDescription("Put a 1/1 black Rat token into play.");
+ spell_two.setDescription("Buyback 4 - Pay 4B, put this card into your hand as it resolves.");
+
+ spell_one.setStackDescription("Lab Rats - Put a 1/1 black Rat token into play");
+ spell_two.setStackDescription("Lab Rats - Buyback, Put a 1/1 black Rat token into play");
+
+ spell_two.setIsBuyBackAbility(true);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sprout Swarm"))
+ {
+ final Command makeToken = new Command()
+ {
+ private static final long serialVersionUID = 648546709124047998L;
+
+ public void execute()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//execute()
+ };//Command
+
+ final SpellAbility spell_one = new Spell(card)
+ {
+ private static final long serialVersionUID = -609007714604161377L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ makeToken.execute();
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility spell_two = new Spell(card)
+ {
+ private static final long serialVersionUID = -1387385820860395676L;
+
+ public void resolve()
+ {
+ makeToken.execute();
+
+ //return card to the hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+ };//SpellAbility
+
+ spell_one.setManaCost("1 G");
+ spell_two.setManaCost("4 G");
+
+ spell_one.setDescription("Put a 1/1 green Saproling token into play. -- Sorry no convoke yet.");
+ spell_two.setDescription("Buyback 3 - Pay 4G, put this card into your hand as it resolves.");
+
+ spell_one.setStackDescription("Sprout Swarm - Put a 1/1 green Saproling token into play");
+ spell_two.setStackDescription("Sprout Swarm - Buyback, Put a 1/1 green Saproling token into play");
+
+ spell_two.setIsBuyBackAbility(true);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Threaten") || cardName.equals("Act of Treason"))
+ {
+ final PlayerZone[] orig = new PlayerZone[1];
+ final PlayerZone[] temp = new PlayerZone[1];
+ final String[] controllerEOT = new String[1];
+ final Card[] target = new Card[1];
+
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 5310901886760561889L;
+
+ public void execute()
+ {
+ //if card isn't in play, do nothing
+ if(! AllZone.GameAction.isCardInPlay(target[0]))
+ return;
+
+ target[0].setController(controllerEOT[0]);
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ //moveTo() makes a new card, so you don't have to remove "Haste"
+ //AllZone.GameAction.moveTo(playEOT[0], target[0]);
+ temp[0].remove(target[0]);
+ orig[0].add(target[0]);
+ target[0].untap();
+ target[0].removeExtrinsicKeyword("Haste");
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+ }//execute()
+ };//Command
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3447822168516135816L;
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ orig[0] = AllZone.getZone(getTargetCard());
+ controllerEOT[0] = getTargetCard().getController();
+ target[0] = getTargetCard();
+
+ //set the controller
+ getTargetCard().setController(card.getController());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(getTargetCard());
+ temp[0] = play;
+ orig[0].remove(getTargetCard());
+
+ ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true);
+ ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true);
+
+
+ getTargetCard().untap();
+ getTargetCard().addExtrinsicKeyword("Haste");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//is card in play?
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ //only use this card if creatures power is greater than 2
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ for(int i = 0; i < list.size(); i++)
+ if(2 < list.get(i).getNetAttack())
+ return true;
+
+ return false;
+ }//canPlayAI()
+ public void chooseTargetAI()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(list));
+ }
+ };//SpellAbility
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Beacon of Unrest"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7614131436905786565L;
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone grave = AllZone.getZone(c);
+
+ if(AllZone.GameAction.isCardInZone(c, grave) && (c.isArtifact() || c.isCreature()))
+ {
+ //set the correct controller if needed
+ c.setController(card.getController());
+
+ //card changes zones
+ AllZone.getZone(c).remove(c);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ //shuffle card back into the library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ library.add(card);
+ AllZone.GameAction.shuffle(card.getController());
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getCreaturesAndArtifacts().length != 0;
+ }
+
+ public Card[] getCreaturesAndArtifacts()
+ {
+ CardList graveyardCards = new CardList();
+ graveyardCards.addAll(AllZone.Human_Graveyard.getCards());
+ graveyardCards.addAll(AllZone.Computer_Graveyard.getCards());
+
+ CardList graveyardCreaturesAndArtifacts = graveyardCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isArtifact() || c.isCreature();
+ }
+ });
+
+ return graveyardCreaturesAndArtifacts.toArray();
+ }
+ public void chooseTargetAI()
+ {
+ Card c[] = getCreaturesAndArtifacts();
+ Card biggest = c[0];
+ for(int i = 0; i < c.length; i++)
+ if(biggest.getNetAttack() < c[i].getNetAttack())
+ biggest = c[i];
+
+ setTargetCard(biggest);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -83460850846474327L;
+
+ public void showMessage()
+ {
+ Object check = AllZone.Display.getChoiceOptional("Select creature", getCreaturesAndArtifacts());
+ if(check != null)
+ {
+ spell.setTargetCard((Card)check);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ else
+ stop();
+ }//showMessage()
+
+ //duplicated from SpellAbility above ^^^^^^^^
+ public Card[] getCreaturesAndArtifacts()
+ {
+ CardList graveyardCards = new CardList();
+ graveyardCards.addAll(AllZone.Human_Graveyard.getCards());
+ graveyardCards.addAll(AllZone.Computer_Graveyard.getCards());
+
+ CardList graveyardCreaturesAndArtifacts = graveyardCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isArtifact() || c.isCreature();
+ }
+ });
+
+ return graveyardCreaturesAndArtifacts.toArray();
+ }
+ };//Input
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Breath of Life") || cardName.equals("Resurrection") || cardName.equals("False Defeat") || cardName.equals("Zombify"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5799646914112924814L;
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone grave = AllZone.getZone(c);
+
+ if(AllZone.GameAction.isCardInZone(c, grave))
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
+ AllZone.GameAction.moveTo(play, c);
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getCreatures().length != 0;
+ }
+ public Card[] getCreatures()
+ {
+ CardList creature = new CardList();
+ PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ creature.addAll(zone.getCards());
+ creature = creature.getType("Creature");
+ return creature.toArray();
+ }
+ public void chooseTargetAI()
+ {
+ Card c[] = getCreatures();
+ Card biggest = c[0];
+ for(int i = 0; i < c.length; i++)
+ if(biggest.getNetAttack() < c[i].getNetAttack())
+ biggest = c[i];
+
+ setTargetCard(biggest);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -3717723884199321767L;
+
+ public void showMessage()
+ {
+ Object check = AllZone.Display.getChoiceOptional("Select creature", getCreatures());
+ if(check != null)
+ {
+ spell.setTargetCard((Card)check);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ else
+ stop();
+ }//showMessage()
+
+ public Card[] getCreatures()
+ {
+ CardList creature = new CardList();
+ PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ creature.addAll(zone.getCards());
+ creature = creature.getType("Creature");
+ return creature.toArray();
+ }
+ };//Input
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Horde of Notions"))
+ {
+ final Ability ability = new Ability(card, "W U B R G")
+ {
+ public void resolve()
+ {
+ Card c = null;
+ if (card.getController().equals("Human"))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select Elemental", getCreatures());
+ c = (Card)o;
+
+ }
+ else
+ {
+ c = getAIElemental();
+ }
+
+ PlayerZone grave = AllZone.getZone(c);
+
+ if(AllZone.GameAction.isCardInZone(c, grave))
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
+ AllZone.GameAction.moveTo(play, c);
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getCreatures().length != 0 && AllZone.GameAction.isCardInPlay(card);
+ }
+ public Card[] getCreatures()
+ {
+ CardList creature = new CardList();
+ PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ creature.addAll(zone.getCards());
+ creature = creature.getType("Elemental");
+ return creature.toArray();
+ }
+ public Card getAIElemental()
+ {
+ Card c[] = getCreatures();
+ Card biggest = c[0];
+ for(int i = 0; i < c.length; i++)
+ if(biggest.getNetAttack() < c[i].getNetAttack())
+ biggest = c[i];
+
+ return biggest;
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+
+ ability.setDescription("W U B R G: You may play target Elemental card from your graveyard without paying its mana cost.");
+ //ability.setBeforePayMana(new Input_);
+ ability.setStackDescription("Horde of Notions - play Elemental card from graveyard without paying its mana cost.");
+ ability.setBeforePayMana(new Input_PayManaCost(ability));
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Animate Dead"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 182812167945075560L;
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone grave = AllZone.getZone(c);
+
+ if(AllZone.GameAction.isCardInZone(c, grave))
+ {
+ c.addSemiPermanentAttackBoost(-1);
+ c.setController(card.getController());
+
+ play.add(c);
+ grave.remove(c);
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ return getCreatures().length != 0;
+ }
+ public Card[] getCreatures()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+ list = list.getType("Creature");
+
+ return list.toArray();
+ }
+ public boolean canPlayAI()
+ {
+ CardList all = new CardList(getCreatures());
+ if(all.isEmpty())
+ return false;
+
+ Card c = CardFactoryUtil.AI_getBestCreature(all);
+
+ if(2 < c.getNetAttack() && 2 < c.getNetDefense())
+ return true;
+
+ return false;
+ }
+
+ public void chooseTargetAI()
+ {
+ Card c[] = getCreatures();
+ Card biggest = c[0];
+ for(int i = 0; i < c.length; i++)
+ if(biggest.getNetAttack() < c[i].getNetAttack())
+ biggest = c[i];
+
+ setTargetCard(biggest);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 9027742835781889044L;
+
+ public void showMessage()
+ {
+ Object check = AllZone.Display.getChoiceOptional("Select creature", getCreatures());
+ if(check != null)
+ {
+ spell.setTargetCard((Card)check);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ else
+ stop();
+ }//showMessage()
+
+ public Card[] getCreatures()
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+ list = list.getType("Creature");
+
+ return list.toArray();
+ }
+ };//Input
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Blinding Light"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -631672055247954361L;
+
+ public void resolve()
+ {
+ CardList nonwhite = new CardList();
+ nonwhite.addAll(AllZone.Human_Play.getCards());
+ nonwhite.addAll(AllZone.Computer_Play.getCards());
+ nonwhite = nonwhite.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && (!CardUtil.getColors(c).contains(Constant.Color.White));
+ }
+ });
+ for(int i = 0; i < nonwhite.size(); i++)
+ nonwhite.get(i).tap();
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ //the computer seems to play this card at stupid times
+ return false;
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Raise the Alarm"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3022771853846089829L;
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ for (int i = 0; i < 2; i++)
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Soldier");
+ c.setImageName("W 1 1 Soldier");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Soldier");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Dragon Fodder"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -6704097906643840324L;
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ for (int i = 0; i < 2; i++)
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Goblin");
+ c.setImageName("R 1 1 Goblin");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Goblin");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Empty the Warrens"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 1439643889038241969L;
+
+ public void resolve()
+ {
+ int stormCount = 0;
+
+ //get storm count
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Graveyard.getCards());
+ list.addAll(AllZone.Computer_Graveyard.getCards());
+
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < list.size(); i++)
+ if(list.get(i).getTurnInZone() == AllZone.Phase.getTurn())
+ stormCount++;
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ for (int i = 0; i < 2 * stormCount; i++)
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Goblin");
+ c.setImageName("R 1 1 Goblin");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Goblin");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Feudkiller's Verdict"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5532477141899236266L;
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(10);
+
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerLife oppLife = AllZone.GameAction.getPlayerLife(opponent);
+
+ if(oppLife.getLife() < life.getLife())
+ makeToken();
+ }//resolve()
+
+ void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Giant Warrior");
+ c.setImageName("W 5 5 Giant Warrior");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Giant");
+ c.addType("Warrior");
+ c.setBaseAttack(5);
+ c.setBaseDefense(5);
+
+ play.add(c);
+ }//makeToken()
+
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Reach of Branches"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 2723115210677439611L;
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Treefolk Shaman");
+ c.setImageName("G 2 5 Treefolk Shaman");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Treefolk");
+ c.addType("Shaman");
+ c.setBaseAttack(2);
+ c.setBaseDefense(5);
+
+ play.add(c);
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pyroclasm"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8035123529251645470L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ if (CardFactoryUtil.canDamage(card,all.get(i)))
+ all.get(i).addDamage(2);
+ }
+ }
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ human = CardListUtil.filterToughness(human, 2);
+ computer = CardListUtil.filterToughness(computer, 2);
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1;
+ }//canPlayAI()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Volcanic Fallout"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8274309635261086286L;
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ if (CardFactoryUtil.canDamage(card,all.get(i)))
+ all.get(i).addDamage(2);
+ }
+
+ PlayerLife compLife = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
+ compLife.subtractLife(2);
+
+ PlayerLife humLife = AllZone.GameAction.getPlayerLife(Constant.Player.Human);
+ humLife.subtractLife(2);
+
+ }
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ human = CardListUtil.filterToughness(human, 2);
+ computer = CardListUtil.filterToughness(computer, 2);
+
+ PlayerLife compLife = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1 && compLife.getLife() > 3;
+ }//canPlayAI()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Flamebreak"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4224693616606508949L;
+
+ public boolean canPlayAI()
+ {
+ return AllZone.Computer_Life.getLife()>3;
+ }
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ if(! all.get(i).getKeyword().contains("Flying"))
+ {
+ if (CardFactoryUtil.canDamage(card, all.get(i)))
+ {
+ all.get(i).setShield(0);
+ all.get(i).addDamage(3);
+ }
+ }
+
+ AllZone.Human_Life.subtractLife(3);
+ AllZone.Computer_Life.subtractLife(3);
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Renewed Faith") || cardName.equals("Dosan's Oldest Chant") || cardName.equals("Nourish"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1133816506198725425L;
+
+ public boolean canPlay()
+ {
+ setStackDescription(card.getName() +" - " +card.getController() +" gains 6 life.");
+ return super.canPlay();
+ }
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(6);
+ }
+ };
+ spell.setDescription("You gain 6 life.");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ if (cardName.equals("Renewed Faith")) {
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "1 W"));
+ card.addCycleCommand(new Command(){
+ private static final long serialVersionUID = 7699412574052780825L;
+
+ public void execute()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(2);
+ }
+ });
+ }
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("TestLife"))
+ {
+ SpellAbility ability1 = new Ability_Activated(card, "1")
+ {
+ private static final long serialVersionUID = -7597743923692184213L;
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(1);
+ }
+ };
+ ability1.setStackDescription(card.getController() +" gains 1 life");
+ ability1.setDescription("1: gain 1 life");
+ card.addSpellAbility(ability1);
+
+ SpellAbility ability2 = new Ability_Activated(card, "1")
+ {
+ private static final long serialVersionUID = 1423759257249171223L;
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.subtractLife(1);
+ }
+ };
+ ability2.setStackDescription(card.getController() +" looses 1 life");
+ ability2.setDescription("1: loose 1 life");
+ card.addSpellAbility(ability2);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Life Burst"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5653342880372240806L;
+
+ public void resolve()
+ {
+ CardList count = new CardList();
+ count.addAll(AllZone.Human_Graveyard.getCards());
+ count.addAll(AllZone.Computer_Graveyard.getCards());
+ count = count.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.getName().equals("Life Burst");
+ }
+ });
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(getTargetPlayer());
+ life.addLife(4 + (4 * count.size()));
+ }
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetComputer());
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Accumulated Knowledge"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7650377883588723237L;
+
+ public void resolve()
+ {
+ CardList count = new CardList();
+ count.addAll(AllZone.Human_Graveyard.getCards());
+ count.addAll(AllZone.Computer_Graveyard.getCards());
+ count = count.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.getName().equals("Accumulated Knowledge");
+ }
+ });
+
+ for (int i=0;i<=count.size();i++)
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ }
+ };
+ spell.setDescription("Draw a card, then draw cards equal to the number of cards named Accumulated Knowledge in all graveyards.");
+ spell.setStackDescription(cardName + " - Draw a card, then draw cards equal to the number of cards named Accumulated Knowledge in all graveyards.");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wit's End"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3829311830858468029L;
+
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetPlayer());
+ Card c[] = hand.getCards();
+ for(int i = 0; i < c.length; i++)
+ AllZone.GameAction.discard(c[i]);
+ }
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cranial Extraction"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8127696608769903507L;
+
+ @SuppressWarnings("unchecked") // Comparator
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ Card choice = null;
+
+ //check for no cards in library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, opponent);
+
+ if(library.size() == 0) //this is not right, but leaving it in here for now.
+ return;
+
+ //human chooses
+ if(opponent.equals(Constant.Player.Computer))
+ {
+ CardList all = AllZone.CardFactory.getAllCards();
+ all.sort(new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ return a.getName().compareTo(b.getName());
+ }
+ });
+ choice = (Card) AllZone.Display.getChoice("Choose", removeLand(all.toArray()));
+
+ Card[] showLibrary = library.getCards();
+ Comparator com = new TableSorter(new CardList(showLibrary), 2, true);
+ Arrays.sort(showLibrary, com);
+
+ AllZone.Display.getChoiceOptional("Opponent's Library", showLibrary);
+ AllZone.GameAction.shuffle(opponent);
+ }//if
+ else//computer chooses
+ {
+ //the computer cheats by choosing a creature in the human players library or hand
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Hand.getCards());
+ all.addAll(AllZone.Human_Library.getCards());
+
+ CardList four = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(c.isLand())
+ return false;
+
+ return 3 < CardUtil.getConvertedManaCost(c.getManaCost());
+ }
+ });
+ if(! four.isEmpty())
+ choice = CardUtil.getRandom(four.toArray());
+ else
+ choice = CardUtil.getRandom(all.toArray());
+
+ }//else
+ remove(choice, opponent);
+ AllZone.GameAction.shuffle(opponent);
+ }//resolve()
+
+ void remove(Card c, String player)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
+
+ CardList all = new CardList();
+ all.addAll(hand.getCards());
+ all.addAll(grave.getCards());
+ all.addAll(library.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ if(all.get(i).getName().equals(c.getName())){
+ if(player.equals(Constant.Player.Human)){
+ AllZone.GameAction.moveTo(AllZone.Human_Removed, all.get(i));
+ }
+ else{
+ AllZone.GameAction.moveTo(AllZone.Computer_Removed, all.get(i));
+ }
+ }
+ }//remove()
+
+ public boolean canPlayAI()
+ {
+ Card[] c = removeLand(AllZone.Human_Library.getCards());
+ return 0 < c.length;
+ }
+ Card[] removeLand(Card[] in)
+ {
+ CardList c = new CardList(in);
+ c = c.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return !c.isLand();
+ }
+ });
+ return c.toArray();
+ }//removeLand()
+ };//SpellAbility spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(new Input_PayManaCost(spell));
+ spell.setStackDescription(card.getName() +" - targeting opponent");
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Coercion"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7200945225788294439L;
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ Card choice = null;
+
+ //check for no cards in hand on resolve
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, opponent);
+ Card[] handChoices = removeLand(hand.getCards());
+
+ if(handChoices.length == 0)
+ return;
+
+ //human chooses
+ if(opponent.equals(Constant.Player.Computer))
+ {
+ choice = (Card) AllZone.Display.getChoice("Choose", handChoices);
+ }
+ else//computer chooses
+ {
+ choice = CardUtil.getRandom(handChoices);
+ }
+
+ AllZone.GameAction.discard(choice);
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ Card[] c = removeLand(AllZone.Human_Hand.getCards());
+ return 0 < c.length;
+ }
+
+ Card[] removeLand(Card[] in)
+ {
+ return in;
+ }//removeLand()
+ };//SpellAbility spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(new Input_PayManaCost(spell));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Brainbite"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6967309558624188256L;
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ Card choice = null;
+
+ //check for no cards in hand on resolve
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, opponent);
+ Card[] handChoices = removeLand(hand.getCards());
+
+ if(handChoices.length == 0){
+ AllZone.GameAction.drawCard(card.getController());
+ return;
+ }
+
+
+ //human chooses
+ if(opponent.equals(Constant.Player.Computer))
+ {
+ choice = (Card) AllZone.Display.getChoice("Choose", handChoices);
+ }
+ else//computer chooses
+ {
+ choice = CardUtil.getRandom(handChoices);
+ }
+
+ AllZone.GameAction.discard(choice);
+ AllZone.GameAction.drawCard(card.getController());
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ Card[] c = removeLand(AllZone.Human_Hand.getCards());
+ return 0 < c.length;
+ }
+
+ Card[] removeLand(Card[] in)
+ {
+ return in;
+ }//removeLand()
+ };//SpellAbility spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(new Input_PayManaCost(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Thoughtseize") || cardName.equals("Distress"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5338238621454661783L;
+
+ public void resolve()
+ {
+ if(cardName.equals("Thoughtseize"))
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+
+ Card choice = null;
+
+ //check for no cards in hand on resolve
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetPlayer());
+ Card[] handChoices = removeLand(hand.getCards());
+
+ if(handChoices.length == 0)
+ return;
+
+ //human chooses
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ choice = (Card) AllZone.Display.getChoice("Choose", handChoices);
+ }
+ else//computer chooses
+ {
+ choice = CardUtil.getRandom(handChoices);
+ }
+
+ AllZone.GameAction.discard(choice);
+ }//resolve()
+
+ public boolean canPlayAI()
+ {
+ Card[] c = removeLand(AllZone.Human_Hand.getCards());
+ return 0 < c.length;
+ }
+
+ Card[] removeLand(Card[] in)
+ {
+ CardList c = new CardList(in);
+ c = c.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return !c.isLand();
+ }
+ });
+ return c.toArray();
+ }//removeLand()
+ };//SpellAbility spell
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Douse in Gloom"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7134826062024728943L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = getCreature();
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+ CardList getCreature()
+ {
+ CardList out = new CardList();
+ CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ list.shuffle();
+
+ for(int i = 0; i < list.size(); i++)
+ if((list.get(i).getNetAttack() >= 2) && (list.get(i).getNetDefense() <= 2))
+ out.add(list.get(i));
+
+ //in case human player only has a few creatures in play, target anything
+ if(out.isEmpty() &&
+ 0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() &&
+ 3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())
+ {
+ out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true).toArray());
+ CardListUtil.sortFlying(out);
+ }
+ return out;
+ }//getCreature()
+
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ getTargetCard().addDamage(2);
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(2);
+ }
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Echoing Decay"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3154935854257358023L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = getCreature();
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+ CardList getCreature()
+ {
+ CardList out = new CardList();
+ CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ list.shuffle();
+
+ for(int i = 0; i < list.size(); i++)
+ if((list.get(i).getNetAttack() >= 2) && (list.get(i).getNetDefense() <= 2))
+ out.add(list.get(i));
+
+ //in case human player only has a few creatures in play, target anything
+ if(out.isEmpty() &&
+ 0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() &&
+ 3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())
+ {
+ out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true).toArray());
+ CardListUtil.sortFlying(out);
+ }
+ return out;
+ }//getCreature()
+
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ final Card c = getTargetCard();
+
+ c.addTempAttackBoost(-2);
+ c.addTempDefenseBoost(-2);
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = 1327455269456577020L;
+
+ public void execute()
+ {
+ c.addTempAttackBoost(2);
+ c.addTempDefenseBoost(2);
+ }
+ });
+
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+
+ list = list.getName(getTargetCard().getName());
+ list.remove(getTargetCard());
+
+ if (!getTargetCard().isFaceDown())
+ for(int i = 0; i < list.size(); i++)
+ {
+ final Card crd = list.get(i);
+
+ crd.addTempAttackBoost(-2);
+ crd.addTempDefenseBoost(-2);
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = 5151337777143949221L;
+
+ public void execute()
+ {
+ crd.addTempAttackBoost(2);
+ crd.addTempDefenseBoost(2);
+ }
+ });
+ //list.get(i).addDamage(2);
+ }
+
+ }//in play?
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Maelstrom Pulse"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4050843868789582138L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = getCreature();
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+ CardList getCreature()
+ {
+ CardList out = new CardList();
+ CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ list.shuffle();
+
+ for(int i = 0; i < list.size(); i++)
+ if((list.get(i).getNetAttack() >= 2) && (list.get(i).getNetDefense() <= 2))
+ out.add(list.get(i));
+
+ //in case human player only has a few creatures in play, target anything
+ if(out.isEmpty() &&
+ 0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() &&
+ 3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())
+ {
+ out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true).toArray());
+ CardListUtil.sortFlying(out);
+ }
+ return out;
+ }//getCreature()
+
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+
+ AllZone.GameAction.destroy(getTargetCard());
+
+ if(! getTargetCard().isToken() && !getTargetCard().isFaceDown())
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+
+ list = list.getName(getTargetCard().getName());
+ list.remove(getTargetCard());
+
+ if (!getTargetCard().isFaceDown())
+ for(int i = 0; i < list.size(); i++)
+ AllZone.GameAction.destroy(list.get(i));
+ }//is token?
+ }//in play?
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -4947592326270275532L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-land permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play) && !card.isLand())
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ravenous Rats") || cardName.equals("Corrupt Court Official"))
+ {
+ final Ability ability = new Ability(card,"0")
+ {
+ public boolean canPlayAI()
+ {
+ return true;
+ }
+ public void resolve()
+ {
+ if(Constant.Player.Computer.equals(getTargetPlayer()))
+ AllZone.GameAction.discardRandom(getTargetPlayer());
+ else
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ }//resolve()
+ };//SpellAbility
+
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -2028008593708491452L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetPlayer(ability));
+ ButtonUtil.disableAll();
+ }
+ else//computer
+ {
+ ability.setTargetPlayer(Constant.Player.Human);
+ AllZone.Stack.add(ability);
+ }//else
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Boris Devilboon"))
+ {
+ final Ability_Tap tokenAbility1 = new Ability_Tap(card, "2 B R")
+ {
+ private static final long serialVersionUID = -6343382804503119405L;
+
+ public boolean canPlayAI()
+ {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+ public void chooseTargetAI() {card.tap();}
+
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Minor Demon");
+ c.setImageName("BR 1 1 Demon");
+ c.setManaCost("B R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Demon");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(tokenAbility1);
+
+ tokenAbility1.setDescription("2 B R, tap: Put a 1/1 black and red Demon creature token named Minor Demon onto the battlefield.");
+ tokenAbility1.setStackDescription(card.getName() + " - Put a 1/1 black and red Demon creature token named Minor Demon onto the battlefield.");
+ tokenAbility1.setBeforePayMana(new Input_PayManaCost(tokenAbility1));
+ }
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Rhys the Redeemed"))
+ {
+ final Ability_Tap tokenAbility1 = new Ability_Tap(card, "2 GW")
+ {
+ private static final long serialVersionUID = 411298860775527337L;
+
+ public boolean canPlayAI()
+ {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+ public void chooseTargetAI() {card.tap();}
+
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Elf Warrior");
+ c.setImageName("GW 1 1 Elf Warrior");
+ c.setManaCost("GW");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elf");
+ c.addType("Warrior");
+
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//resolve()
+ };//SpellAbility
+
+ card.addSpellAbility(tokenAbility1);
+
+ tokenAbility1.setDescription("2 GW, tap: Put a 1/1 green and white Elf Warrior creature token into play.");
+ tokenAbility1.setStackDescription(card.getName() + " - Put a 1/1 green and white Elf Warrior creature token into play.");
+ tokenAbility1.setBeforePayMana(new Input_PayManaCost(tokenAbility1));
+
+ /////////////////////////////////////////////////////////////////////
+
+ final Ability_Tap copyTokens1 = new Ability_Tap(card, "4 GW GW")
+ {
+ private static final long serialVersionUID = 6297992502069547478L;
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList allTokens = new CardList();
+ allTokens.addAll(play.getCards());
+ allTokens = allTokens.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isCreature() && c.isToken();
+ }
+ });
+
+ for (int i=0;i= 2;
+ }
+ };
+
+ card.addSpellAbility(copyTokens1);
+
+ copyTokens1.setDescription("4 GW GW, tap: For each creature token you control, put a token into play that's a copy of that creature.");
+ copyTokens1.setStackDescription(card.getName() + " - For each creature token you control, put a token into play that's a copy of that creature.");
+ copyTokens1.setBeforePayMana(new Input_PayManaCost(copyTokens1));
+
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Bringer of the Green Dawn") || cardName.equals("Bringer of the Blue Dawn") ||
+ cardName.equals("Bringer of the White Dawn"))
+ {
+ final SpellAbility diffCost = new Spell(card)
+ {
+ private static final long serialVersionUID = -1598664186463358630L;
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand ,card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play ,card.getController());
+
+
+ hand.remove(card);
+ play.add(card);
+ card.comesIntoPlay(); //do i need this?
+ }
+ public boolean canPlay()
+ {
+ return AllZone.Phase.getActivePlayer().equals(card.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn") && !AllZone.GameAction.isCardInPlay(card);
+ }
+
+ };
+ diffCost.setManaCost("W U B R G");
+ diffCost.setDescription("You may pay W U B R G rather than pay "+card.getName() +"'s mana cost. ");
+ diffCost.setStackDescription(card.getName() + " - Creature 5/5");
+ card.addSpellAbility(diffCost);
+
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Thelonite Hermit"))
+ {
+
+ Command turnsFaceUp = new Command()
+ {
+ private static final long serialVersionUID = -3882798504865405413L;
+
+ public void execute()
+ {
+ makeToken();
+ makeToken();
+ makeToken();
+ makeToken();
+
+ }//execute()
+
+ public void makeToken()
+ {
+ Card c = new Card();
+
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }
+ };//Command
+
+
+ card.addTurnFaceUpCommand(turnsFaceUp);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Imperial Hellkite"))
+ {
+ final String player = card.getController();
+ Command turnsFaceUp = new Command()
+ {
+ private static final long serialVersionUID = -1407485989096862288L;
+
+ public void execute()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ CardList list = new CardList(lib.getCards());
+ list = list.getType("Dragon");
+
+ if (list.size()==0)
+ return;
+
+
+ if (player.equals(Constant.Player.Computer))
+ {
+ Card dragon = CardFactoryUtil.AI_getBestCreature(list);
+ lib.remove(dragon);
+ hand.add(dragon);
+ }
+ else //human
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select Dragon", list.toArray());
+ Card dragon = (Card)o;
+ lib.remove(dragon);
+ hand.add(dragon);
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//execute()
+ };//Command
+
+ card.addTurnFaceUpCommand(turnsFaceUp);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Corrupt"))
+ {
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 335838994716307031L;
+
+ Card check;
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= countSwamps(card))
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+
+ public int countSwamps(Card c)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
+ CardList swamps = new CardList(play.getCards());
+ swamps = swamps.getType("Swamp");
+ return swamps.size();
+ }
+
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= 12) //12? mebbe 15?
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= countSwamps(card))
+ return flying.get(i);
+
+ return null;
+ }
+
+ public void resolve()
+ {
+ int damage = countSwamps(card);
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
+ }
+ }
+ else {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sunlance"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -8327380630150660908L;
+
+ int damage = 3;
+ Card check;
+ public boolean canPlayAI()
+ {
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage &&
+ (!CardUtil.getColors(flying.get(i)).contains(Constant.Color.White)))
+ {
+ return flying.get(i);
+ }
+ return null;
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ //target
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -579427555773493417L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-white creature for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if((!CardUtil.getColors(card).contains(Constant.Color.White)) &&
+ card.isCreature() &&
+ zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//SpellAbility - target
+
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Saltblast"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -8701870029034823295L;
+
+ Card check;
+ public boolean canPlayAI()
+ {
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(!CardUtil.getColors(flying.get(i)).contains(Constant.Color.White))
+ {
+ return flying.get(i);
+ }
+ return null;
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ //target
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 6040042391157137555L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-white permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if((!CardUtil.getColors(card).contains(Constant.Color.White)) &&
+ zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//SpellAbility - target
+
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Firebolt"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4100322462753117988L;
+
+ int damage = 2;
+ Card check;
+
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ };//SpellAbility
+
+ final SpellAbility flashback = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -4811352682106571233L;
+ int damage = 2;
+ Card check;
+
+ public boolean canPlay()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard ,card.getController());
+ String phase = AllZone.Phase.getPhase();
+ String activePlayer = AllZone.Phase.getActivePlayer();
+
+ return AllZone.GameAction.isCardInZone(card, grave) &&
+ ((phase.equals(Constant.Phase.Main1) || phase.equals(Constant.Phase.Main2)) &&
+ card.getController().equals(activePlayer) && AllZone.Stack.size() == 0 );
+ }
+
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard , card.getController());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, card.getController());
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+
+ grave.remove(card);
+ removed.add(card);
+
+ }
+ };//flashback
+ flashback.setManaCost("4 R");
+ flashback.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(flashback,true));
+ flashback.setDescription("Flashback: 4R");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ card.addSpellAbility(flashback);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
+ card.setFlashback(true);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Spark Spray"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6619448976712515187L;
+
+ public void chooseTargetAI()
+ {
+ setStackDescription("Spark Spray cycling - Computer draws a card");
+ }//chooseTargetAI()
+
+ public void resolve()
+ {
+ if(card.getController().equals(Constant.Player.Computer))
+ {
+ AllZone.GameAction.drawCard(Constant.Player.Computer);
+ return;
+ }
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(1);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(1);
+ }
+ };//SpellAbility
+ spell.setDescription("Spark Spray deals 1 damage to target creature or player.");
+ card.clearSpellAbility();
+
+ card.addSpellAbility(spell);
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "R"));
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cackling Flames"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 2635417318395677454L;
+
+ int damage = 3;
+ Card check;
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+
+
+ public void resolve()
+ {
+ int damage = getDamage();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ int getDamage()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ if(hand.size() == 0)
+ return 5;
+
+ return 3;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mob Justice"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -671093248575416927L;
+
+ public boolean canPlayAI()
+ {
+ int damage = countControlledCreatures(Constant.Player.Computer);
+
+ if(AllZone.Human_Life.getLife() <= damage || damage >= 4)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ return false;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetPlayer(Constant.Player.Human);
+ }//chooseTargetAI()
+
+ public void resolve()
+ {
+ int damage = countControlledCreatures(card.getController());
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ //count basic lands you control
+ int countControlledCreatures(String player)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+ CardList creatures = new CardList(play.getCards());
+ creatures = creatures.getType("Creature");
+
+ return creatures.size();
+ }//countControlledCreatures();
+
+ };//SpellAbility
+ card.clearSpellAbility();
+
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tribal Flames"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -9055422004395136061L;
+
+ Card check;
+ public boolean canPlayAI()
+ {
+ int damage = countLandTypes();
+
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ int damage = countLandTypes();
+
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ int damage = countLandTypes();
+
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+
+ public void resolve()
+ {
+ int damage = countLandTypes();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ //count basic lands you control
+ int countLandTypes()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList land = new CardList(play.getCards());
+
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+ int count = 0;
+
+ for(int i = 0; i < basic.length; i++)
+ {
+ CardList c = land.getType(basic[i]);
+ if(! c.isEmpty())
+ count++;
+ }
+
+ return count;
+ }//countLandTypes()
+
+ };//SpellAbility
+ card.clearSpellAbility();
+
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Erratic Explosion"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -6003403347798646257L;
+
+ int damage = 3;
+ Card check;
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+ public void resolve()
+ {
+ int damage = getDamage();
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ javax.swing.JOptionPane.showMessageDialog(null, "Erratic Explosion causes " +damage +" to " +getTargetCard());
+
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ {
+ javax.swing.JOptionPane.showMessageDialog(null, "Erratic Explosion causes " +damage +" to " +getTargetPlayer());
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ }
+ //randomly choose a nonland card
+ int getDamage()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList notLand = new CardList(library.getCards());
+ notLand = notLand.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return ! c.isLand();
+ }
+ });
+ notLand.shuffle();
+
+ if(notLand.isEmpty())
+ return 0;
+
+ Card card = notLand.get(0);
+ return CardUtil.getConvertedManaCost(card.getSpellAbility()[0]);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell, true));
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Char"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1379875309204771345L;
+
+ int damage = 4;
+ Card check;
+ public boolean canPlayAI()
+ {
+ if(AllZone.Computer_Life.getLife() < 2)
+ return false;
+
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+ }
+ }
+ else
+ {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+ }
+
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7645439029870010010L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target Creature, Player or Planeswalker");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if((card.isCreature() || card.isPlaneswalker())&& zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectCard()
+ public void selectPlayer(String player)
+ {
+ spell.setTargetPlayer(player);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ };
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Psionic Blast"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5315747587330795963L;
+
+ int damage = 4;
+ Card check;
+ public boolean canPlayAI()
+ {
+ if(AllZone.Computer_Life.getLife() <= 2)
+ return false;
+
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+ }
+ }
+ else
+ {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(2);
+ }
+
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -3883369136409452222L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target Creature, Player or Planeswalker");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if((card.isCreature() || card.isPlaneswalker())&& zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectCard()
+ public void selectPlayer(String player)
+ {
+ spell.setTargetPlayer(player);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ };
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Hidetsugu's Second Rite"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 176857775451818523L;
+
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(getTargetPlayer());
+ if(life.getLife() == 10)
+ life.subtractLife(10);
+ }
+ public boolean canPlay()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerLife p = AllZone.GameAction.getPlayerLife(opponent);
+ return p.getLife() == 10;
+ }
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Soulscour") )
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -4554873222565897972L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isPermanent() && !c.isArtifact())
+ AllZone.GameAction.destroy(c);
+ }
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ // the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }// *************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("March of Souls"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1468254925312413359L;
+
+ public void resolve()
+ {
+ change(AllZone.Human_Play, card.getController());
+ change(AllZone.Computer_Play, card.getController());
+ }
+ public void change(PlayerZone play, String owner)
+ {
+ Card[] c = play.getCards();
+ for (int i = 0; i < c.length; i++)
+ {
+ if(c[i].isCreature())
+ {
+ AllZone.GameAction.destroyNoRegeneration(c[i]);
+ play.add(getCreature(c[i].getController()));
+ }
+ }
+ }//change()
+ public Card getCreature(String owner)
+ {
+ //TODO: owner and controller is NOT the same player sometimes
+ //owner is the player who played March of Souls
+ //the controller is the player who's creature was destroyed
+ Card c = new Card();
+ c.setToken(true);
+ c.setOwner(owner);
+ c.setController(owner);
+
+ c.setName("Spirit");
+ c.setImageName("W 1 1 Spirit");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Flying");
+
+ c.setManaCost("W");
+ c.addType("Creature");
+ c.addType("Spirit");
+ return c;
+ }//getCreature()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+//*************** START *********** START **************************
+ if (cardName.equals("Wrath of God") || cardName.equals("Damnation"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -18728406578984546L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isCreature())
+ AllZone.GameAction.destroyNoRegeneration(c);
+ }
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ // the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }// *************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Day of Judgment"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -2916641841124966207L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isCreature())
+ AllZone.GameAction.destroy(c);
+ }
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ // the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }// *************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Planar Cleansing") )
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -4233719265268955876L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isPermanent() && !c.isLand())
+ AllZone.GameAction.destroy(c);
+ }
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ // the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }// *************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Tranquility") || cardName.equals("Tempest of Light") || cardName.equals("Cleanfall"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 3087098751201624354L;
+
+ public void resolve()
+ {
+
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isEnchantment())
+ AllZone.GameAction.destroy(c);
+
+ }
+
+
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Enchantment");
+ computer = computer.getType("Enchantment");
+
+
+ if (human.size() == 0)
+ return false;
+
+ // the computer will at least destroy 2 more human enchantments
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }// *************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Hush"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1572271570905127602L;
+
+ public void resolve()
+ {
+
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for (int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if (c.isEnchantment())
+ AllZone.GameAction.destroy(c);
+ }
+
+ }// resolve()
+
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Enchantment");
+ computer = computer.getType("Enchantment");
+
+
+ if (human.size() == 0)
+ return false;
+
+ // the computer will at least destroy 2 more human enchantments
+ return computer.size() < human.size() - 1 ||
+ (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };// SpellAbility
+
+ spell.setDescription("Destroy all enchantments.");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2"));
+ }// *************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Incendiary Command"))
+ {
+ //not sure what to call variables, so I just made up something
+ final String[] m_player = new String[1];
+ final Card[] m_land = new Card[1];
+
+ final ArrayList userChoice = new ArrayList();
+
+ final String[] cardChoice = {
+ "Incendiary Command deals 4 damage to target player",
+ "Incendiary Command deals 2 damage to each creature",
+ "Destroy target nonbasic land",
+ "Each player discards all cards in his or her hand, then draws that many cards"
+ };
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 9178547049760990376L;
+
+ public void resolve()
+ {
+// System.out.println(userChoice);
+// System.out.println(m_land[0]);
+// System.out.println(m_player[0]);
+
+ //"Incendiary Command deals 4 damage to target player",
+ if(userChoice.contains(cardChoice[0]))
+ AllZone.GameAction.getPlayerLife(m_player[0]).subtractLife(4);
+
+ //"Incendiary Command deals 2 damage to each creature",
+ if(userChoice.contains(cardChoice[1]))
+ {
+ //get all creatures
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+ list = list.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addDamage(2);
+ }
+
+ //"Destroy target nonbasic land",
+ if(userChoice.contains(cardChoice[2]))
+ AllZone.GameAction.destroy(m_land[0]);
+
+ //"Each player discards all cards in his or her hand, then draws that many cards"
+ if(userChoice.contains(cardChoice[3]))
+ {
+ discardDraw(Constant.Player.Computer);
+ discardDraw(Constant.Player.Human);
+ }
+ }//resolve()
+
+ void discardDraw(String player)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ int n = hand.size();
+
+ //technically should let the user discard one card at a time
+ //in case graveyard order matters
+ for(int i = 0; i < n; i++)
+ AllZone.GameAction.discardRandom(player);
+
+ for(int i = 0; i < n; i++)
+ AllZone.GameAction.drawCard(player);
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ final Command setStackDescription = new Command()
+ {
+
+ private static final long serialVersionUID = -4833850318955216009L;
+
+ public void execute()
+ {
+ ArrayList a = new ArrayList();
+ if(userChoice.contains(cardChoice[0]))
+ a.add("deals 4 damage to " +m_player[0]);
+
+ if(userChoice.contains(cardChoice[1]))
+ a.add("deals 2 damage to each creature");
+
+ if(userChoice.contains(cardChoice[2]))
+ a.add("destroy " +m_land[0]);
+
+ if(userChoice.contains(cardChoice[3]))
+ a.add("each player discards all cards in his or her hand, then draws that many cards");
+
+ String s = a.get(0) +", " +a.get(1);
+ spell.setStackDescription(card.getName() +" - " +s);
+ }
+ };//Command
+
+
+ final Input targetLand = new Input()
+ {
+ private static final long serialVersionUID = 1485276539154359495L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target nonbasic land");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isLand() &&
+ zone.is(Constant.Zone.Play) &&
+ !c.getType().contains("Basic"))
+ {
+ m_land[0] = c;
+ setStackDescription.execute();
+
+ stopSetNext(new Input_PayManaCost(spell));
+ }//if
+ }//selectCard()
+ };//Input targetLand
+
+ final Input targetPlayer = new Input()
+ {
+ private static final long serialVersionUID = -2636869617248434242L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target player");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectPlayer(String player)
+ {
+ m_player[0] = player;
+ setStackDescription.execute();
+
+ //if user needs to target nonbasic land
+ if(userChoice.contains(cardChoice[2]))
+ stopSetNext(targetLand);
+ else
+ {
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectPlayer()
+ };//Input targetPlayer
+
+
+ Input chooseTwoInput = new Input()
+ {
+ private static final long serialVersionUID = 5625588008756700226L;
+
+ public void showMessage()
+ {
+ //reset variables
+ m_player[0] = null;
+ m_land[0] = null;
+
+ userChoice.clear();
+
+ ArrayList display = new ArrayList();
+
+ //get all
+ CardList list = new CardList();
+ list.addAll(AllZone.Human_Play.getCards());
+ list.addAll(AllZone.Computer_Play.getCards());
+
+ CardList land = list.getType("Land");
+ CardList basicLand = list.getType("Basic");
+
+ display.add("Incendiary Command deals 4 damage to target player");
+ display.add("Incendiary Command deals 2 damage to each creature");
+ if(land.size() != basicLand.size())
+ display.add("Destroy target nonbasic land");
+ display.add("Each player discards all cards in his or her hand, then draws that many cards");
+
+ ArrayList a = chooseTwo(display);
+ //everything stops here if user cancelled
+ if(a == null)
+ {
+ stop();
+ return;
+ }
+
+ userChoice.addAll(a);
+
+ if(userChoice.contains(cardChoice[0]))
+ stopSetNext(targetPlayer);
+ else if(userChoice.contains(cardChoice[2]))
+ stopSetNext(targetLand);
+ else
+ {
+ setStackDescription.execute();
+
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//showMessage()
+
+ ArrayList chooseTwo(ArrayList choices)
+ {
+ ArrayList out = new ArrayList();
+ Object o = AllZone.Display.getChoiceOptional("Choose Two", choices.toArray());
+ if(o == null)
+ return null;
+
+ out.add((String) o);
+
+ choices.remove(out.get(0));
+ o = AllZone.Display.getChoiceOptional("Choose Two", choices.toArray());
+ if(o == null)
+ return null;
+
+ out.add((String) o);
+
+ return out;
+ }//chooseTwo()
+ };//Input chooseTwoInput
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ spell.setBeforePayMana(chooseTwoInput);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Boil") || cardName.equals("Boiling Seas"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5951776248246552958L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if(c.getType().contains("Island"))
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Human_Play.getCards());
+ list = list.getType("Island");
+
+ return 3 < list.size();
+ }
+ };//SpellAbility
+ spell.setStackDescription(card.getName() + " - destroy all Islands.");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Plague Wind"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6008660207658995400L;
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, opponent);
+
+ CardList all = new CardList(play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if(c.isCreature())
+ AllZone.GameAction.destroyNoRegeneration(c);
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Overwhelming Forces"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7165356050118574287L;
+
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, opponent);
+
+ CardList all = new CardList(play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if(c.isCreature())
+ AllZone.GameAction.destroy(c);
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Path of Anger's Flame"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4070937328002003491L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList start = new CardList(play.getCards());
+ final CardList list = start.getType("Creature");
+
+ for(int i = 0; i < list.size(); i++)
+ list.get(i).addTempAttackBoost(2);
+
+ play.updateObservers();
+
+ Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 6078548097470388679L;
+
+ public void execute()
+ {
+ for(int i = 0; i < list.size(); i++)
+ if(AllZone.GameAction.isCardInPlay(list.get(i)))
+ list.get(i).addTempAttackBoost(-2);
+ }
+ };
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kjeldoran War Cry"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7384618531690849205L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList start = new CardList(play.getCards());
+ final CardList list = start.getType("Creature");
+
+ final int boost = countCards();
+
+ for(int i = 0; i < list.size(); i++)
+ {
+ list.get(i).addTempAttackBoost(boost);
+ list.get(i).addTempDefenseBoost(boost);
+ }
+
+ play.updateObservers();
+
+ Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -2803160667440730370L;
+
+ public void execute()
+ {
+ for(int i = 0; i < list.size(); i++)
+ if(AllZone.GameAction.isCardInPlay(list.get(i)))
+ {
+ list.get(i).addTempAttackBoost(- boost);
+ list.get(i).addTempDefenseBoost(- boost);
+ }
+ }
+ };
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//resolve()
+ int countCards()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Graveyard.getCards());
+ all.addAll(AllZone.Computer_Graveyard.getCards());
+
+ all = all.getName("Kjeldoran War Cry");
+ return all.size() + 1;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Akroma's Vengeance") ||
+ cardName.equals("Devastation") ||
+ cardName.equals("Jokulhaups") ||
+ cardName.equals("Purify") ||
+ cardName.equals("Shatterstorm") ||
+ cardName.equals("Obliterate"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7384618531690849205L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+
+ if(cardName.equals("Akroma's Vengeance") && (c.isCreature() || c.isArtifact() || c.isEnchantment())) // Destroy Enchantment rather than Land
+ AllZone.GameAction.destroy(c); // Can regenerate
+ if(cardName.equals("Devastation") && (c.isCreature() || c.isLand()))
+ AllZone.GameAction.destroy(c); // Can regenerate
+ if((cardName.equals("Jokulhaups") || cardName.equals("Obliterate") ) && (c.isCreature() || c.isArtifact() || c.isLand()))
+ AllZone.GameAction.destroyNoRegeneration(c); // CAN'T regenerate
+ if(cardName.equals("Purify") && (c.isArtifact() || c.isEnchantment()))
+ AllZone.GameAction.destroy(c); // Can regenerate
+ if(cardName.equals("Shatterstorm") && (c.isArtifact()))
+ AllZone.GameAction.destroyNoRegeneration(c); // CAN'T regenerate
+ }
+ }//resolve()
+ };//SpellAbility
+
+ if(cardName.equals("Akroma's Vengeance"))
+ {
+ spell.setStackDescription("Akroma's Vengeance - Destroy all artifacts, creatures, and enchantments."); // add stack description
+ spell.setDescription("Destroy all artifacts, creatures, and enchantments."); // add spell detail description
+ }
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ if(cardName.equals("Akroma's Vengeance")) //add cycling
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "3"));
+ if(cardName.equals("Obliterate"))
+ card.setText("Obliterate can't be countered. \r\n" + card.getText());
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wheel of Fortune"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7707418370887790709L;
+
+ public void resolve()
+ {
+ discardDraw7(Constant.Player.Human);
+ discardDraw7(Constant.Player.Computer);
+ }//resolve()
+ void discardDraw7(String player)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ Card[] c = hand.getCards();
+ for(int i = 0; i < c.length; i++)
+ AllZone.GameAction.discard(c[i]);
+
+ for(int i = 0; i < 7; i++)
+ AllZone.GameAction.drawCard(player);
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Armageddon") || cardName.equals("Ravages of War"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 432601263297207029L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ if(c.isLand())
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ int human = countPower(AllZone.Human_Play);
+ int computer = countPower(AllZone.Computer_Play);
+
+ return human < computer || MyRandom.percentTrue(10);
+ }
+ public int countPower(PlayerZone play)
+ {
+ CardList list = new CardList(play.getCards());
+ list = list.getType("Creature");
+ int power = 0;
+ for(int i = 0; i < list.size(); i++)
+ power += list.get(i).getNetAttack();
+
+ return power;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Remove Soul") || cardName.equals("False Summoning") || cardName.equals("Essence Scatter") || cardName.equals("Preemptive Strike"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4685055135070191326L;
+
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ //is spell?, did opponent play it?, is this a creature spell?
+ return sa.isSpell() &&
+ opponent.equals(sa.getSourceCard().getController()) &&
+ sa.getSourceCard().getType().contains("Creature");
+ }//canPlay()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Counterspell") || cardName.equals("Cancel") || cardName.equals("Last Word"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -2489268054171391552L;
+
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Remand"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7259402997927108504L;
+
+ public void resolve()
+ {
+ //counter spell, return it to owner's hand
+ SpellAbility sa = AllZone.Stack.pop();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, sa.getSourceCard().getOwner());
+ AllZone.GameAction.moveTo(hand, sa.getSourceCard());
+
+ //draw card
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Regress"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4207725827500789300L;
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }
+ }//resolve()
+
+ public void chooseTargetAI()
+ {
+ PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList hum = new CardList(hPlay.getCards());
+
+ Card best = CardFactoryUtil.AI_getMostExpensivePermanent(hum, card, true);
+ if (best!=null)
+ setTargetCard(best);
+ }
+ public boolean canPlayAI()
+ {
+ PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList hum = new CardList(hPlay.getCards());
+
+ return hum.size()>0;
+ }
+ };
+ //spell.setChooseTargetAI(CardFactoryUtil.AI_targetType("All", AllZone.Human_Play));
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "All"));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Echoing Truth"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 563933533543239220L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 4 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ //if target card is not in play, just quit
+ if(! AllZone.GameAction.isCardInPlay(getTargetCard()) || !CardFactoryUtil.canTarget(card, getTargetCard()) )
+ return;
+
+ //get all permanents
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ CardList sameName = all.getName(getTargetCard().getName());
+
+ if (!getTargetCard().isFaceDown())
+ {
+ //bounce all permanents with the same name
+ for(int i = 0; i < sameName.size(); i++)
+ {
+ if(sameName.get(i).isToken())
+ AllZone.GameAction.destroy(sameName.get(i));
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, sameName.get(i).getOwner());
+ AllZone.GameAction.moveTo(hand, sameName.get(i));
+ }
+ }//for
+ }//if (!isFaceDown())
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -3978705328511825933L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target non-land permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(! card.isLand() && zone.is(Constant.Zone.Play) && CardFactoryUtil.canTarget(spell, card))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Repulse"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7586791617021788730L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 3 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ @SuppressWarnings("unused") // play
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+
+ //play.remove(getTargetCard());
+ //hand.add(getTargetCard());
+ }
+ AllZone.GameAction.drawCard(card.getController());
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -4976281514575975012L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+
+ else if(card.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Unsummon"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4920446621228732642L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 2 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ @SuppressWarnings("unused") // play
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+
+ //play.remove(getTargetCard());
+ //hand.add(getTargetCard());
+ }
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7657949950004365660L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+
+ else if(card.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Impulse"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -6793636573741251978L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ CardList top = new CardList();
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ Card c;
+ int j = 4;
+ if (library.size() < 4)
+ j = library.size();
+ for(int i = 0; i < j; i++)
+ {
+ c = library.get(0);
+ library.remove(0);
+ top.add(c);
+ }
+
+ if (top.size() >= 1)
+ {
+ //let user get choice
+ Card chosen = (Card) AllZone.Display.getChoice("Choose a card to put into your hand", top.toArray());
+ top.remove(chosen);
+
+ //put card in hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ hand.add(chosen);
+
+ //add cards to bottom of library
+ for(int i = 0; i < top.size(); i++)
+ library.add(top.get(i));
+ }
+ }//resolve()
+ };//SpellAbility
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Bribery"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4267653042039058744L;
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ //choose creature from opponents library to put into play
+ //shuffle opponent's library
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, opponent);
+ CardList choices = new CardList(library.getCards());
+
+ choices = choices.getType("Creature");
+ Object o = AllZone.Display.getChoiceOptional("Choose a creature", choices.toArray());
+ if(o != null)
+ resolve((Card)o);
+ }
+ public void computerResolve()
+ {
+ CardList all = new CardList(AllZone.Human_Library.getCards());
+ all = all.getType("Creature");
+
+ CardList flying = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.getKeyword().contains("Flying");
+ }
+ });
+ //get biggest flying creature
+ Card biggest = null;
+ if(flying.size() != 0)
+ {
+ biggest = flying.get(0);
+
+ for(int i = 0; i < flying.size(); i++)
+ if(biggest.getNetAttack() < flying.get(i).getNetAttack())
+ biggest = flying.get(i);
+ }
+
+ //if flying creature is small, get biggest non-flying creature
+ if(all.size() != 0 &&
+ (biggest == null || biggest.getNetAttack() < 3))
+ {
+ biggest = all.get(0);
+
+ for(int i = 0; i < all.size(); i++)
+ if(biggest.getNetAttack() < all.get(i).getNetAttack())
+ biggest = all.get(i);
+ }
+ if(biggest != null)
+ resolve(biggest);
+ }//computerResolve()
+ public void resolve(Card selectedCard)
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, opponent);
+
+ Card c = selectedCard;
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ //need to set controller before adding it to "play"
+ c.setController(card.getController());
+ c.setSickness(true);
+
+ library.remove(c);
+ play.add(c);
+
+
+ AllZone.GameAction.shuffle(opponent);
+ }//resolve()
+ };
+
+ spell.setBeforePayMana(new Input_PayManaCost(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Words of Wisdom"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7394898791285593737L;
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.drawCard(opponent);
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Counsel of the Soratami") || cardName.equals("Inspiration") || cardName.equals("Touch of Brilliance"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1889094576060845154L;
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Concentrate") || cardName.equals("Harmonize") )
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3561111468549060269L;
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Amnesia"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5456164079438881319L;
+
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetPlayer());
+ Card[] c = hand.getCards();
+
+ for(int i = 0; i < c.length; i++)
+ if(! c[i].isLand())
+ AllZone.GameAction.discard(c[i]);
+ }
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Evacuation"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -6305494177352031326L;
+
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Creature");
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ //if is token, remove token from play, else return creature to hand
+ if(all.get(i).isToken())
+ getPlay(all.get(i)).remove(all.get(i));
+ else
+ AllZone.GameAction.moveTo(getHand(all.get(i)), all.get(i));
+ }
+ }//resolve()
+ PlayerZone getPlay(Card c)
+ {
+ return AllZone.getZone(Constant.Zone.Play, c.getController());
+ }
+
+ PlayerZone getHand(Card c)
+ {
+ return AllZone.getZone(Constant.Zone.Hand, c.getOwner());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ if (cardName.equals("Lockjaw Snapper"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+
+ CardList creatures = new CardList();
+ creatures.addAll(hPlay.getCards());
+ creatures.addAll(cPlay.getCards());
+ creatures = creatures.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.getCounters(Counters.M1M1) > 0;
+ }
+ });
+
+ for (int i=0; i= 7)
+ {
+ makeToken();
+ makeToken();
+ }
+ }
+ public void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Bear");
+ c.setImageName("G 2 2 Bear");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Bear");
+ c.setBaseAttack(2);
+ c.setBaseDefense(2);
+
+ play.add(c);
+
+ }//resolve()
+ };
+
+ spell.setDescription("Put two 2/2 green Bear creature tokens into play. Threshold - Put four 2/2 green Bear creature tokens into play instead if seven or more cards are in your graveyard. ");
+ spell.setStackDescription(card.getController() + " Puts 2/2 green Bear tokens into play.");
+
+ card.setFlashback(true);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "5 G G", "0"));
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sprout"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 1299216756153970592L;
+ public void resolve()
+ {
+ makeToken();
+ }
+ public void makeToken()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+
+ }//resolve()
+ };
+
+ spell.setDescription("Put a 1/1 green Saproling creature token into play.");
+ spell.setStackDescription(card.getController() + " put a 1/1 green Saproling creature token into play.");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Delirium Skeins"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7901561313373975648L;
+
+ public void resolve()
+ {
+ for(int i = 0; i < 3; i++)
+ AllZone.GameAction.discardRandom(Constant.Player.Computer);
+
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard(3));
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wrap in Vigor"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4235465815975050436L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+
+ public void resolve()
+ {
+ final Card[] c = AllZone.getZone(Constant.Zone.Play, card.getController()).getCards();
+
+ for(int i = 0; i < c.length; i++)
+ if(c[i].isCreature())
+ c[i].addShield();
+
+ AllZone.EndOfTurn.addUntil(new Command()
+ {
+ private static final long serialVersionUID = -3946800525315027053L;
+
+ public void execute()
+ {
+ for(int i = 0; i < c.length; i++)
+ c[i].resetShield();
+ }
+ });
+
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Smother"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6479035316340603704L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(true, 3, card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardUtil.getConvertedManaCost(card.getManaCost()) <= 3 && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ AllZone.GameAction.destroyNoRegeneration(c);
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 1877945605889747187L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +card.getName() +" - creature must have a converted manacost of 3 or less");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && CardUtil.getConvertedManaCost(card.getManaCost()) <= 3)
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Strangling Soot"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3598479453933951865L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(3, card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+
+ public void resolve()
+ {
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && c.getNetDefense() <= 3 && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ AllZone.GameAction.destroy(c);
+
+ }//resolve()
+ };//SpellAbility
+
+ final SpellAbility flashback = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -4009531242109129036L;
+
+ public boolean canPlay()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard ,card.getController());
+
+ return AllZone.GameAction.isCardInZone(card, grave);
+ }
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(3, card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard , card.getController());
+ PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, card.getController());
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && c.getNetDefense() <= 3 && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ AllZone.GameAction.destroy(c);
+
+ grave.remove(card);
+ removed.add(card);
+ }//resolve()
+ };//flashback
+
+ Input targetFB = new Input()
+ {
+
+ private static final long serialVersionUID = -5469698194749752297L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +card.getName() +" - creature must have a toughness of 3 or less");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(flashback, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && card.getNetDefense() <= 3)
+ {
+ flashback.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(flashback));
+ }
+ }
+ };//Input
+
+ flashback.setManaCost("5 R");
+ flashback.setBeforePayMana(targetFB);
+ flashback.setDescription("Flashback: 5 R");
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -198153850086215235L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +card.getName() +" - creature must have a toughness of 3 or less");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && card.getNetDefense() <= 3)
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ spell.setBeforePayMana(target);
+
+ card.addSpellAbility(flashback);
+
+ card.setFlashback(true);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Minions' Murmurs"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 7270026936498671973L;
+
+ public boolean canPlayAI()
+ {
+ int n = countCreatures();
+ return 0 < n && n < AllZone.Computer_Life.getLife();
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ int n = countCreatures();
+ for(int i = 0; i < n; i++)
+ AllZone.GameAction.drawCard(card.getController());
+
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(n);
+ }//resolve()
+
+ int countCreatures()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(play.getCards());
+ list = list.getType("Creature");
+ return list.size();
+ }
+ };//SpellAbility
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tendrils of Corruption"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -618587752177627111L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 0 < human.size();
+ }//canPlayAI()
+
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ CardListUtil.sortAttack(human);
+ setTargetCard(human.get(0));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ int n = countSwamps();
+ getTargetCard().addDamage(n);
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(n);
+ }
+ }//resolve()
+
+ int countSwamps()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(play.getCards());
+ list = list.getType("Swamp");
+ return list.size();
+ }
+ };//SpellAbility
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Ichor Slick"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -273970706213674570L;
+
+ public boolean canPlayAI()
+ {
+ CardList c = CardFactoryUtil.AI_getHumanCreature(3, card, true);
+ CardListUtil.sortAttack(c);
+ CardListUtil.sortFlying(c);
+
+ if(c.isEmpty())
+ return false;
+ else
+ {
+ setTargetCard(c.get(0));
+ return true;
+ }
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -1615047325868708734L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]) )
+ {
+ target[0].addTempAttackBoost(3);
+ target[0].addTempDefenseBoost(3);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(-3);
+ target[0].addTempDefenseBoost(-3);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7381927922574152604L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +card.getName());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(card.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+ spell.setDescription("Target creature gets -3/-3 until end of turn");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2"));
+
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Funeral Charm"))
+ {
+ //discard
+ final SpellAbility spell_one = new Spell(card)
+ {
+ private static final long serialVersionUID = 8273875515630095127L;
+ public boolean canPlayAI()
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return MyRandom.random.nextBoolean();
+ }
+ public void resolve()
+ {
+ if(Constant.Player.Computer.equals(getTargetPlayer()))
+ AllZone.GameAction.discardRandom(getTargetPlayer());
+ else
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ }//resolve()
+ };//SpellAbility
+ spell_one.setDescription("Target player discards a card.");
+ spell_one.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell_one));
+
+
+ //creature gets +2/-1
+ final SpellAbility spell_two = new Spell(card)
+ {
+ private static final long serialVersionUID = -4554812851052322555L;
+
+
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(ComputerUtil.getAttackers().getAttackers());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {return 1 < c.getNetDefense();}
+ });
+
+ list.shuffle();
+ if(list.size() > 0)
+ setTargetCard(list.get(0));
+
+ return (list.size() > 0) && MyRandom.random.nextBoolean();
+ }
+
+
+ public void resolve()
+ {
+ final Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ c.addTempAttackBoost(2);
+ c.addTempDefenseBoost(-1);
+
+ Command until = new Command()
+ {
+ private static final long serialVersionUID = 4674846621452044251L;
+
+ public void execute()
+ {
+ c.addTempAttackBoost(-2);
+ c.addTempDefenseBoost(1);
+ }
+ };//Command
+ AllZone.EndOfTurn.addUntil(until);
+ }//if card in play?
+ }//resolve()
+ };//SpellAbility
+ spell_two.setDescription("Target creature gets +2/-1 until end of turn.");
+ spell_two.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell_two));
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell_one);
+ card.addSpellAbility(spell_two);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Regrowth"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1771016287736735113L;
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), graveyard))
+ {
+ graveyard.remove(getTargetCard());
+ hand.add(getTargetCard());
+ }
+ }//resolve()
+ public boolean canPlay()
+ {
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ return graveyard.getCards().length != 0 && super.canPlay();
+ }
+ };
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 3687454413838053102L;
+
+ public void showMessage()
+ {
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ Object o = AllZone.Display.getChoiceOptional("Select target card", graveyard.getCards());
+ if(o == null)
+ stop();
+ else
+ {
+ spell.setStackDescription("Return " +o +" to its owner's hand");
+ spell.setTargetCard((Card)o);
+
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//showMessage()
+ };
+ spell.setChooseTargetAI(CardFactoryUtil.AI_targetType("All", AllZone.Computer_Graveyard));
+ spell.setBeforePayMana(runtime);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Commune with Nature"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7652317332073733242L;
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ //get top 5 cards of library
+ CardList top = new CardList();
+ int limit = AllZone.Computer_Library.getCards().length;
+
+ for(int i = 0; i < 5 && i < limit; i++)
+ {
+ top.add(AllZone.Computer_Library.get(0));
+ AllZone.Computer_Library.remove(0);
+ }
+
+ //put creature card in hand, if there is one
+ CardList creature = top.getType("Creature");
+ if(creature.size() != 0)
+ {
+ AllZone.Computer_Hand.add(creature.get(0));
+ top.remove(creature.get(0));
+ }
+
+ //put cards on bottom of library
+ for(int i = 0; i < top.size(); i++)
+ AllZone.Computer_Library.add(top.get(i));
+ }//computerResolve()
+ public void humanResolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+
+ CardList list = new CardList();
+ for(int i = 0; i < 5 && i < library.getCards().length; i++)
+ list.add(library.get(i));
+
+ //optional, select a creature
+ Object o = AllZone.Display.getChoiceOptional("Select a creature", list.toArray());
+ if(o != null && ((Card)o).isCreature())
+ {
+ AllZone.GameAction.moveTo(hand, (Card)o);
+ list.remove((Card)o);
+ }
+
+ //put remaining cards on the bottom of the library
+ for(int i = 0; i < list.size(); i++)
+ {
+ library.remove(list.get(i));
+ library.add(list.get(i));
+ }
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Kodama's Reach"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3361422153566629825L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ CardList land = new CardList(AllZone.Computer_Library.getCards());
+ land = land.getType("Basic");
+
+ //just to make the computer a little less predictable
+ land.shuffle();
+
+ //3 branches: 1-no land in deck, 2-one land in deck, 3-two or more land in deck
+ if(land.size() != 0)
+ {
+ //branch 2 - at least 1 land in library
+ Card tapped = land.remove(0);
+ tapped.tap();
+
+ AllZone.Computer_Play.add(tapped);
+ AllZone.Computer_Library.remove(tapped);
+
+ //branch 3
+ if(land.size() != 0)
+ {
+ Card toHand = land.remove(0);
+ AllZone.Computer_Hand.add(toHand);
+ AllZone.Computer_Library.remove(toHand);
+ }
+ }
+ }//computerResolve()
+
+ public void humanResolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play , card.getController());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand , card.getController());
+
+ CardList list = new CardList(library.getCards());
+ list = list.getType("Basic");
+
+ //3 branches: 1-no land in deck, 2-one land in deck, 3-two or more land in deck
+
+ //branch 1
+ if(list.size() == 0)
+ return;
+
+ //branch 2
+ Object o = AllZone.Display.getChoiceOptional("Put into play tapped", list.toArray());
+ if(o != null)
+ {
+ Card c = (Card)o;
+ c.tap();
+ list.remove(c);
+
+ library.remove(c);
+ play.add(c);
+
+ if(list.size() == 0)
+ return;
+
+ o = AllZone.Display.getChoiceOptional("Put into your hand", list.toArray());
+ if(o != null)
+ {
+ //branch 3
+ library.remove(o);
+ hand.add(o);
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//if
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pestermite"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c))
+ {
+ if(c.isTapped())
+ c.untap();
+ else
+ c.tap();
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 5202575895575352408L;
+
+ public void execute()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ CardList hum = new CardList();
+ hum.addAll(AllZone.Human_Play.getCards());
+
+ if (all.size() != 0) {
+
+ if(card.getController().equals(Constant.Player.Human)) {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetSpecific(ability, all, "Select target permanent to tap/untap.", true));
+ ButtonUtil.enableAll();
+ }
+ else if (card.getController().equals(Constant.Player.Computer)) {
+ Card human = CardFactoryUtil.AI_getBestCreature(hum);
+ ability.setTargetCard(human);
+ AllZone.Stack.add(ability);
+ }
+ }
+
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -3055232264358172133L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ list = list.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return c.isUntapped();
+ }
+ });
+
+ return (list.size() > 0) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Angel of Despair"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c))
+ {
+ if(c.isToken())
+ AllZone.getZone(c).remove(c);
+
+ else
+ AllZone.GameAction.destroy(c);
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -3583483691705438214L;
+
+ public void execute()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ CardList hum = new CardList();
+ hum.addAll(AllZone.Human_Play.getCards());
+
+ if (all.size() != 0) {
+
+ if(card.getController().equals(Constant.Player.Human)) {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetSpecific(ability, all, "Select target permanent.", true));
+ ButtonUtil.disableAll();
+ }
+ else if (card.getController().equals(Constant.Player.Computer)) {
+ Card human = CardFactoryUtil.AI_getBestCreature(hum);
+ ability.setTargetCard(human);
+ AllZone.Stack.add(ability);
+ }
+ }
+
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -173202865726476053L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+
+ return (list.size() > 0) && AllZone.getZone(getSourceCard()).is(Constant.Zone.Hand);
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Yawgmoth's Bargain")){
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ if(library.size() != 0)
+ {
+ Card c = library.get(0);
+ library.remove(0);
+ hand.add(c);
+ }
+ }
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ ability.setDescription("Pay 1 life: Draw a card.");
+ ability.setStackDescription(card.getName() +" - Pay 1 life: Draw a card.");
+
+ card.addSpellAbility(ability);
+
+ //instead of paying mana, pay life and add to stack
+ //Input showMessage() is always the first method called
+ Input payLife = new Input()
+ {
+
+ private static final long serialVersionUID = 8660593629867722192L;
+
+ public void showMessage()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);
+
+ //this order is very important, do not change
+ stop();
+ AllZone.Stack.push(ability);
+ }
+ };//Input
+ ability.setBeforePayMana(payLife);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Necropotence"))
+ {
+ final CardList necroCards = new CardList();
+
+ final Command necro = new Command()
+ {
+ private static final long serialVersionUID = 4511445425867383336L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ //put cards removed by Necropotence into player's hand
+ if(necroCards.size() > 0){
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ for(int i = 0;i 0;
+ }
+
+ int calculateLife()
+ {
+ PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ CardList creatureList = new CardList(zone.getCards());
+ creatureList = creatureList.getType("Creature");
+
+ return 2 * creatureList.size();
+ }
+
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(calculateLife());
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mystic Snake"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(AllZone.Stack.size() > 0) {
+ SpellAbility sa = AllZone.Stack.peek();
+ if (sa.isSpell() && CardFactoryUtil.isCounterable(sa.getSourceCard()) ) {
+ sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+ }
+ }
+ }//resolve()
+ };//SpellAbility
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -6564365394043612388L;
+
+ public void execute()
+ {
+ if(AllZone.Stack.size() > 0) {
+ ability.setStackDescription("Mystic Snake counters " +AllZone.Stack.peek().getSourceCard().getName());
+ AllZone.Stack.add(ability);
+ }
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 6440845807532409545L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ });
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Absorb"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -2007620906017942538L;
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(3);
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Undermine"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4999966043862729936L;
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(3);
+
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Punish Ignorance"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6845184687406705133L;
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ AllZone.GameAction.getPlayerLife(opponent).subtractLife(3);
+
+ String player = card.getController();
+ AllZone.GameAction.getPlayerLife(player).addLife(3);
+
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Exclude"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5615796501064636046L;
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ //is spell?, did opponent play it?, is this a creature spell?
+ return sa.isSpell() &&
+ opponent.equals(sa.getSourceCard().getController()) &&
+ sa.getSourceCard().getType().contains("Creature")
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }//canPlay()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Eladamri's Call"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -6495398165357932918L;
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ CardList creatures = new CardList(AllZone.Human_Library.getCards());
+ creatures = creatures.getType("Creature");
+
+ Object check = AllZone.Display.getChoiceOptional("Select creature", creatures.toArray());
+ if(check != null)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, (Card)check);
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+ }
+ public void computerResolve()
+ {
+ Card[] library = AllZone.Computer_Library.getCards();
+ CardList list = new CardList(library);
+ list = list.getType("Creature");
+
+
+ //pick best creature
+ Card c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null)
+ c = library[0];
+ AllZone.Computer_Library.remove(c);
+ AllZone.Computer_Hand.add(c);
+ }
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ return library.getCards().length != 0;
+ }
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList();
+ creature.addAll(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ return creature.size() != 0;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Dismiss"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -7959473218345045760L;
+ public void resolve()
+ {
+ SpellAbility sa = AllZone.Stack.pop();
+ AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
+
+ AllZone.GameAction.drawCard(card.getController());
+
+ }
+ public boolean canPlay()
+ {
+ if(AllZone.Stack.size() == 0)
+ return false;
+
+ //see if spell is on stack and that opponent played it
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ SpellAbility sa = AllZone.Stack.peek();
+
+ return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
+ && CardFactoryUtil.isCounterable(sa.getSourceCard());
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Global Ruin"))
+ {
+ final CardList target = new CardList();
+ //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 humanBasic = new Vector();
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5739127258598357186L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ //should check if computer has land in hand, or if computer has more basic land types than human.
+ }
+ @SuppressWarnings("unchecked") // computerBasic
+ public void resolve()
+ {
+ //add computer's lands to target
+ @SuppressWarnings("unused") // computerCountBasic
+ int computerCountBase = 0;
+ @SuppressWarnings("unused") // computerBasic
+ Vector> computerBasic = new Vector();
+
+ //figure out which basic land types the computer has
+ CardList land = new CardList(AllZone.Computer_Play.getCards());
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+
+ for (int i = 0; i < basic.length; i++)
+ {
+ CardList cl = land.getType(basic[i]);
+ 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.toArray());
+ }
+ }
+
+ //when this spell resolves all basic lands which were not selected are sacrificed.
+ for(int i = 0; i < target.size(); i++)
+ if(AllZone.GameAction.isCardInPlay(target.get(i)))
+ AllZone.GameAction.sacrifice(target.get(i));
+ }//resolve()
+ };//SpellAbility
+
+
+ final Input input = new Input()
+ {
+ private static final long serialVersionUID = 1739423591445361917L;
+ private int count;
+ 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
+ count = countBase[0] - index[0] - 1; //subtract by one since humanBasic is 0 indexed.
+ if(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;
+ stop();
+ }
+ else{
+ AllZone.Display.showMessage("Select target " + humanBasic.get(count) +" land to not sacrifice");
+ ButtonUtil.enableOnlyCancel();
+ }
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(c.isLand() && zone.is(Constant.Zone.Play) && c.getController().equals(Constant.Player.Human) && c.getName().equals(humanBasic.get(count)))
+ {
+ //get all other basic[count] lands human player controls and add them to target
+ PlayerZone humanPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList land = new CardList(humanPlay.getCards());
+ CardList cl = land.getType((String)humanBasic.get(count));
+ cl.remove(c);
+ target.addAll(cl.toArray());
+
+ index[0]++;
+ showMessage();
+
+ if(index[0] >= humanBasic.size())
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectCard()
+ };//Input
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -122635387376995855L;
+
+ public void showMessage()
+ {
+ countBase[0] = 0;
+ //figure out which basic land types the human has
+ //put those in an set to use later
+ CardList land = new CardList(AllZone.Human_Play.getCards());
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+
+ for (int i = 0; i < basic.length; i++)
+ {
+ CardList c = land.getType(basic[i]);
+ if (!c.isEmpty())
+ {
+ humanBasic.add(basic[i]);
+ countBase[0]++;
+ }
+ }
+ if(countBase[0] == 0){
+ //human has no basic land, so don't prompt to select one.
+ stop();
+ }
+ else{
+ index[0] = 0;
+ target.clear();
+ stopSetNext(input);
+ }
+ }
+ };//Input
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ spell.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Gerrard's Verdict"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 4734024742326763385L;
+ public boolean canPlayAI()
+ {
+ PlayerZone humanHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
+ if (humanHand.size() >= 2)
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList list = new CardList(hand.getCards());
+ list.shuffle();
+
+ if (list.size()== 0)
+ return;
+
+ Card c1 = list.get(0);
+ list.remove(c1);
+ AllZone.Computer_Graveyard.add(c1);
+ AllZone.Computer_Hand.remove(c1);
+
+ if (list.size()== 0)
+ return;
+
+ Card c2 = list.get(0);
+ list.remove(c2);
+ AllZone.Computer_Graveyard.add(c2);
+ AllZone.Computer_Hand.remove(c2);
+
+ if (c1.getType().contains("Land")) {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Human);
+ life.addLife(3);
+ }
+
+ if (c2.getType().contains("Land")) {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Human);
+ life.addLife(3);
+ }
+
+
+ }//resolve()
+ public void computerResolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Human);
+ CardList list = new CardList(hand.getCards());
+
+ if (list.size() > 0){
+
+ Object o = AllZone.Display.getChoiceOptional("First card to discard", list.toArray());
+
+ Card c = (Card)o;
+ list.remove(c);
+
+ hand.remove(c);
+ grave.add(c);
+
+ if(c.getType().contains("Land")) {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
+ life.addLife(3);
+ }
+
+ if (list.size() > 0)
+ {
+ Object o2 = AllZone.Display.getChoiceOptional("Second card to discard", list.toArray());
+
+ Card c2 = (Card)o2;
+ list.remove(c2);
+
+ hand.remove(c2);
+ grave.add(c2);
+
+ if(c2.getType().contains("Land")) {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
+ life.addLife(3);
+ }
+ }
+ }
+ }
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Temporal Spring"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 2649912511833536966L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 3 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ AllZone.GameAction.moveToTopOfLibrary(getTargetCard());
+ }
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = 3852696858086356864L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(c);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Boomerang") || cardName.equals("Eye of Nowhere"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5383879224433456795L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 3 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetCard().getOwner());
+ AllZone.GameAction.moveTo(hand, getTargetCard());
+ }
+ @SuppressWarnings("unused") // targetManaCost
+ String targetManaCost = getTargetCard().getManaCost();
+ //System.out.println("target card has a converted manacost of: " +CardUtil.getConvertedManaCost(targetManaCost));
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 7717499561403038165L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, c)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(c);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Culling Sun"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 2169815434022673011L;
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ int convertedManaCost = CardUtil.getConvertedManaCost(c.getManaCost());
+ if(c.isCreature() && (convertedManaCost <= 3))
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1 || (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Retribution of the Meek"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4989080454206680708L;
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ int power = c.getNetAttack();
+ if(c.isCreature() && (power >= 4))
+ AllZone.GameAction.destroyNoRegeneration(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.getNetAttack() >= 4;
+ }
+ });
+
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.getNetAttack() >= 4;
+ }
+ });
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1 || (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Mass Calcify"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -3985301372801316515L;
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+ //int convertedManaCost = CardUtil.getConvertedManaCost(c.getManaCost());
+ if(c.isCreature() && !CardUtil.getColors(c).contains(Constant.Color.White))
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList human = new CardList(AllZone.Human_Play.getCards());
+ CardList computer = new CardList(AllZone.Computer_Play.getCards());
+
+ human = human.getType("Creature");
+ computer = computer.getType("Creature");
+
+ //the computer will at least destroy 2 more human creatures
+ return computer.size() < human.size()-1 || (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Cleanse"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6329910910925881386L;
+ public void resolve()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+
+ for(int i = 0; i < all.size(); i++)
+ {
+ Card c = all.get(i);
+
+ if(c.isCreature() && CardUtil.getColors(c).contains(Constant.Color.Black))
+ AllZone.GameAction.destroy(c);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ CardList hum = new CardList(AllZone.Human_Play.getCards());
+ CardList comp = new CardList(AllZone.Computer_Play.getCards());
+
+ hum = hum.getType("Creature");
+ comp = comp.getType("Creature");
+
+ CardList human = new CardList();
+ CardList computer = new CardList();
+
+ for (int i=0; i= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+ if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ if (c == null) {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+ setTargetCard(c);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage)
+ return flying.get(i);
+
+ return null;
+ }
+
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ c.addDamage(damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(3);
+
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -924544537419004913L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target Creature, Player or Planeswalker");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(spell, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if((card.isCreature() || card.isPlaneswalker()) && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }//selectCard()
+ public void selectPlayer(String player)
+ {
+ spell.setTargetPlayer(player);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ };
+ spell.setBeforePayMana(target);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Archon of Justice"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ if(getTargetCard() != null){
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ AllZone.GameAction.removeFromGame(getTargetCard());
+ }
+ }
+ }
+ };
+ ability.setStackDescription("Archon of Justice - Remove target permament from the game.");
+
+ Command leavesPlay = new Command()
+ {
+ private static final long serialVersionUID = 7552566264976488465L;
+
+ public void execute()
+ {
+ if(card.getController().equals(Constant.Player.Human))
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetPermanent(ability));
+ else
+ {
+ //if computer controlled Archon of Justice have it select the best creature, or enchantment, or artifact, whatever the human controllers, and as a last option a card it controls
+
+ CardList human_list = new CardList(AllZone.Human_Play.getCards());
+ ability.setTargetCard(CardFactoryUtil.AI_getBestCreature(human_list));
+ if(ability.getTargetCard() == null){
+ ability.setTargetCard(CardFactoryUtil.AI_getBestEnchantment(human_list, card, true));
+ }
+ if(ability.getTargetCard() == null){
+ ability.setTargetCard(CardFactoryUtil.AI_getBestArtifact(human_list));
+ }
+ if(ability.getTargetCard() == null){
+ if(human_list.size() == 0){
+ CardList computer_list = new CardList(AllZone.Computer_Play.getCards());
+ if(computer_list.size() == 0){
+ return; //we have nothing in play to destroy.
+ }
+ else{
+ ability.setTargetCard(computer_list.get(0)); //should determine the worst card to destroy, but this case wont be hit much.
+ }
+ }
+ ability.setTargetCard(human_list.get(0));
+ }
+ AllZone.Stack.add(ability);
+ }
+ }//execute()
+ };//Command
+ card.addDestroyCommand(leavesPlay);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Knight of the Reliquary"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 7554368501399705784L;
+ public void resolve()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ Card c = getTargetCard();
+ if (AllZone.GameAction.isCardInPlay(c))
+ {
+ AllZone.GameAction.sacrifice(c);
+
+ CardList landInLib = new CardList(lib.getCards());
+ landInLib = landInLib.getType("Land");
+
+ if (landInLib.size() > 0)
+ {
+ if (card.getController().equals(Constant.Player.Computer))
+ {
+ lib.remove(landInLib.get(0));
+ play.add(landInLib.get(0));
+ }
+ else
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select land card to put into play: ", landInLib.toArray());
+ if (o != null)
+ {
+ Card crd = (Card)o;
+ lib.remove(crd);
+ play.add(crd);
+ }
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }
+ }//if(isCardInPlay)
+ }
+
+ public boolean canPlayAI()
+ {
+ CardList landInLib = new CardList(AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer).getCards());
+ CardList landInPlay = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
+
+ landInLib = landInLib.getType("Land");
+ landInPlay = landInPlay.getType("Land");
+
+ if (landInLib.size() > 0 && landInPlay.size() > 0)
+ return true;
+ else
+ return false;
+
+ }
+ public void chooseTargetAI()
+ {
+ CardList land = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(c.getType().contains("Plains") || c.getType().contains("Forest"))
+ return true;
+ else
+ return false;
+ }
+ });
+ if(land.size()>0)
+ setTargetCard(land.get(0));
+ }
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4320917612145305541L;
+
+ public void showMessage()
+ {
+ CardList land = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(c.getType().contains("Plains") || c.getType().contains("Forest"))
+ return true;
+ else
+ return false;
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, land, "Select a Plains or Forest to sacrifice.", false));
+ }
+ };
+ ability.setBeforePayMana(runtime);
+ ability.setDescription("T, Sacrifice a Forest or Plains: Search your library for a land card, put it into play, then shuffle your library.");
+ ability.setStackDescription(card.getName() + " - Search your library for a card and put it into play, then shuffle your library");
+ card.addSpellAbility(ability);
+
+ }
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Knight of the White Orchid"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+
+ CardList basic = new CardList(lib.getCards());
+ basic = basic.getType("Plains");
+
+
+
+ if (card.getController().equals(Constant.Player.Computer))
+ {
+ if (basic.size() > 0)
+ {
+ Card c = basic.get(0);
+ lib.remove(c);
+ play.add(c);
+
+ }
+ }
+ else // human
+ {
+ if (basic.size() > 0)
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select Plains card to put into play: ", basic.toArray());
+ if (o != null)
+ {
+ Card c = (Card)o;
+ lib.remove(c);
+ play.add(c);
+ }
+ }
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//resolve()
+
+ };//Ability
+
+ Command fetchBasicLand = new Command()
+ {
+
+ private static final long serialVersionUID = -1086551054597721988L;
+
+ public void execute()
+ {
+ String player = card.getController();
+ PlayerZone oppPlay = AllZone.getZone(Constant.Zone.Play, AllZone.GameAction.getOpponent(player));
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList self = new CardList(play.getCards());
+ CardList opp = new CardList(oppPlay.getCards());
+
+ self = self.getType("Land");
+ opp = opp.getType("Land");
+
+ if (self.size() < opp.size())
+ {
+ ability.setStackDescription(card.getName()+ " - search library for a plains and put it into play");
+ AllZone.Stack.add(ability);
+ }
+ }
+ };
+
+ card.addComesIntoPlayCommand(fetchBasicLand);
+
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Niv-Mizzet, the Firemind"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 8670005059055071206L;
+ public boolean canPlayAI() {return false;}
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Draw a card.");
+ ability.setStackDescription(card.getName() + " - draw a card.");
+ ability.setBeforePayMana(new Input_NoCost_TapAbility(ability));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Hoofprints of the Stag"))
+ {
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7275454992618058248L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ if(firstTime){
+ card.setCounter(Counters.HOOFPRINT, 0);
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addComesIntoPlayCommand(intoPlay);
+
+ final SpellAbility a2 = new Ability(card, "2 W")
+ {
+ public void resolve()
+ {
+ card.subtractCounter(Counters.HOOFPRINT, 4);
+
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Elemental");
+ c.setImageName("W 4 4 Elemental");
+ c.setManaCost("W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elemental");
+ c.addIntrinsicKeyword("Flying");
+ c.setBaseAttack(4);
+ c.setBaseDefense(4);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ }
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i= 4 && AllZone.getZone(card).is(Constant.Zone.Play) &&
+ AllZone.Phase.getActivePlayer().equals(card.getController()) &&
+ !AllZone.Phase.getPhase().equals("End of Turn");
+ }//canPlay()
+ public boolean canPlayAI()
+ {
+ return true;
+ }
+ };//spellAbility
+
+ a2.setDescription("2 W, Remove four hoofprint counters from Hoofprints of the Stag: Put a 4/4 white Elemental creature token with flying into play. Play this ability only during your turn.");
+ a2.setStackDescription(card.getName() + " - put a 4/4 white Elemental creature token with flying into play.");
+
+ card.addSpellAbility(a2);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Elvish Farmer") || cardName.equals("Mycologist"))
+ {
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 882942955555047018L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ if(firstTime){
+ card.setCounter(Counters.SPORE, 0);
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addComesIntoPlayCommand(intoPlay);
+
+ final SpellAbility a2 = new Ability(card, "0")
+ {
+ public void chooseTargetAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList saps = new CardList(play.getCards());
+ saps = saps.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c) {
+ if((c.getType().contains("Saproling") || c.getKeyword().contains("Changeling")) &&
+ AllZone.GameAction.isCardInPlay(c) )
+ return true;
+ return false;
+ }
+
+ });
+
+ if (saps.size() != 0)
+ setTargetCard(saps.getCard(0));
+ }
+ public void resolve()
+ {
+ //get all saprolings:
+ Card c = getTargetCard();
+ if(c == null )
+ return;
+
+ if (!AllZone.GameAction.isCardInPlay(c))
+ return;
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ //AllZone.getZone(c).remove(c);
+ AllZone.GameAction.sacrifice(c);
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(c.getController());
+ life.addLife(2);
+ }
+ }//resolve
+ public boolean canPlayAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ CardList saps = new CardList(play.getCards());
+ saps = saps.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c) {
+ if(c.getType().contains("Saproling") || c.getKeyword().contains("Changeling") &&
+ AllZone.GameAction.isCardInPlay(c))
+ return true;
+ return false;
+ }
+
+ });
+ if(AllZone.Computer_Life.getLife() < 6 && saps.size() > 0)
+ return true;
+ else
+ return false;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4803541385354247499L;
+
+ public void showMessage()
+ {
+ CardList saps = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ saps = saps.getType("Saproling");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, saps, "Select a Saproling to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(a2);
+ a2.setDescription("Sacrifice a Saproling: You gain 2 life.");
+ a2.setStackDescription(card.getController() + " gains 2 life.");
+ a2.setBeforePayMana(runtime);
+
+
+ }//*************** END ************ END **************************
+
+ else if (cardName.equals("Pallid Mycoderm"))
+ {
+
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 3400057700040211691L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ if(firstTime){
+ card.setCounter(Counters.SPORE, 0);
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addComesIntoPlayCommand(intoPlay);
+
+ final SpellAbility a2 = new Ability(card, "0")
+ {
+ final Command eot1 = new Command()
+ {
+ private static final long serialVersionUID = -4485431571276851181L;
+
+ public void execute()
+ {
+ String player = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList creats = new CardList(play.getCards());
+ creats = creats.getType("Creature");
+
+ for (int i=0; i < creats.size(); i++)
+ {
+ Card creat = creats.get(i);
+
+ if (creat.getType().contains("Fungus") || creat.getType().contains("Saproling") || creat.getKeyword().contains("Changeling"))
+ {
+ creat.addTempAttackBoost(-1);
+ creat.addTempDefenseBoost(-1);
+ }
+ }
+
+ }
+ };
+ public void resolve()
+ {
+ //get all player controls saprolings:
+ String player = card.getController();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList creats = new CardList(play.getCards());
+ creats = creats.getType("Creature");
+
+ @SuppressWarnings("unused") // saps
+ CardList saps = new CardList();
+
+ Card c = getTargetCard();
+ @SuppressWarnings("unused") // hand
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ //AllZone.getZone(c).remove(c);
+ AllZone.GameAction.sacrifice(c);
+
+
+ for (int i=0; i < creats.size(); i++)
+ {
+ Card creat = creats.get(i);
+
+ if (creat.getType().contains("Fungus") || creat.getType().contains("Saproling"))
+ {
+ creat.addTempAttackBoost(1);
+ creat.addTempDefenseBoost(1);
+ }
+ }
+
+ }
+ AllZone.EndOfTurn.addUntil(eot1);
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 6754180514935882692L;
+
+ public void showMessage()
+ {
+ CardList saps = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ saps = saps.getType("Saproling");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, saps, "Select a Saproling to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(a2);
+ a2.setDescription("Sacrifice a Saproling: Each Fungus and each Saproling you control gets +1/+1 until end of turn");
+ a2.setStackDescription("Saprolings and Fungi you control get +1/+1 until end of turn.");
+
+ a2.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+ //*************** START *********** START **************************
+ else if(cardName.equals("Psychotrope Thallid"))
+ {
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 8020106056714209199L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ if(firstTime){
+ card.setCounter(Counters.SPORE, 0);
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addComesIntoPlayCommand(intoPlay);
+
+ final SpellAbility a2 = new Ability(card, "1")
+ {
+ public void resolve()
+ {
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ //AllZone.getZone(c).remove(c);
+ AllZone.GameAction.sacrifice(c);
+
+ AllZone.GameAction.drawCard(c.getController());
+ }
+ }//resolve
+ public boolean canPlayAI()
+ {
+ //TODO: make AI able to use this
+ return false;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -6388866343458002392L;
+
+ public void showMessage()
+ {
+ CardList saps = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ saps = saps.getType("Saproling");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, saps, "Select a Saproling to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(a2);
+ a2.setDescription("1, Sacrifice a Saproling: You draw a card.");
+ a2.setStackDescription(card.getController() + " draws a card.");
+ a2.setBeforePayMana(runtime);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Wall of Mulch"))
+ {
+
+ final SpellAbility a2 = new Ability(card, "G")
+ {
+ public void resolve()
+ {
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ //AllZone.getZone(c).remove(c);
+ AllZone.GameAction.sacrifice(c);
+ AllZone.GameAction.drawCard(c.getController());
+ }
+ }//resolve
+ public boolean canPlayAI()
+ {
+ //TODO: make AI able to use this
+ return false;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -4390488827563977718L;
+
+ public void showMessage()
+ {
+ CardList walls = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ walls = walls.getType("Wall");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, walls, "Select a Wall to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(a2);
+ a2.setDescription("G, Sacrifice a Wall: You draw a card.");
+ a2.setStackDescription(card.getController() + " draws a card.");
+ a2.setBeforePayMana(runtime);
+
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ else if (cardName.equals("Rootwater Thief"))
+ {
+ //final String player = card.getController();
+ //final String opponent = AllZone.GameAction.getOpponent(player);
+
+ final Ability ability2 = new Ability(card, "2")
+ {
+ public void resolve()
+ {
+ String opponent = AllZone.GameAction.getOpponent(card.getController());
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, opponent);
+ CardList cards = new CardList(lib.getCards());
+
+ if (cards.size() > 0 )
+ {
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select card to remove: ", cards.toArray());
+ Card c = (Card)o;
+ AllZone.GameAction.removeFromGame(c);
+ AllZone.GameAction.shuffle(opponent);
+ }
+ else
+ {
+ Card c = lib.get(0);
+ AllZone.GameAction.removeFromGame(c);
+ AllZone.GameAction.shuffle(opponent);
+ }
+ }
+
+ }
+ public boolean canPlay()
+ {
+ //this is set to false, since it should only TRIGGER
+ return false;
+ }
+ };// ability2
+ //card.clearSpellAbility();
+ card.addSpellAbility(ability2);
+ ability2.setStackDescription(card.getName() + " - search opponent's library and remove a card from game.");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if (cardName.equals("Goblin Trenches"))
+ {
+ final String player = card.getController();
+
+ final SpellAbility ability = new Ability(card, "2")
+ {
+ public boolean canPlay()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList lands = new CardList();
+ lands.addAll(play.getCards());
+ lands = lands.getType("Land");
+
+ if (lands.size() >= 1 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+
+ public void chooseTargetAI()
+ {
+ Card c = getTappedLand(); //first, try to get a tapped land to sac
+ if (c!=null)
+ {
+ setTargetCard(c);
+
+ }
+ else
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList lands = new CardList();
+ lands.addAll(play.getCards());
+ lands = lands.getType("Land");
+
+ setTargetCard(c);
+
+ }
+ }
+ public Card getTappedLand()
+ {
+ //target creature that is going to attack
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ CardList lands = new CardList();
+ lands.addAll(play.getCards());
+ lands = lands.getType("Land");
+
+ for(int i=0;i 0 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ public boolean canPlayAI() {
+ String phase = AllZone.Phase.getPhase();
+ return phase.equals(Constant.Phase.Main2);
+ }
+
+ public void resolve()
+ {
+ card.subtractCounter(Counters.ICE, 1);
+
+ if (card.getCounters(Counters.ICE) == 0)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Marit Lage");
+ c.setManaCost("B");
+ c.setToken(true);
+
+ c.addType("Legendary");
+ c.addType("Creature");
+ c.addType("Avatar");
+ c.addIntrinsicKeyword("Flying");
+ c.addExtrinsicKeyword("Indestructible");
+ c.setBaseAttack(20);
+ c.setBaseDefense(20);
+
+ play.add(c);
+ AllZone.GameAction.sacrifice(card);
+ }// if counters == 0
+ }
+ };
+ ability.setDescription("3: Remove an ice counter from Dark Depths.");
+ ability.setStackDescription(card.getName() +" - remove an ice counter.");
+
+ card.addSpellAbility(ability);
+
+ }//*************** END ************ END **************************
+ /*
+ //*************** START *********** START **************************
+ else if (cardName.equals("Acridian"))
+ {
+ final String player = card.getController();
+
+ final Ability echo = new Ability(card, "1 G")
+ {
+ public void resolve()
+ {
+ card.setEchoPaid(true);
+ System.out.println("set echo to true");
+ }
+ public boolean canPlay()
+ {
+ //this is set to false, since it should only TRIGGER
+ return false;
+ }
+ };// ability2
+ //card.clearSpellAbility();
+ card.addSpellAbility(echo);
+ echo.setStackDescription(card.getName() + " - " + player + " paid echo.");
+
+ Command paid = new Command() {public void execute() {AllZone.Stack.add(echo);}};
+
+ //echo.setBeforePayMana(new Input_PayManaCost_Ability(echo.getManaCost(), paid));
+ echo.setAfterPayMana(new Input_PayManaCost_Ability(echo.getManaCost(), paid));
+
+
+ }//*************** END ************ END **************************
+
+ */
+
+ //*************** START *********** START **************************
+ else if (cardName.equals("Oros, the Avenger"))
+ {
+ final String player = card.getController();
+
+ final Ability ability2 = new Ability(card, "2 W")
+ {
+ public void resolve()
+ {
+ if (player.equals("Human"))
+ {
+ CardList cards = new CardList();
+ PlayerZone hum = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ cards.addAll(hum.getCards());
+ cards.addAll(comp.getCards());
+ cards = cards.getType("Creature");
+
+ for (int i=0;i 0;
+ }
+
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if (c!=null)
+ {
+ if ( CardFactoryUtil.canTarget(card, c) && c.isCreature() && c.getType().contains("Legendary") )
+ AllZone.GameAction.moveTo(AllZone.getZone(Constant.Zone.Hand, card.getOwner()), c);
+ }
+ }
+ };
+
+ Input runtime = new Input()
+ {
+
+ private static final long serialVersionUID = -7649200192384343204L;
+
+ public void showMessage()
+ {
+ CardList choice = new CardList();
+ choice.addAll(AllZone.Human_Play.getCards());
+ choice.addAll(AllZone.Computer_Play.getCards());
+
+ choice = choice.getType("Creature");
+ choice = choice.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return (c.isCreature() && c.getType().contains("Legendary"));
+ }
+ });
+
+ //System.out.println("size of choice: " + choice.size());
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, choice, "Select target Legendary creature:", true));
+ }
+ };
+
+ ability.setDescription("tap: Return target legendary creature to its owner's hand.");
+ //ability.setStackDescription(card.getName() + " - gives target creature +1/+2 until end of turn.");
+
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(runtime);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add G");
+ card.setText(card.getSpellText() + "\r\ntap: Return target legendary creature to its owner's hand.");
+ //card.addIntrinsicKeyword("tap: add G");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Pendelhaven"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = 8154776336533992188L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ CardList att = new CardList();
+ att.addAll(c.getAttackers());
+
+ for (int i=0; i 0 && AllZone.GameAction.isCardInPlay(card) && card.isUntapped())
+ return true;
+ else
+ return false;
+ }
+
+ };
+
+ ability.setDescription("1 U, tap: Put target artifact card in your graveyard on top of your library.");
+ ability.setStackDescription(card.getName() + " - put artifact card in your graveyard on top of your library.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n1 U, tap: Put target artifact card in your graveyard on top of your library.");
+ //card.addExtrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Volrath's Stronghold"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1 B")
+ {
+ private static final long serialVersionUID = 2821525387844776907L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+
+ public void humanResolve()
+ {
+ CardList cards = new CardList(AllZone.Human_Graveyard.getCards());
+
+ CardList list = new CardList();
+
+ for (int i=0;i < cards.size(); i++)
+ {
+ //System.out.println("type: " +cards.get(i).getType());
+ if (cards.get(i).getType().contains("Creature")){
+ //System.out.println(cards.get(i).getName());
+ Card c = cards.get(i);
+ list.add(c);
+
+ }
+ }
+
+ if (list.size() != 0) {
+ Object check = AllZone.Display.getChoiceOptional("Select Creature", list.toArray());
+ if(check != null)
+ {
+ //PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ //library.add((Card)check, 0);
+ AllZone.GameAction.moveToTopOfLibrary((Card)check);
+ }
+ }
+ }
+ public void computerResolve()
+ {
+ Card[] grave = AllZone.Computer_Graveyard.getCards();
+ CardList list = new CardList(grave);
+ CardList creats = new CardList();
+
+ for (int i=0;i < list.size(); i++)
+ {
+ if (list.get(i).getType().contains("Creature")){
+ Card k = list.get(i);
+ creats.add(k);
+ }
+
+ }
+
+ //pick best artifact
+ if (creats.size() != 0){
+ Card c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null)
+ c = grave[0];
+ //System.out.println("computer picked - " +c);
+ AllZone.Computer_Graveyard.remove(c);
+ //AllZone.Computer_Library.add(c, 0);
+ AllZone.GameAction.moveToTopOfLibrary(c);
+ }
+ }//computerResolve
+
+ public boolean canPlay(){
+ String controller = card.getController();
+
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, controller);
+ CardList list = new CardList(grave.getCards());
+ CardList cards = new CardList();
+
+ for (int i=0;i 0 && AllZone.GameAction.isCardInPlay(card) && card.isUntapped())
+ return true;
+ else
+ return false;
+ }
+
+ };
+
+ ability.setDescription("1 B, tap: Put target creature card in your graveyard on top of your library.");
+ ability.setStackDescription(card.getName() + " - put creature card in your graveyard on top of your library.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n1 U, tap: Put target creature card in your graveyard on top of your library.");
+ //card.addExtrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Oboro, Palace in the Clouds"))
+ {
+ final Ability ability = new Ability(card, "1")
+ {
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, card);
+ }
+ };
+
+ ability.setDescription("1: Return Oboro, Palace in the Clouds to your hand.");
+ ability.setStackDescription("Return " + card.getName() + " to your hand.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n1: Return Oboro, Palace in the Clouds to your hand.");
+ //card.addExtrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Mikokoro, Center of the Sea"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "2")
+ {
+ private static final long serialVersionUID = -199960897120235012L;
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(Constant.Player.Computer);
+ AllZone.GameAction.drawCard(Constant.Player.Human);
+ }
+ };
+
+ ability.setDescription("2, tap: Each player draws a card.");
+ ability.setStackDescription(card.getName() + " - Each player draws a card.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n2, tap: Each player draws a card.");
+ //card.addExtrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Gargoyle Castle"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "5")
+ {
+
+ private static final long serialVersionUID = 8524185208900629992L;
+
+ public boolean canPlay()
+ {
+ if (AllZone.GameAction.isCardInPlay(card) && card.isUntapped())
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ String player = card.getController();
+ AllZone.GameAction.sacrifice(card);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Gargoyle");
+ c.setImageName("C 3 4 Gargoyle");
+ c.setManaCost("1");
+ c.setToken(true);
+
+ c.addType("Artifact");
+ c.addType("Creature");
+ c.addType("Gargoyle");
+ c.setBaseAttack(3);
+ c.setBaseDefense(4);
+ c.addIntrinsicKeyword("Flying");
+
+ play.add(c);
+ }
+ };
+
+ ability.setDescription("5, tap, sacrifice Gargoyle Castle: Put a 3/4 colorless Gargoyle artifact creature token with flying onto the battlefield.");
+ ability.setStackDescription(card.getName() + " - Put a 3/4 colorless Gargoyle artifact creature token with flying onto the battlefield.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n5, tap, sacrifice Gargoyle Castle: Put a 3/4 colorless Gargoyle artifact creature token with flying onto the battlefield.");
+ //card.addIntrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Kher Keep"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1 R")
+ {
+ private static final long serialVersionUID = 4037838521451709399L;
+
+ public boolean canPlay()
+ {
+ if (AllZone.GameAction.isCardInPlay(card) && card.isUntapped())
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ String player = card.getController();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Kobolds of Kher Keep");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Kobold");
+ c.setBaseAttack(0);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }
+ };
+
+ ability.setDescription("1 R, tap: Put a 0/1 red Kobold creature token named Kobolds of Kher Keep into play.");
+ ability.setStackDescription(card.getName() + " - Put a 0/1 red Kobold creature token named Kobolds of Kher Keep into play.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n1 R, tap: Put a 0/1 red Kobold creature token named Kobolds of Kher Keep into play.");
+ //card.addIntrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Vitu-Ghazi, the City-Tree"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "2 G W")
+ {
+ private static final long serialVersionUID = 1781653158406511188L;
+
+ public boolean canPlay()
+ {
+ if (AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ String player = card.getController();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }
+ };
+
+ ability.setDescription("2 G W, tap: Put a 1/1 green Saproling creature token into play.");
+ ability.setStackDescription(card.getName() + " - Put a 1/1 green Saproling creature token named into play.");
+
+ card.addSpellAbility(ability);
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ //card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getSpellText() + "\r\n 2 G W, tap: Put a 1/1 green Saproling creature token into play.");
+ //card.addIntrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Hatching Plans"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ };
+
+ Command draw3Cards = new Command()
+ {
+ private static final long serialVersionUID = -4919203791300685078L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - draw three cards.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(draw3Cards);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Anodet Lurker"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(3);
+ }
+ };
+
+ Command gain3Life = new Command()
+ {
+ private static final long serialVersionUID = 9156307402354672176L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - Gain 3 life.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(gain3Life);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Tarpan"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(1);
+ }
+ };
+
+ Command gain1Life = new Command()
+ {
+ private static final long serialVersionUID = 206350020224577500L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - Gain 1 life.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(gain1Life);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Onulet"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(2);
+ }
+ };
+
+ Command gain2Life = new Command()
+ {
+ private static final long serialVersionUID = 7840609060047275126L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - Gain 2 life.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(gain2Life);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Sprouting Thrinax"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ makeToken();
+ makeToken();
+ makeToken();
+ }//resolve()
+
+ void makeToken()
+ {
+ Card c = new Card();
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ };//Ability
+
+ Command make3Tokens = new Command()
+ {
+ private static final long serialVersionUID = 5246587197020320581L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - put three 1/1 Saproling creature tokens into play.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(make3Tokens);
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Solemn Simulacrum"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ CardList basic = new CardList(lib.getCards());
+ basic = basic.getType("Basic");
+
+ if (card.getController().equals(Constant.Player.Computer))
+ {
+ if (basic.size() > 0)
+ {
+ Card c = basic.get(0);
+ lib.remove(c);
+ play.add(c);
+ c.tap();
+
+ }
+ }
+ else // human
+ {
+ if (basic.size() > 0)
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select Basic Land card to put into play tapped: ", basic.toArray());
+ if (o != null)
+ {
+ Card c = (Card)o;
+ lib.remove(c);
+ play.add(c);
+ c.tap();
+ }
+ }
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//resolve()
+ };//Ability
+
+ Command fetchBasicLand = new Command()
+ {
+ private static final long serialVersionUID = -7912757481694029348L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - search library for a basic land card and put it into play tapped.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ final Ability ability2 = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+
+ AllZone.GameAction.drawCard(card.getController());
+ }//resolve()
+ };//Ability
+
+ Command draw = new Command()
+ {
+ private static final long serialVersionUID = -549395102229088642L;
+
+ public void execute()
+ {
+ ability2.setStackDescription(card.getName()+ " - Draw a card.");
+ AllZone.Stack.add(ability2);
+ }
+ };
+
+ card.addDestroyCommand(draw);
+ card.addComesIntoPlayCommand(fetchBasicLand);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Gods' Eye, Gate to the Reikai"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("1");
+ c.setToken(true);
+
+ c.setName("Spirit");
+ c.setImageName("C 1 1 Spirit");
+
+ c.addType("Creature");
+ c.addType("Spirit");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+
+ }//resolve()
+ };//Ability
+
+ Command makeToken = new Command()
+ {
+ private static final long serialVersionUID = 2339209292936869322L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - put a 1/1 Spirit creature token into play");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(makeToken);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Flagstones of Trokair"))
+ {
+
+ final Ability ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ CardList plains = new CardList(lib.getCards());
+ plains = plains.getType("Plains");
+
+ if (card.getController().equals(Constant.Player.Computer))
+ {
+ if (plains.size() > 0)
+ {
+ Card c = plains.get(0);
+ lib.remove(c);
+ play.add(c);
+ c.tap();
+
+ }
+ }
+ else // human
+ {
+ if (plains.size() > 0)
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select plains card to put into play tapped: ", plains.toArray());
+ if (o != null)
+ {
+ Card c = (Card)o;
+ lib.remove(c);
+ play.add(c);
+ c.tap();
+ }
+ }
+ }
+ AllZone.GameAction.shuffle(card.getController());
+ }//resolve()
+ };//Ability
+
+ Command fetchPlains = new Command()
+ {
+
+ private static final long serialVersionUID = 5991465998493672076L;
+
+ public void execute()
+ {
+ ability.setStackDescription(card.getName()+ " - search library for a plains card and put it into play tapped.");
+ AllZone.Stack.add(ability);
+ }
+ };
+
+ card.addDestroyCommand(fetchPlains);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Master Transmuter"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "U")
+ {
+
+ private static final long serialVersionUID = -9076784333448226913L;
+
+ public void resolve() {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList artifacts = new CardList(hand.getCards());
+ artifacts = artifacts.getType("Artifact");
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select artifact to put onto the battlefield: ", artifacts.toArray());
+ if(o!=null)
+ {
+ Card c = (Card)o;
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ else
+ {
+ //CardList arts = new CardList(play.getCards());
+ //arts = arts.getType("Artifact");
+
+ Card c = getTargetCard();
+ AllZone.GameAction.moveTo(hand, c);
+
+ Card crd = CardFactoryUtil.AI_getMostExpensivePermanent(artifacts, card, false);
+ hand.remove(crd);
+ play.add(crd);
+
+ }
+ }
+
+ public boolean canPlayAI()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+
+ CardList handArts = new CardList(hand.getCards());
+ handArts = handArts.getType("Artifact");
+
+ CardList playArts = new CardList(play.getCards());
+ playArts = playArts.getType("Artifact");
+
+ if (handArts.size() > 0 && playArts.size() > 0){
+
+ if (CardUtil.getConvertedManaCost(CardFactoryUtil.AI_getCheapestPermanent(playArts, card, false).getManaCost()) <
+ CardUtil.getConvertedManaCost(CardFactoryUtil.AI_getMostExpensivePermanent(handArts, card, false).getManaCost()))
+ {
+ setTargetCard(CardFactoryUtil.AI_getCheapestPermanent(playArts, card, false));
+ return true;
+ }
+
+ }
+ return false;
+ }
+ };
+
+ Input target = new Input()
+ {
+
+ private static final long serialVersionUID = 4246650335595231655L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select artifact to return to hand");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play,card.getController());
+ if(c.isArtifact() && AllZone.GameAction.isCardInZone(c, play))
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand,card.getController());
+
+ AllZone.GameAction.moveTo(hand, c);
+ AllZone.Stack.add(ability);
+ stopSetNext(new ComputerAI_StackNotEmpty());
+ }
+ }//selectCard()
+ };//Input
+
+ card.addSpellAbility(ability);
+ ability.setDescription("U, tap, Return an artifact you control to its owner's hand: You may put an artifact card from your hand onto the battlefield.");
+ ability.setStackDescription(card + "You may put an artifact card from your hand onto the battlefield");
+ ability.setAfterPayMana(target);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Hanna, Ship's Navigator"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1 U W")
+ {
+ private static final long serialVersionUID = 7959233413572648987L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }//resolve()
+ public void humanResolve()
+ {
+ CardList cards = new CardList(AllZone.Human_Graveyard.getCards());
+ //legends = legends.getType().contains("Legendary");
+ CardList list = new CardList();
+
+ for (int i=0;i < cards.size(); i++)
+ {
+ //System.out.println("type: " +cards.get(i).getType());
+ if (cards.get(i).getType().contains("Artifact") || cards.get(i).getType().contains("Enchantment")){
+ //System.out.println(cards.get(i).getName());
+ Card c = cards.get(i);
+ list.add(c);
+
+ }
+ }
+
+ if (list.size() != 0) {
+ Object check = AllZone.Display.getChoiceOptional("Select Artifact or Enchantment", list.toArray());
+ if(check != null)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, (Card)check);
+ }
+ }
+ }
+ public void computerResolve()
+ {
+ Card[] grave = AllZone.Computer_Graveyard.getCards();
+ CardList list = new CardList(grave);
+ CardList artenchants = new CardList();
+ //list = list.getType("Creature");
+
+ for (int i=0;i < list.size(); i++)
+ {
+ if (list.get(i).getType().contains("Artifact") || list.get(i).getType().contains("Enchantment")){
+ Card k = list.get(i);
+ artenchants.add(k);
+ }
+
+ }
+
+ //pick best artifact / enchantment
+ if (artenchants.size() != 0){
+ Card c = CardFactoryUtil.AI_getBestArtifact(list);
+ if(c == null)
+ c = CardFactoryUtil.AI_getBestEnchantment(list,card, true);
+ if(c == null)
+ c = grave[0];
+ System.out.println("computer picked - " +c);
+ AllZone.Computer_Graveyard.remove(c);
+ AllZone.Computer_Hand.add(c);
+ }
+ }//computerResolve
+
+ public boolean canPlay(){
+ String controller = card.getController();
+
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, controller);
+ CardList list = new CardList(grave.getCards());
+ CardList cards = new CardList();
+
+ for (int i=0;i 0 && AllZone.GameAction.isCardInPlay(card) && !card.hasSickness() && card.isUntapped())
+ return true;
+ else
+ return false;
+ }
+
+
+ };//SpellAbility
+ //card.addSpellAbility(ability);
+ ability.setDescription("1 U W, tap: Return target artifact or enchantment card from your graveyard to your hand.");
+ ability.setBeforePayMana(new Input_PayManaCost(ability));
+ ability.setStackDescription("Hanna, Ship's Navigator - Returns an artifact or enchantment card from graveyard to hand.");
+ card.addSpellAbility(ability);
+
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Sleight of Hand"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5608200094037045828L;
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ if (library.size() >= 1 && super.canPlay())
+ return true;
+ else
+ return false;
+
+ }
+ public void resolve()
+ {
+
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library,card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ CardList lib = new CardList(library.getCards());
+
+ CardList topTwo = new CardList();
+
+ if (lib.size() == 1) {
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ else
+ {
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ topTwo.add(lib.get(0));
+ topTwo.add(lib.get(1));
+
+ Object o = AllZone.Display.getChoiceOptional("Select card to put in hand: ", topTwo.toArray());
+
+ Card c1 = (Card)o;
+ topTwo.remove(c1);
+ library.remove(c1);
+ hand.add(c1);
+
+ Card c2 = topTwo.get(0);
+ library.remove(c2);
+ library.add(c2);
+ }
+ else //computer
+ {
+ Card c1 = lib.get(0);
+ library.remove(c1);
+ lib.remove(c1);
+ hand.add(c1);
+
+ Card c2 = lib.get(0);
+ library.remove(c2);
+ lib.remove(c2);
+ library.add(c2); //put on bottom
+
+ }
+
+ }
+
+ }
+ };
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Brainstorm"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -5722651962081633839L;
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+
+ public void humanResolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, Constant.Player.Human);
+
+ CardList putOnTop = new CardList(hand.getCards());
+
+ Object o = AllZone.Display.getChoiceOptional("First card to put on top: ", putOnTop.toArray());
+ if(o != null)
+ {
+ Card c1 = (Card)o;
+ putOnTop.remove(c1);
+ hand.remove(c1);
+ lib.add(c1,0);
+ }
+ o = AllZone.Display.getChoiceOptional("Second card to put on top: ", putOnTop.toArray());
+ if(o != null)
+ {
+ Card c2 = (Card)o;
+ putOnTop.remove(c2);
+ hand.remove(c2);
+ lib.add(c2,0);
+ }
+
+ }
+
+ public void computerResolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer);
+
+ CardList putOnTop = new CardList(hand.getCards());
+
+ Card c1 = putOnTop.get(0);
+ putOnTop.remove(c1);
+ hand.remove(c1);
+ lib.add(c1, 0);
+
+ Card c2 = putOnTop.get(0);
+ putOnTop.remove(c2);
+ hand.remove(c2);
+ lib.add(c2, 0);
+ //TODO: somehow find the least desirable cards at the moment, and put those on top
+ }
+
+ public boolean canPlay()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ if (lib.size() >= 2)
+ return true;
+ else
+ return false;
+ }
+
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Banishing Knack"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6518824567946786581L;
+ public boolean canPlayAI(){return false;}
+ public void resolve()
+ {
+ final Card creature = getTargetCard();
+ final Ability_Tap tBanish = new Ability_Tap(creature)
+ {
+ private static final long serialVersionUID = -1008113001678623984L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ setStackDescription(creature+" - Return"+getTargetCard()+"to its owner's hand");
+ final Card[] target = new Card[1];
+ target[0] = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, target[0].getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(creature, target[0]) )
+ {
+ AllZone.GameAction.moveTo(hand ,target[0]);
+ }
+ }//resolve()
+ };//tBanish;
+ tBanish.setDescription("T: Return target nonland permanent to its owner's hand.");
+ creature.addSpellAbility(tBanish);
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return (!c.isLand() && CardFactoryUtil.canTarget(creature, c));
+ }
+ });
+ tBanish.setBeforePayMana(CardFactoryUtil.input_targetSpecific(tBanish, all, "Return target nonland permanent to its owner's hand.", true));
+ AllZone.EndOfTurn.addUntil(new Command(){
+ private static final long serialVersionUID = -7819140065166374666L;
+
+ public void execute(){
+ creature.removeSpellAbility(tBanish);
+ }
+ });
+ }
+ };//SpellAbility
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ spell.setDescription("Until end of turn, target creature gains \"T: Return target nonland permanent to its owner's hand.\"");
+ spell.setStackDescription("Target creature gains \"T: Return target nonland permanent to its owner's hand.\"");
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Cromat")){
+
+ //LibBounce Ability
+ final Ability a1 = new Ability(card, "G U")
+ {
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card) )
+ {
+ card.setBaseAttack(5);
+ card.setBaseDefense(5);
+
+ card.setAssignedDamage(0);
+ card.setDamage(0);
+ card.untap();
+ AllZone.getZone(card).remove(card);
+
+ //put card on top of library
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
+ library.add(card, 0);
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input runtime1 = new Input()
+ {
+ private static final long serialVersionUID = 1469011418219527227L;
+
+ public void showMessage()
+ {
+ a1.setStackDescription("Put " +card +" on top of its owner's library");
+
+ stopSetNext(new Input_PayManaCost(a1));
+ }
+ };
+ a1.setDescription("G U: Put Cromat on top of its owner's library.");
+ a1.setStackDescription("Put Cromat on top of its owner's library.");
+ card.addSpellAbility(a1);
+ a1.setBeforePayMana(runtime1);
+ //Kill ability
+
+ final Ability a2 = new Ability(card, "W B"){
+ public boolean canPlay()
+ {
+ return (AllZone.GameAction.isCardInPlay(card) && (AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card)));
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ //TODO
+ }
+ public void resolve()
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }//resolve()
+ };
+ Input runtime2 = new Input()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void showMessage()
+ {
+ CardList targets = new CardList();
+ if(AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card)){
+ if (AllZone.Combat.isBlocked(card)){ targets = AllZone.Combat.getBlockers(card); }
+ else {
+ targets = new CardList();
+ for (Card c : AllZone.Combat.getAttackers()){
+ if (AllZone.Combat.isBlocked(c))
+ if (AllZone.Combat.getBlockers(c).contains(card)) targets.add(c);
+ }
+ }
+ }
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, targets, "Select target blocking or blocked by Cromat.", true));
+ }
+ };
+ card.addSpellAbility(a2);
+ a2.setBeforePayMana(runtime2);
+ a2.setDescription("W B: Destroy target creature blocking or blocked by Cromat.");
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Mutavault"))
+ {
+ final Command eot1 = new Command()
+ {
+ private static final long serialVersionUID = 5106629534549783845L;
+
+ public void execute()
+ {
+ Card c = card;
+
+ c.setBaseAttack(0);
+ c.setBaseDefense(0);
+ c.removeIntrinsicKeyword("Changeling");
+ c.removeType("Creature");
+ }
+ };
+
+ final SpellAbility a1 = new Ability(card, "1")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ Card c = card;
+
+ c.setBaseAttack(2);
+ c.setBaseDefense(2);
+
+ //to prevent like duplication like "Changeling Changeling Creature Creature"
+ if(! c.getIntrinsicKeyword().contains("Changeling"))
+ {
+ c.addIntrinsicKeyword("Changeling");
+ c.addType("Creature");
+ }
+ AllZone.EndOfTurn.addUntil(eot1);
+ }
+ };//SpellAbility
+
+ card.clearSpellAbility();
+ card.addSpellAbility(a1);
+ a1.setDescription("1: Mutavault becomes a 2/2 creature with all creature types until end of turn. It's still a land.");
+ a1.setStackDescription(card +" becomes a 2/2 creature with changeling until EOT");
+
+ Command paid1 = new Command() {
+ private static final long serialVersionUID = -601119544294387668L;
+ public void execute() {AllZone.Stack.add(a1);}
+ };
+
+ a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
+
+ //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
+ //anyway, this does the trick:
+ card.removeIntrinsicKeyword("tap: add 1");
+ card.setText(card.getText() + "\r\n1: Mutavault becomes a 2/2 creature with all creature types until end of turn. It's still a land.");
+ card.addIntrinsicKeyword("tap: add 1");
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Dragon Blood"))
+ {
+ Ability_Tap ability = new Ability_Tap(card, "3")
+ {
+ private static final long serialVersionUID = -8095802059752537764L;
+ public void resolve()
+ {
+ if(getTargetCard() != null && getTargetCard().isCreature()
+ && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addCounter(Counters.P1P1,1);
+ }
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(list));
+ return (getTargetCard() != null);
+ }
+ };
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ ability.setDescription("3, T: Put a +1/+1 counter on target creature.");
+ ability.setStackDescription(card+": put a +1/+1 counter on target Creature.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Reminisce"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 505983020365091226L;
+
+ public void resolve()
+ {
+ String player = getTargetPlayer();
+ // Move graveyard into library
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
+ Card[] g = grave.getCards();
+ for (int i = 0; i < g.length; i++)
+ {
+ grave.remove(g[i]);
+ library.add(g[i],0);
+ }
+ // Shuffle library
+ AllZone.GameAction.shuffle(player);;
+ }
+
+ public boolean canPlayAI()//97% of the time shuffling your grave into your library is a good thing
+ {
+ setTargetPlayer(Constant.Player.Computer);
+ return true;
+ }
+
+ };//SpellAbility
+ spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Energizer"))
+ {
+ Ability_Tap ability = new Ability_Tap(card, "2")
+ {
+ private static final long serialVersionUID = 6444406158364728638L;
+ public void resolve()
+ {
+ card.addCounter(Counters.P1P1,1);
+ }
+ public boolean canPlayAI()
+ {
+ return(true);
+ }
+ };
+ ability.setDescription("2, T: Put a +1/+1 counter on Energizer.");
+ ability.setStackDescription("Put a +1/+1 counter on target Energizer.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("AEther Vial"))
+ {
+ //final int[] converted = null;
+ final Ability_Tap ability = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = 1854859213307704018L;
+
+ public boolean canPlay()
+ {
+ return card.getCounters(Counters.CHARGE) > 0;
+ }
+
+ public void resolve() {
+ String player = card.getController();
+
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+
+ //converted[0] = card.getCounters(Counters.CHARGE);
+ //System.out.println("converted: " + converted[0]);
+
+ CardList list = new CardList(hand.getCards());
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return CardUtil.getConvertedManaCost(c.getManaCost()) == card.getCounters(Counters.CHARGE) && c.isCreature();
+ }
+ });
+
+
+ if (list.size()>0)
+ {
+ if (player.equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Pick creature to put into play", list.toArray());
+ if (o!=null)
+ {
+ Card c = (Card)o;
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ else
+ {
+ Card c = list.get(0);
+ if(AllZone.GameAction.isCardInZone(c, hand)) {
+ hand.remove(c);
+ play.add(c);
+ }
+ }
+ }
+ }
+ };
+
+ ability.setDescription("Tap: You may put a creature card with converted mana cost equal to the number of charge counters on AEther Vial from your hand into play.");
+ ability.setStackDescription(card.getName() + " - put creature card with converted mana cost equal to the number of charge counters into play.");
+
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("AEther Spellbomb"))
+ {
+
+ final Ability ability = new Ability(card, "U")
+ {
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);
+ }
+ public boolean canPlayAI()
+ {
+ CardList humanPlay = new CardList(AllZone.Human_Play.getCards());
+ if (humanPlay.size() > 0)
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(humanPlay));
+ return ((AllZone.Computer_Hand.size() > 2)&&(getTargetCard() != null)) ;
+ }
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ target[0] = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, target[0].getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ if (!target[0].isToken())
+ AllZone.GameAction.moveTo(hand ,target[0]);
+ else
+ AllZone.getZone(target[0]).remove(target[0]);
+ }
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }//resolve()
+ };//SpellAbility
+ ability.setDescription("U, Sacrifice AEther Spellbomb: Return target creature to its owner's hand.");
+ card.addSpellAbility(ability);
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
+ }
+ //*************** START *********** START **************************
+ if(cardName.equals("Lifespark Spellbomb"))
+ {
+ final SpellAbility ability = new Ability_Activated(card, "G")
+ {
+ private static final long serialVersionUID = -5744842090293912606L;
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);
+ }
+ public boolean canPlayAI()
+ {
+ CardList land = new CardList(AllZone.Computer_Play.getCards());
+ land = land.getType("Land");
+ CardList basic = land.getType("Basic");
+ if (basic.size() < 3) return false;
+ Card[] basic_1 = basic.toArray();
+ for(Card var : basic_1)
+ if (var.isTapped()) basic.remove(var);
+ basic.shuffle();
+ if (basic.size() == 0)
+ return false;
+ if (basic.get(0) != null) {
+ setTargetCard(basic.get(0));
+ return true;
+ }
+ return false;
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ //in case ability is played twice
+ final int[] oldAttack = new int[1];
+ final int[] oldDefense = new int[1];
+
+ final Card card[] = new Card[1];
+ card[0] = getTargetCard();
+
+ oldAttack[0] = card[0].getBaseAttack();
+ oldDefense[0] = card[0].getBaseDefense();
+
+ card[0].setBaseAttack(3);
+ card[0].setBaseDefense(3);
+ card[0].addType("Creature");
+
+ //EOT
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 7236360479349324099L;
+
+ public void execute()
+ {
+ card[0].setBaseAttack(oldAttack[0]);
+ card[0].setBaseDefense(oldDefense[0]);
+
+ card[0].removeType("Creature");
+ }
+ };
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }//resolve()
+ };//SpellAbility
+ card.addSpellAbility(ability);
+ ability.setDescription("G, Sacrifice Lifespark Spellbomb: Target land becomes a 3/3 Creature until end of turn. It is still a land.");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetType(ability, "Land"));
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Pyrite Spellbomb"))
+ {
+
+ final SpellAbility ability = new Ability_Activated(card, "R")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);
+ }
+ public boolean canPlayAI()
+ {
+ Random r = new Random();
+ if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
+ return true;
+ else
+ return false;
+ }
+
+ public void chooseTargetAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(2, card, true);
+ list.shuffle();
+
+ if(list.isEmpty() || AllZone.Human_Life.getLife() < 5 + 2)
+ setTargetPlayer(Constant.Player.Human);
+ else
+ setTargetCard(list.get(0));
+ }//chooseTargetAI
+ public void resolve()
+ {
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ getTargetCard().addDamage(2);
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(2);
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }//resolve()
+ };//Ability_Activated
+
+ ability.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(ability, true));
+ ability.setDescription("R, Sacrifice Pyrite Spellbomb: Pyrite Spellbomb deals 2 damage to target creature or player.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Sunbeam Spellbomb"))
+ {
+ final Ability ability = new Ability(card, "W")
+ {
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);
+ }
+ public boolean canPlayAI()
+ {
+ return (AllZone.GameAction.getPlayerLife(Constant.Player.Computer).getLife() < 7);
+ }
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(card.getController()).addLife(5);
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }//resolve()
+ };//SpellAbility
+ ability.setStackDescription("You gain 5 life");
+ ability.setDescription("W, Sacrifice Sunbeam Spellbomb: You gain 5 life.");
+ card.addSpellAbility(ability);
+ } //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Necrogen Spellbomb"))
+ {
+ final Ability ability = new Ability(card, "B")
+ {
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);
+ }
+ public boolean canPlayAI()
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return (MyRandom.random.nextBoolean()&&AllZone.Human_Hand.size()>0);
+ }
+ public void resolve()
+ {
+ String s = getTargetPlayer();
+ setStackDescription("Necrogen Spellbomb - " +s +" discards a card");
+ if(Constant.Player.Computer.equals(getTargetPlayer()))
+ AllZone.GameAction.discardRandom(getTargetPlayer());
+ else
+ AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }//resolve()
+ };//SpellAbility
+ ability.setDescription("B, Sacrifice Necrogen Spellbomb: Target player discards a card");
+ ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
+ card.addSpellAbility(ability);
+ } //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Sensei's Divining Top"))
+ {
+ //ability2: Draw card, and put divining top on top of library
+ final SpellAbility ability2 = new Ability_Tap(card, "0")
+ {
+ private static final long serialVersionUID = -2523015092351744208L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+ String owner = card.getOwner();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, owner);
+
+ AllZone.GameAction.drawCard(player);
+ play.remove(card);
+ lib.add(card,0); //move divining top to top of library
+ card.untap();
+
+ }
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ if (AllZone.getZone(card).is(Constant.Zone.Play))
+ return true;
+ else
+ return false;
+ }//canPlay()
+ };//SpellAbility ability2
+
+ ability2.setBeforePayMana(new Input()
+ {
+ private static final long serialVersionUID = -4773496833654414458L;
+ @SuppressWarnings("unused") // check
+ int check = -1;
+ public void showMessage()
+ {
+ AllZone.Stack.push(ability2);
+ stop();
+ }//showMessage()
+ });
+
+
+
+ //ability (rearrange top 3 cards) :
+ final SpellAbility ability1 = new Ability(card, "1")
+ {
+ public void resolve()
+ {
+ String player = card.getController();
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
+
+ if (lib.size() < 3)
+ return;
+
+ CardList topThree = new CardList();
+
+ //show top 3 cards:
+ topThree.add(lib.get(0));
+ topThree.add(lib.get(1));
+ topThree.add(lib.get(2));
+
+ for (int i=1;i<=3;i++){
+ String Title = "Put on top: ";
+ if (i==2)
+ Title = "Put second from top: ";
+ if (i==3)
+ Title = "Put third from top: ";
+ Object o = AllZone.Display.getChoiceOptional(Title, topThree.toArray());
+ if(o == null)
+ break;
+ Card c_1 = (Card)o;
+ topThree.remove(c_1);
+ lib.remove(c_1);
+ lib.add(c_1,i-1);
+ }
+
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+
+ }
+ public boolean canPlay()
+ {
+ if (AllZone.getZone(card).is(Constant.Zone.Play))
+ return true;
+ else
+ return false;
+ }//canPlay()
+ };//SpellAbility ability1
+
+
+ ability1.setDescription("1: Look at the top three cards of your library, then put them back in any order.");
+ ability1.setStackDescription("Sensei's Divining Top - rearrange top 3 cards");
+ card.addSpellAbility(ability1);
+ ability1.setBeforePayMana(new Input_PayManaCost(ability1));
+
+ ability2.setDescription("tap: Draw a card, then put Sensei's Divining Top on top of its owner's library.");
+ ability2.setStackDescription("Sensei's Divining Top - draw a card, then put back on owner's library");
+ ability2.setBeforePayMana(new Input_NoCost_TapAbility((Ability_Tap) ability2));
+ card.addSpellAbility(ability2);
+
+ }
+ //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Sphinx of Jwar Isle"))
+ {
+ final SpellAbility ability1 = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ String player = card.getController();
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
+
+ if (lib.size() < 1)
+ return;
+
+ CardList cl = new CardList();
+ cl.add(lib.get(0));
+
+ AllZone.Display.getChoiceOptional("Top card", cl.toArray());
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };
+
+ ability1.setStackDescription(card.getName() + " - look at top card of library.");
+ ability1.setDescription("You may look at the top card of your library.");
+ card.addSpellAbility(ability1);
+ }
+ //*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Imperial Recruiter"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ if(AllZone.GameAction.isCardInZone(getTargetCard(), lib))
+ {
+ Card c = getTargetCard();
+ AllZone.GameAction.shuffle(card.getController());
+ lib.remove(c);
+ hand.add(c, 0);
+
+ }
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -8887306085997352723L;
+
+ public void execute()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList cards = new CardList(lib.getCards());
+ CardList powerTwoCreatures = new CardList();
+
+ for (int i=0;i 0)
+ {
+ if (card.getController().equals("Human"))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select a card in opponent's graveyard to remove", gravecards.toArray());
+ if (o!=null)
+ {
+ Card removedCard = (Card)o;
+ AllZone.GameAction.removeFromGame(removedCard);
+ }
+ }
+ else
+ {
+ AllZone.GameAction.removeFromGame(gravecards.get(0));
+ }
+ }
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ CardList creatures = new CardList(play.getCards());
+ creatures = creatures.getType("Creature");
+
+ //Object o = AllZone.Display.getChoiceOptional("Select a creature card to bounce", blackBlue.toArray());
+
+
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetSpecific(ability, creatures, "Select a creature you control.", false));
+ ButtonUtil.disableAll();
+
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = 3089921616375272120L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Cavern Harpy"))
+ {
+ final SpellAbility a1 = new Ability(card,"0")
+ {
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.subtractLife(1);
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getOwner());
+
+ if (card.isToken())
+ AllZone.getZone(card).remove(card);
+ else
+ AllZone.GameAction.moveTo(hand, card);
+
+
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner());
+
+ if(AllZone.GameAction.isCardInPlay(c))
+ {
+ AllZone.getZone(c).remove(c);
+
+ if(! c.isToken())
+ {
+ Card newCard = AllZone.CardFactory.getCard(c.getName(), c.getOwner());
+ hand.add(newCard);
+ }
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -7855081477395863590L;
+
+ public void execute()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+
+ CardList creatures = new CardList(play.getCards());
+ creatures = creatures.getType("Creature");
+
+ CardList blackBlue = new CardList();
+
+
+ for(int i=0;i 0 && life >= 4)
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void computerResolve()
+ {
+ //TODO: somehow select a good non-creature card for AI
+ CardList creature = new CardList(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ if(creature.size() != 0)
+ {
+ Card c = CardFactoryUtil.AI_getBestCreature(creature);
+
+ if(c == null)
+ {
+ creature.shuffle();
+ c = creature.get(0);
+ }
+
+ AllZone.GameAction.shuffle(card.getController());
+
+ //move to top of library
+ AllZone.Computer_Library.remove(c);
+ AllZone.Computer_Library.add(c, 0);
+
+ //lose 2 life
+ String player = Constant.Player.Computer;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.subtractLife(2);
+ }
+ }//computerResolve()
+ public void humanResolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+
+ CardList list = new CardList(library.getCards());
+
+ if(list.size() != 0)
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select a card", list.toArray());
+
+ AllZone.GameAction.shuffle(card.getController());
+ if(o != null)
+ {
+ //put card on top of library
+ library.remove(o);
+ library.add((Card)o, 0);
+ }
+ //lose 2 life
+ String player = Constant.Player.Human;
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.subtractLife(2);
+ }//if
+
+
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Nemata, Grove Guardian"))
+ {
+ final SpellAbility a1 = new Ability(card, "2 G")
+ {
+ public boolean canPlayAI()
+ {
+ return MyRandom.random.nextBoolean();
+ }
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ //this is a hack, check the stack to see if this card has an ability on the stack
+ //if so, we can't use the ability
+ for (int i=0; i 0)
+ return true;
+ else
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Aven Cloudchaser") || cardName.equals("Cloudchaser Eagle") || cardName.equals("Monk Realist"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ {
+ if(c.isToken())
+ AllZone.getZone(c).remove(c);
+
+ else
+ AllZone.GameAction.destroy(c);
+ }
+ }
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 8586704292133752803L;
+
+ public void execute()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.getType("Enchantment");
+
+
+ if (all.size() != 0) {
+
+ if(card.getController().equals(Constant.Player.Human)) {
+ AllZone.InputControl.setInput(CardFactoryUtil.input_targetSpecific(ability, all, "Select target enchantment.", true));
+ ButtonUtil.disableAll();
+ }
+ else if (card.getController().equals(Constant.Player.Computer)) {
+ Card human = CardFactoryUtil.AI_getBestEnchantment(all, card, true);
+ ability.setTargetCard(human);
+ AllZone.Stack.add(ability);
+ }
+ }
+
+ }//execute()
+ };//Command
+ card.addComesIntoPlayCommand(intoPlay);
+
+ card.clearSpellAbility();
+
+ card.addSpellAbility(new Spell_Permanent(card)
+ {
+ private static final long serialVersionUID = -8467111038318551304L;
+
+ public boolean canPlayAI()
+ {
+ CardList ench = new CardList();
+ ench.addAll(AllZone.Human_Play.getCards());
+ ench = ench.getType("Enchantment");
+
+ if (ench.size() > 0)
+ return true;
+ else
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Intuition"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 8282597086298330698L;
+
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ CardList libraryList = new CardList(AllZone.Human_Library.getCards());
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList selectedCards = new CardList();
+
+ Object o = AllZone.Display.getChoiceOptional("Select first card", libraryList.toArray());
+ if(o != null)
+ {
+ Card c1 = (Card)o;
+ libraryList.remove(c1);
+ selectedCards.add(c1);
+ }
+ else {
+ return;
+ }
+ o = AllZone.Display.getChoiceOptional("Select second card", libraryList.toArray());
+ if(o != null)
+ {
+ Card c2 = (Card)o;
+ libraryList.remove(c2);
+ selectedCards.add(c2);
+ }
+ else {
+ return;
+ }
+ o = AllZone.Display.getChoiceOptional("Select third card", libraryList.toArray());
+ if(o != null)
+ {
+ Card c3 = (Card)o;
+ libraryList.remove(c3);
+ selectedCards.add(c3);
+ }
+ else {
+ return;
+ }
+
+ Card choice = selectedCards.get(MyRandom.random.nextInt(2)); //comp randomly selects one of the three cards
+
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
+ library.remove(choice);
+ hand.add(choice);
+
+ selectedCards.remove(choice);
+ Card toGrave1 = selectedCards.get(0);
+ Card toGrave2 = selectedCards.get(1);
+ library.remove(toGrave1);
+ library.remove(toGrave2);
+ selectedCards.remove(toGrave2);
+ selectedCards.remove(toGrave2);
+
+ grave.add(toGrave1);
+ grave.add(toGrave2);
+
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+ }
+ public void computerResolve()
+ {
+ Card[] library = AllZone.Computer_Library.getCards();
+ CardList list = new CardList(library);
+ CardList selectedCards = new CardList();
+
+ //pick best creature
+ Card c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null) {
+ c = library[0];
+ }
+ list.remove(c);
+ selectedCards.add(c);
+
+ c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null) {
+ c = library[0];
+ }
+ list.remove(c);
+ selectedCards.add(c);
+
+ c = CardFactoryUtil.AI_getBestCreature(list);
+ if(c == null) {
+ c = library[0];
+ }
+ list.remove(c);
+ selectedCards.add(c);
+
+ Object o = AllZone.Display.getChoiceOptional("Select card to give to computer", selectedCards.toArray());
+
+ Card choice = (Card)o;
+
+ selectedCards.remove(choice);
+ AllZone.Computer_Library.remove(choice);
+ AllZone.Computer_Hand.add(choice);
+
+ AllZone.Computer_Library.remove(selectedCards.get(0));
+ AllZone.Computer_Library.remove(selectedCards.get(1));
+
+ AllZone.Computer_Graveyard.add(selectedCards.get(0));
+ AllZone.Computer_Graveyard.add(selectedCards.get(1));
+
+ }
+ public boolean canPlay()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ return library.getCards().length >= 3;
+ }
+ public boolean canPlayAI()
+ {
+ CardList creature = new CardList();
+ creature.addAll(AllZone.Computer_Library.getCards());
+ creature = creature.getType("Creature");
+ return creature.size() != 0;
+ }
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Rakka Mar"))
+ {
+ final SpellAbility a1 = new Ability_Tap(card, "R")
+ {
+ private static final long serialVersionUID = -3868544882464692305L;
+
+ public boolean canPlayAI()
+ {
+ return true;
+
+ }
+ public void resolve()
+ {
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Elemental");
+ c.setImageName("R 3 1 Elemental");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elemental");
+ c.setBaseAttack(3);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Haste");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ };//SpellAbility
+ card.addSpellAbility(a1);
+ a1.setDescription("R, T: Put a 3/1 red Elemental creature token with haste into play.");
+ a1.setStackDescription("Put a 3/1 red Elemental creature token with haste into play.");
+
+ a1.setBeforePayMana(new Input_PayManaCost(a1));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Tolsimir Wolfblood"))
+ {
+ final SpellAbility a1 = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -1900858280382389010L;
+
+ public boolean canPlayAI()
+ {
+ String controller = card.getController();
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+ CardList voja = new CardList(play.getCards());
+ voja = voja.getName("Voja");
+
+ if (voja.size() == 0)
+ return true;
+ else
+ return false;
+
+ }
+ public void resolve()
+ {
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+
+ c.setName("Voja");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("W G");
+ c.setToken(true);
+
+ c.addType("Legendary");
+ c.addType("Creature");
+ c.addType("Wolf");
+ c.setBaseAttack(2);
+ c.setBaseDefense(2);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ };//SpellAbility
+ card.addSpellAbility(a1);
+ a1.setDescription("T: Put a legendary 2/2 green and white Wolf creature token named Voja into play.");
+ a1.setStackDescription("Put a 2/2 white green Legendary Wolf creature token named Voja into play.");
+
+ a1.setBeforePayMana(new Input_PayManaCost(a1));
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Invincible Hymn"))
+ {
+ final String player = card.getController();
+
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -827136493013927725L;
+
+ public void resolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList libCards = new CardList(library.getCards());
+ int lifeGain = libCards.size();
+
+ System.out.println("lifeGain: " + lifeGain);
+
+ PlayerLife life = AllZone.GameAction.getPlayerLife(player);
+ life.setLife(lifeGain);
+
+ System.out.println("life.getLife(): " + life.getLife());
+ }
+ public boolean canPlayAI()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ CardList libCards = new CardList(library.getCards());
+ int lifeGain = libCards.size();
+
+ PlayerLife compLife = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
+ if (lifeGain > compLife.getLife())
+ return true;
+ else
+ return false;
+ }
+ };//spell
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Ranger of Eos"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+
+ CardList cards = new CardList(lib.getCards());
+ CardList oneCostCreatures = new CardList();
+
+ for (int i=0;i= 1)
+ {
+ Card c1 = oneCostCreatures.getCard(0);
+ lib.remove(c1);
+ hand.add(c1);
+ oneCostCreatures.remove(c1);
+
+ if (oneCostCreatures.size() >= 1)
+ {
+ Card c2 = oneCostCreatures.getCard(0);
+ lib.remove(c2);
+ hand.add(c2);
+ oneCostCreatures.remove(c2);
+
+ }
+
+
+ }
+ //ability.setTargetCard(powerTwoCreatures.get(0));
+ //AllZone.Stack.add(ability);
+ AllZone.GameAction.shuffle(controller);
+ }
+
+
+ //...
+
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = -5697680711324878027L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Ranger of Eos - Grab 2 creatures");
+ AllZone.Stack.add(ability);
+ }//execute()
+ };//Command
+ //ability.setStackDescription("Ranger of Eos - Grab 2 creatures");
+ //AllZone.Stack.add(ability);
+ card.addComesIntoPlayCommand(intoPlay);
+
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Scarblade Elite"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 3505019464802566898L;
+
+ public boolean canPlay()
+ {
+ String controller = card.getController();
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard ,controller);
+
+ CardList sins = new CardList(graveyard.getCards());
+ sins = sins.getType("Assassin");
+
+ if (sins.size() > 0 && AllZone.GameAction.isCardInPlay(card) && CardFactoryUtil.canTarget(card, getTargetCard()) )
+ return true;
+ else
+ return false;
+
+ }
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {return AllZone.GameAction.isCardInPlay(c);}
+ });
+
+ CardListUtil.sortAttack(human);
+ CardListUtil.sortFlying(human);
+
+ //if(0 < human.size())
+ // setTargetCard(human.get(0));
+
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Computer);
+
+ CardList grave = new CardList(graveyard.getCards());
+ grave = grave.getType("Assassin");
+
+ if (human.size() > 0 && grave.size() > 0)
+ setTargetCard(human.get(0));
+
+ return 0 < human.size() && 0 < grave.size();
+ }
+
+ public void resolve()
+ {
+ String controller = card.getController();
+ PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard ,controller);
+
+ CardList sins = new CardList(graveyard.getCards());
+ sins = sins.getType("Assassin");
+
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ Object o = AllZone.Display.getChoiceOptional("Pick an Assassin to remove", sins.toArray());
+
+ if(o != null)
+ {
+ Card crd = (Card)o;
+ graveyard.remove(crd);
+
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ } //if o!= null
+ }//player.equals("human")
+ else
+ {
+ Card crd = sins.get(0);
+ graveyard.remove(crd);
+
+ Card c = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ {
+ AllZone.GameAction.destroy(c);
+ }
+ }
+ }//resolve()
+ };//SpellAbility
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -4853162388286494888L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature to destroy");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if(!CardFactoryUtil.canTarget(ability, card)){
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ if(c.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ //tap ability
+ card.tap();
+
+ ability.setTargetCard(c);
+ AllZone.Stack.add(ability);
+ stop();
+ }
+ }//selectCard()
+ };//Input
+
+ card.addSpellAbility(ability);
+ ability.setDescription("tap: Remove an Assassin card in your graveyard from the game: Destroy target creature.");
+ ability.setBeforePayMana(target);
+
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Broodmate Dragon"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public void resolve()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Dragon");
+ c.setImageName("R 4 4 Dragon");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Dragon");
+
+ c.addIntrinsicKeyword("Flying");
+
+ c.setBaseAttack(4);
+ c.setBaseDefense(4);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ }//resolve()
+ };
+ Command intoPlay = new Command()
+ {
+ private static final long serialVersionUID = 2848700532090223394L;
+
+ public void execute()
+ {
+ ability.setStackDescription("Broodmate Dragon - put a 4/4 red Dragon creature token into play.");
+ AllZone.Stack.add(ability);
+ }
+ };
+ card.addComesIntoPlayCommand(intoPlay);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Gift of Estates"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4997834790204261916L;
+
+ public boolean canPlay()
+ {
+ String oppPlayer = AllZone.GameAction.getOpponent(card.getController());
+
+ PlayerZone selfZone = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone oppZone = AllZone.getZone(Constant.Zone.Play, oppPlayer);
+
+ CardList self = new CardList(selfZone.getCards());
+ CardList opp = new CardList(oppZone.getCards());
+
+ self = self.getType("Land");
+ opp = opp.getType("Land");
+
+ return (self.size() < opp.size()) && super.canPlay();
+ }//canPlay()
+
+ public void resolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ CardList plains = new CardList(library.getCards());
+ plains = plains.getType("Plains");
+
+ for(int i = 0; i < 3 && i < plains.size(); i++)
+ AllZone.GameAction.moveTo(hand, plains.get(i));
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Tithe"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 1504792204526793942L;
+
+ public boolean oppMoreLand()
+ {
+ String oppPlayer = AllZone.GameAction.getOpponent(card.getController());
+
+ PlayerZone selfZone = AllZone.getZone(Constant.Zone.Play, card.getController());
+ PlayerZone oppZone = AllZone.getZone(Constant.Zone.Play, oppPlayer);
+
+ CardList self = new CardList(selfZone.getCards());
+ CardList opp = new CardList(oppZone.getCards());
+
+ self = self.getType("Land");
+ opp = opp.getType("Land");
+
+ return (self.size() < opp.size()) && super.canPlay();
+ }//oppoMoreLand()
+
+ public void resolve()
+ {
+ PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+
+ CardList plains = new CardList(library.getCards());
+ plains = plains.getType("Plains");
+
+ if(0 < plains.size())
+ AllZone.GameAction.moveTo(hand, plains.get(0));
+
+ if(oppMoreLand() && 1 < plains.size())
+ AllZone.GameAction.moveTo(hand, plains.get(1));
+
+ }//resolve()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Survival of the Fittest"))
+ {
+ SpellAbility ability = new Ability(card, "G")
+ {
+ public void resolve()
+ {
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }//resolve()
+ public void humanResolve()
+ {
+ CardList handCreatures = new CardList(AllZone.Human_Hand.getCards());
+ handCreatures = handCreatures.getType("Creature");
+
+ if (handCreatures.size() == 0)
+ return;
+
+ Object discard = AllZone.Display.getChoiceOptional("Select Creature to discard", handCreatures.toArray());
+ if (discard != null){
+
+ CardList creatures = new CardList(AllZone.Human_Library.getCards());
+ creatures = creatures.getType("Creature");
+
+ if (creatures.size() != 0) {
+ Object check = AllZone.Display.getChoiceOptional("Select Creature", creatures.toArray());
+ if(check != null)
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
+ AllZone.GameAction.moveTo(hand, (Card)check);
+ }
+ AllZone.GameAction.shuffle(Constant.Player.Human);
+ }
+ AllZone.GameAction.discard((Card)discard);
+ }
+ }
+ public void computerResolve()
+ {
+ //TODO
+ }
+
+
+ };//SpellAbility
+
+ //card.clearSpellAbility();
+ ability.setDescription("G: Discard a creature card: Search your library for a creature card, reveal that card, and put it into your hand. Then shuffle your library.");
+ //ability.setBeforePayMana(new Input_NoCost_TapAbility((Ability) ability));
+ //ability.setBeforePayMana(new Input_PayManaCost(ability));
+ ability.setStackDescription("Survival of the Fittest - search for a creature card and put into hand");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Gerrard's Command"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 3128602006949603902L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -650846106294962607L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-3);
+ target[0].addTempDefenseBoost(-3);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(3);
+ target[0].addTempDefenseBoost(3);
+ target[0].untap();
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+//*************** START *********** START **************************
+ if(cardName.equals("Brute Force"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4733538427752827505L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ //Card[] att = c.getAttackers();
+
+ CardList list = new CardList();
+ list.addAll(c.getAttackers());
+ list = list.filter(new CardListFilter()
+ {
+
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(card, c);
+ }
+
+ });
+
+ if(list.size() != 0)
+ return list.get(0);
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 8299648917436556370L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-3);
+ target[0].addTempDefenseBoost(-3);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]) )
+ {
+ target[0].addTempAttackBoost(3);
+ target[0].addTempDefenseBoost(3);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Nameless Inversion"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 5479536291205544905L;
+
+ public boolean canPlayAI()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(3, card, true);
+ CardListUtil.sortFlying(list);
+
+ for(int i = 0; i < list.size(); i++)
+ if(2 <= list.get(i).getNetAttack())
+ {
+ setTargetCard(list.get(i));
+ return true;
+ }
+ return false;
+ }//canPlayAI()
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -1954104042512587145L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-3);
+ target[0].addTempDefenseBoost(3);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(3);
+ target[0].addTempDefenseBoost(-3);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tromp the Domains"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 1523193367625798058L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+
+ int countLandTypes()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList land = new CardList(play.getCards());
+
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+ int count = 0;
+
+ for(int i = 0; i < basic.length; i++)
+ {
+ CardList c = land.getType(basic[i]);
+ if(! c.isEmpty())
+ count++;
+ }
+
+ return count;
+ }//countLandTypes()
+ public void resolve()
+ {
+
+ final int boost = countLandTypes();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(play.getCards());
+ @SuppressWarnings("unused") // c
+ Card c;
+
+ 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 = -4207130279969069542L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-boost);
+ target[0].addTempDefenseBoost(-boost);
+
+ target[0].removeExtrinsicKeyword("Trample");
+ }
+ }
+ };//Command
+
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(boost);
+ target[0].addTempDefenseBoost(boost);
+
+ target[0].addExtrinsicKeyword("Trample");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//if
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Titanic Ultimatum"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4920407567000133514L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ CardList list = new CardList(play.getCards());
+ @SuppressWarnings("unused") // c
+ Card c;
+
+ 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 = -3807842003906681893L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-5);
+ target[0].addTempDefenseBoost(-5);
+
+ target[0].removeExtrinsicKeyword("Trample");
+ target[0].removeExtrinsicKeyword("First Strike");
+ target[0].removeExtrinsicKeyword("Lifelink");
+ }
+ }
+ };//Command
+
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(5);
+ target[0].addTempDefenseBoost(5);
+
+ target[0].addExtrinsicKeyword("Trample");
+ target[0].addExtrinsicKeyword("First Strike");
+ target[0].addExtrinsicKeyword("Lifelink");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }//if
+ }//for
+ }//resolve()
+ };
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Primal Boost"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 2449600319884238808L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+
+ CardList list = new CardList(c.getAttackers());
+ CardListUtil.sortFlying(list);
+
+ Card[] att = list.toArray();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 3753684523153747308L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-4);
+ target[0].addTempDefenseBoost(-4);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(4);
+ target[0].addTempDefenseBoost(4);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setDescription("Target creature gets +4/+4 until end of turn.");
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, "2 G"));
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wildsize"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4558777579924787035L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+
+ CardList list = new CardList(c.getAttackers());
+ CardListUtil.sortFlying(list);
+
+ Card[] att = list.toArray();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -8390763209393328399L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-2);
+ target[0].addTempDefenseBoost(-2);
+
+ target[0].removeExtrinsicKeyword("Trample");
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(2);
+ target[0].addTempDefenseBoost(2);
+ target[0].addExtrinsicKeyword("Trample");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Feral Lightning"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1841642966580694848L;
+
+ public boolean canPlayAI()
+ {
+ return AllZone.Phase.getPhase().equals(Constant.Phase.Main1);
+ }
+
+
+ public void resolve()
+ {
+ final Card[] token = new Card[3];
+ final Command atEOT = new Command()
+ {
+ private static final long serialVersionUID = -1928884889370422828L;
+
+ public void execute()
+ {
+ //destroy tokens at end of turn
+ for(int i = 0; i < token.length; i++)
+ if(AllZone.GameAction.isCardInPlay(token[i]))
+ AllZone.GameAction.destroy(token[i]);
+ }
+ };
+ AllZone.EndOfTurn.addAt(atEOT);
+
+ for(int i = 0; i < token.length; i++)
+ token[i] = makeToken();
+ }//resolve()
+ Card makeToken()
+ {
+ Card c = new Card();
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setName("Elemental");
+ c.setImageName("R 3 1 Elemental");
+ c.setManaCost("R");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Elemental");
+ c.setBaseAttack(3);
+ c.setBaseDefense(1);
+ c.addIntrinsicKeyword("Haste");
+ c.setSacrificeAtEOT(true);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+
+ return c;
+ }//makeToken()
+ };//SpellAbility
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Inspirit"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -601100008975177639L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -3197321199337917886L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-2);
+ target[0].addTempDefenseBoost(-4);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(2);
+ target[0].addTempDefenseBoost(4);
+
+ target[0].untap();
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Might of Oaks"))
+ {
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -33985340162641452L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -5138969487216215323L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-7);
+ target[0].addTempDefenseBoost(-7);
+ }
+ }
+ };
+
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ target[0].addTempAttackBoost(7);
+ target[0].addTempDefenseBoost(7);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Guided Strike"))
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 6381010042083054770L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(-1);
+ target[0].removeExtrinsicKeyword("First Strike");
+ }
+ }
+ };
+
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6373328936243472966L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(1);
+ target[0].addExtrinsicKeyword("First Strike");
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Aggressive Urge"))
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = 5519847437187468154L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].addTempAttackBoost(-1);
+ target[0].addTempDefenseBoost(-1);
+ }
+ }
+ };
+
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -1043326570050661433L;
+
+ public boolean canPlayAI()
+ {
+ return getAttacker() != null;
+ }
+ public void chooseTargetAI()
+ {
+ setTargetCard(getAttacker());
+ }
+ public Card getAttacker()
+ {
+ //target creature that is going to attack
+ Combat c = ComputerUtil.getAttackers();
+ Card[] att = c.getAttackers();
+ if(att.length != 0)
+ return att[0];
+ else
+ return null;
+ }//getAttacker()
+ public void resolve()
+ {
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addTempAttackBoost(1);
+ target[0].addTempDefenseBoost(1);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ AllZone.GameAction.drawCard(card.getController());
+ }
+ }//resolve()
+ };
+ spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Vindicate"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -2302610807061478203L;
+
+ public boolean canPlayAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return 4 < AllZone.Phase.getTurn() && 0 < human.size();
+ }
+ public void chooseTargetAI()
+ {
+ CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
+ setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
+ }
+
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ if(getTargetCard().isToken())
+ AllZone.getZone(getTargetCard()).remove(getTargetCard());
+ else
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }
+ }//if
+ }//resolve()
+ };//SpellAbility
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7826307781920832218L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target permanent for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };//Input
+
+ spell.setBeforePayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Shatter"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -8518902112426882210L;
+
+ public boolean canPlayAI()
+ {
+ return (getArtifact().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ if(getArtifact().size() != 0){
+ Card bestArtifact = CardFactoryUtil.AI_getBestArtifact(getArtifact());
+ setTargetCard(bestArtifact);
+ }
+ }//getEnchantment()
+ CardList getArtifact()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanArtifact(card, true);
+ return list;
+ }//getArtifact()
+ public void resolve()
+ {
+ AllZone.GameAction.destroy(getTargetCard());
+ }//resolve()
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 7950082427462078698L;
+
+ public void showMessage()
+ {
+ //Display all artifacts in play
+ //Allow human player to select which one to destroy
+ CardList allCards = new CardList();
+ allCards.addAll(AllZone.Human_Play.getCards());
+ allCards.addAll(AllZone.Computer_Play.getCards());
+
+ //get artifacts
+ CardList allArtifacts = allCards.getType("Artifact");
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, allArtifacts, "Select target Artifact to destroy.",true));
+
+ }
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(runtime);
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ else if(cardName.equals("Disenchant") || cardName.equals("Naturalize"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 6231507037766815249L;
+
+ public boolean canPlayAI()
+ {
+ return (getEnchantment().size() != 0 || getArtifact().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ if(getEnchantment().size() != 0)
+ {
+ Card bestEnchantment = CardFactoryUtil.AI_getBestEnchantment(getEnchantment(), card, true);
+ if(getArtifact().size() != 0){
+ Card bestArtifact = CardFactoryUtil.AI_getBestArtifact(getArtifact());
+ if(CardUtil.getConvertedManaCost(bestArtifact.getManaCost()) > CardUtil.getConvertedManaCost(bestEnchantment.getManaCost())){
+ setTargetCard(bestArtifact);
+ }
+ else{
+ setTargetCard(bestEnchantment);
+ }
+ }
+ else{
+ setTargetCard(bestEnchantment);
+ }
+ }
+ else if(getArtifact().size() != 0){
+ Card bestArtifact = CardFactoryUtil.AI_getBestArtifact(getArtifact());
+ setTargetCard(bestArtifact);
+ }
+
+ }
+ CardList getEnchantment()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanEnchantment(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return !c.getKeyword().contains("Indestructible");
+ }
+ });
+ return list;
+ }//getEnchantment()
+ CardList getArtifact()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanArtifact(card, true);
+ list = list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return !c.getKeyword().contains("Indestructible");
+ }
+ });
+ return list;
+ }//getArtifact()
+ public void resolve()
+ {
+ //AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ AllZone.GameAction.destroy(getTargetCard());
+
+ }//resolve()
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -1212213052029735882L;
+
+ public void showMessage()
+ {
+ //Display all artifacts and enchantments in play
+ //Allow human player to select which one to destroy
+ CardList allCards = new CardList();
+ allCards.addAll(AllZone.Human_Play.getCards());
+ allCards.addAll(AllZone.Computer_Play.getCards());
+
+ //get enchantments and get artifacts
+ CardList allEnchantments = allCards.getType("Enchantment");
+ CardList allArtifacts = allCards.getType("Artifact");
+
+ //put enchantments and artifacts in same cardList to display
+ CardList allEnchantmentsAndArtifacts = allEnchantments;
+ allEnchantmentsAndArtifacts.addAll(allArtifacts.toArray());
+
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, allEnchantmentsAndArtifacts, "Select target Enchantment or Artifact to destroy.", true));
+ }
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(runtime);
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Demystify"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = -4045818747862804365L;
+
+ public boolean canPlayAI()
+ {
+ return (getEnchantment().size() != 0) && (AllZone.Phase.getTurn() > 4);
+ }
+ public void chooseTargetAI()
+ {
+ Card best = CardFactoryUtil.AI_getBestEnchantment(getEnchantment(), card, true);
+ setTargetCard(best);
+ }
+ CardList getEnchantment()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanEnchantment(card, true);
+ return list;
+ }//getCreature()
+ public void resolve()
+ {
+ AllZone.GameAction.destroyNoRegeneration(getTargetCard());
+ }//resolve()
+ };
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 746063168471322007L;
+
+ public void showMessage()
+ {
+ CardList choice = new CardList();
+ choice.addAll(AllZone.Human_Play.getCards());
+ choice.addAll(AllZone.Computer_Play.getCards());
+
+ choice = choice.getType("Enchantment");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, choice, "Select target Enchantment to destroy.",true));
+ }
+ };
+
+ card.clearSpellAbility();
+ spell.setBeforePayMana(runtime);
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Animate Land"))
+ {
+ final Card[] target = new Card[1];
+ final Command untilEOT = new Command()
+ {
+ private static final long serialVersionUID = -3359299797188942353L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(target[0]))
+ {
+ target[0].removeType("Creature");
+ }
+ }
+ };
+
+ SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 4890851927124377327L;
+
+ public void resolve()
+ {
+ target[0] = getTargetCard();
+ if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
+ {
+ target[0].addType("Creature");
+ target[0].setBaseAttack(3);
+ target[0].setBaseDefense(3);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }//resolve()
+ public boolean canPlayAI()
+ {
+ return false;
+/* all this doesnt work, computer will not attack with the animated land
+
+//does the computer have any land in play?
+CardList land = new CardList(AllZone.Computer_Play.getCards());
+land = land.getType("Land");
+land = land.filter(new CardListFilter()
+{
+ public boolean addCard(Card c)
+ {
+ //checks for summoning sickness, and is not tapped
+ return CombatUtil.canAttack(c);
+ }
+});
+return land.size() > 1 && CardFactoryUtil.AI_isMainPhase();
+*/
+ }
+ };//SpellAbility
+// spell.setChooseTargetAI(CardFactoryUtil.AI_targetType("Land", AllZone.Computer_Play));
+
+ spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "Land"));
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Aven Riftwatcher"))
+ {
+ Command gain2Life = new Command()
+ {
+ private static final long serialVersionUID = 5588978023269625349L;
+
+ public boolean firstTime = true;
+ public void execute()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.addLife(2);
+
+ //testAndSet - only needed when comes into play.
+ if(firstTime){
+ card.setCounter(Counters.AGE, 3); //vanishing
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addLeavesPlayCommand(gain2Life);
+ card.addComesIntoPlayCommand(gain2Life);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Calciderm"))
+ {
+ Command ageCounters = new Command()
+ {
+ private static final long serialVersionUID = 431920157968451817L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ //testAndSet - only needed when comes into play.
+ if(firstTime){
+ card.setCounter(Counters.AGE, 4);
+ }
+ firstTime = false;
+ }
+ };
+ card.addComesIntoPlayCommand(ageCounters);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Blastoderm"))
+ {
+ Command fadeCounters = new Command()
+ {
+ private static final long serialVersionUID = -580691660706977218L;
+ public boolean firstTime = true;
+ public void execute()
+ {
+
+ //testAndSet - only needed when comes into play.
+ if(firstTime){
+ card.setCounter(Counters.FADE, 3);
+ }
+ firstTime = false;
+ }
+ };
+
+ card.addComesIntoPlayCommand(fadeCounters);
+
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Godsire"))
+ {
+ final SpellAbility a1 = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -1160527561099142816L;
+
+ public void resolve()
+ {
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+
+ c.setName("Beast");
+ c.setImageName("RGW 8 8 Beast");
+
+ c.setOwner(card.getController());
+ c.setController(card.getController());
+
+ c.setManaCost("R G W");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Beast");
+ c.setBaseAttack(8);
+ c.setBaseDefense(8);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+
+ public boolean canPlayAI()
+ {
+ return AllZone.Phase.getPhase().equals("Main2");
+ }
+
+ };//SpellAbility
+ card.addSpellAbility(a1);
+ a1.setDescription("T: Put an 8/8 Beast creature token into play that's red, green, and white.");
+ a1.setStackDescription("Put an 8/8 Beast creature token into play that's red, green, and white.");
+
+ //a1.setBeforePayMana(new Input_PayManaCost(a1));
+ }//*************** END ************ END **************************
+
+ if (cardName.equals("Ior Ruin Expedition"))
+ {
+ final SpellAbility ability = new Ability(card, "0")
+ {
+ public boolean canPlay()
+ {
+ return card.getCounters(Counters.QUEST) >= 3 && AllZone.GameAction.isCardInPlay(card)&&!AllZone.Stack.getSourceCards().contains(card);//in play and not already activated(Sac cost problems)
+ }
+ public boolean canPlayAI() {return (AllZone.Computer_Hand.size() < 6)&&(AllZone.Computer_Library.size()>0);}
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.drawCard(card.getController());
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }
+ };
+ ability.setDescription("Remove three quest counters from Ior Ruin Expedition and sacrifice it: Draw two cards.");
+ ability.setStackDescription(card.getName() +" - Draw two cards.");
+
+ card.addSpellAbility(ability);
+ }
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Wydwen, the Biting Gale"))
+ {
+ final SpellAbility a1 = new Ability(card,"U B")
+ {
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ public void resolve()
+ {
+ PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
+ life.subtractLife(1);
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getOwner());
+ /*
+ AllZone.getZone(card).remove(card);
+ hand.add(card);
+ */
+ if (card.isToken())
+ AllZone.getZone(card).remove(card);
+ else
+ AllZone.GameAction.moveTo(hand, card);
+
+
+ }
+ };//a1
+
+ //card.clearSpellAbility();
+ card.addSpellAbility(a1);
+ a1.setStackDescription(card.getController() + " pays 1 life and returns Wydwen back to owner's hand.");
+ a1.setDescription("U B, Pay 1 life: Return Wydwen, the Biting Gale to its owner's hand.");
+
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Earthcraft"))
+ {
+ final SpellAbility a1 = new Ability(card,"0")
+ {
+ private static final long serialVersionUID = 6787319311700905218L;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public boolean canPlay()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped();
+ }
+ });
+
+ if (creats.size() > 0 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+
+ if (getTargetCard()== null)
+ return;
+
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ //else
+ // computerResolve();
+ }
+ public void humanResolve()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped() && !c.equals(card);
+ }
+ });
+
+ if (creats.size() == 1) {
+ creats.get(0).tap();
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ getTargetCard().untap();
+
+ }
+ else if (creats.size() > 1) {
+ Object o = AllZone.Display.getChoice("Select creature to tap", creats.toArray());
+
+ if (o!= null)
+ {
+ Card c1 = (Card)o;
+ c1.tap();
+ if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ getTargetCard().untap();
+ }
+ }
+
+
+
+ }//humanResolve
+
+ };//a1
+
+ //card.clearSpellAbility();
+ card.addSpellAbility(a1);
+ a1.setDescription("Tap an untapped creature you control: untap target basic land.");
+
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = -2287693175821059029L;
+
+ public void showMessage()
+ {
+ CardList all = new CardList();
+ all.addAll(AllZone.Human_Play.getCards());
+ all.addAll(AllZone.Computer_Play.getCards());
+ all = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return (c.isBasicLand()) && CardFactoryUtil.canTarget(card, c) && c.isTapped();
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a1, all, "Select target basic land", true));
+ }
+ };
+ a1.setBeforePayMana(runtime);
+
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Tradewind Rider"))
+ {
+ final SpellAbility a1 = new Ability_Tap(card,"0")
+ {
+ private static final long serialVersionUID = 3438865371487994984L;
+
+ public void chooseTargetAI()
+ {
+ if(getCreature().size() != 0)
+ {
+ Card bestCreature = CardFactoryUtil.AI_getBestCreature(getCreature());
+ if(getEnchantment().size() != 0){
+ Card bestEnchantment = CardFactoryUtil.AI_getBestEnchantment(getEnchantment(), card, true);
+ if(CardUtil.getConvertedManaCost(bestCreature.getManaCost()) > CardUtil.getConvertedManaCost(bestEnchantment.getManaCost())){
+ setTargetCard(bestCreature);
+ }
+ else{
+ setTargetCard(bestEnchantment);
+ }
+ }
+ else{
+ setTargetCard(bestCreature);
+ }
+ }
+ else if(getArtifact().size() != 0){
+ Card bestArtifact = CardFactoryUtil.AI_getBestArtifact(getArtifact());
+ setTargetCard(bestArtifact);
+ }
+
+ }//ChooseTargetAI()
+ CardList getCreature()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
+ return list;
+ }//getEnchantment()
+ CardList getArtifact()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanArtifact(card, true);
+ return list;
+ }//getArtifact()
+ CardList getEnchantment()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanEnchantment(card, true);
+ return list;
+ }
+
+
+
+ public boolean canPlayAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList cards = new CardList();
+
+ cards.addAll(play.getCards());
+ cards = cards.filter(new CardListFilter(){
+
+ public boolean addCard(Card c) {
+ return (c.isArtifact() || c.isEnchantment() || c.isCreature() ) && CardFactoryUtil.canTarget(card, c);
+ }
+
+ });
+
+ return cards.size() > 0;
+
+ }
+ public boolean canPlay()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped() && !c.equals(card);
+ }
+ });
+
+ if (creats.size() > 1 && AllZone.GameAction.isCardInPlay(card) && card.isUntapped() && !card.hasSickness())
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+
+ if (getTargetCard()== null)
+ return;
+
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped() && !c.equals(card);
+ }
+ });
+
+ CardList tappedCreats = new CardList();
+
+ Object o = AllZone.Display.getChoice("Pick first creature to tap", creats.toArray());
+
+ if (o!= null)
+ {
+ Card c1 = (Card)o;
+ creats.remove(c1);
+ tappedCreats.add(c1);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick second creature to tap", creats.toArray());
+ if (o!= null)
+ {
+ Card c2 = (Card)o;
+ creats.remove(c2);
+ tappedCreats.add(c2);
+ }
+ else
+ return;
+
+ for(int i = 0; i CardUtil.getConvertedManaCost(bestEnchantment.getManaCost())){
+ setTargetCard(bestArtifact);
+ }
+ else{
+ setTargetCard(bestEnchantment);
+ }
+ }
+ else{
+ setTargetCard(bestEnchantment);
+ }
+ }
+ else if(getArtifact().size() != 0){
+ Card bestArtifact = CardFactoryUtil.AI_getBestArtifact(getArtifact());
+ setTargetCard(bestArtifact);
+ }
+
+ }
+ CardList getEnchantment()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanEnchantment(card, true);
+ return list;
+ }//getEnchantment()
+ CardList getArtifact()
+ {
+ CardList list = CardFactoryUtil.AI_getHumanArtifact(card, true);
+ return list;
+ }//getArtifact()
+
+
+ public boolean canPlayAI()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList cards = new CardList();
+
+ cards.addAll(play.getCards());
+ cards = cards.filter(new CardListFilter(){
+
+ public boolean addCard(Card c) {
+ return (c.isArtifact() || c.isEnchantment() ) && CardFactoryUtil.canTarget(card, c);
+ }
+
+ });
+
+ return cards.size() > 0;
+
+ }
+ public boolean canPlay()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped();
+ }
+ });
+
+ if (creats.size() > 3 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+
+ if (getTargetCard()== null)
+ return;
+
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+ CardList creats = new CardList();
+
+ creats.addAll(play.getCards());
+ creats = creats.getType("Creature");
+ creats = creats.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return c.isUntapped();
+ }
+ });
+
+ CardList tappedCreats = new CardList();
+
+ Object o = AllZone.Display.getChoice("Pick first creature to tap", creats.toArray());
+
+ if (o!= null)
+ {
+ Card c1 = (Card)o;
+ creats.remove(c1);
+ tappedCreats.add(c1);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick second creature to tap", creats.toArray());
+ if (o!= null)
+ {
+ Card c2 = (Card)o;
+ creats.remove(c2);
+ tappedCreats.add(c2);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick third creature to tap", creats.toArray());
+ if (o!= null)
+ {
+ Card c3 = (Card) o;
+ creats.remove(c3);
+ tappedCreats.add(c3);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick fourth creature to tap", creats.toArray());
+ if (o!= null)
+ {
+ Card c4 = (Card) o;
+ creats.remove(c4);
+ tappedCreats.add(c4);
+ }
+ else
+ return;
+
+
+ for(int i = 0; i 6 && druidsUntapped > 6 && AllZone.GameAction.isCardInPlay(card))
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+
+ String player = card.getController();
+ if(player.equals(Constant.Player.Human))
+ humanResolve();
+ else
+ computerResolve();
+ }
+ public void humanResolve()
+ {
+ String controller = card.getController();
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, controller);
+ CardList druids = new CardList();
+
+ druids.addAll(play.getCards());
+ druids = druids.getType("Druid");
+
+ CardList tappedDruids = new CardList();
+
+ Object o = AllZone.Display.getChoice("Pick first druid to tap", druids.toArray());
+
+ if (o!= null)
+ {
+ Card c1 = (Card)o;
+ druids.remove(c1);
+ tappedDruids.add(c1);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick second druid to tap", druids.toArray());
+ if (o!= null)
+ {
+ Card c2 = (Card)o;
+ druids.remove(c2);
+ tappedDruids.add(c2);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick third druid to tap", druids.toArray());
+ if (o!= null)
+ {
+ Card c3 = (Card) o;
+ druids.remove(c3);
+ tappedDruids.add(c3);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick fourth druid to tap", druids.toArray());
+ if (o!= null)
+ {
+ Card c4 = (Card) o;
+ druids.remove(c4);
+ tappedDruids.add(c4);
+ }
+ else
+ return;
+ o = AllZone.Display.getChoice("Pick fifth druid to tap", druids.toArray());
+ if (o!= null)
+ {
+ Card c5 = (Card) o;
+ druids.remove(c5);
+ tappedDruids.add(c5);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick sixth druid to tap", druids.toArray());
+ if (o!= null)
+ {
+ Card c6 = (Card) o;
+ druids.remove(c6);
+ tappedDruids.add(c6);
+ }
+ else
+ return;
+
+ o = AllZone.Display.getChoice("Pick seventh druid to tap", druids.toArray());
+ if (o!=null)
+ {
+ Card c7 = (Card) o;
+ druids.remove(c7);
+ tappedDruids.add(c7);
+ }
+ else
+ return;
+
+ for(int i = 0; i humCreats.size())
+ return true;
+ else
+ return false;
+ }
+ });
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Chameleon Colossus"))
+ {
+ final int attack[] = new int[1];
+ final int defense[] = new int[1];
+
+
+ final Command untilEOT = new Command()
+ {
+
+ private static final long serialVersionUID = 861635058350850025L;
+
+ public void execute()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ card.setTempAttackBoost(0);
+ card.setTempDefenseBoost(0);
+ }
+ }
+ };
+
+ SpellAbility ability = new Ability_Activated(card, "2 G G")
+ {
+
+ private static final long serialVersionUID = -4910313985049099384L;
+ public boolean canPlayAI()
+ {
+ return CardFactoryUtil.AI_doesCreatureAttack(card);
+ }
+ public boolean canPlay()
+ {
+ if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) &&
+ !card.isFaceDown())
+ return true;
+ else
+ return false;
+ }
+ public void resolve()
+ {
+ if(AllZone.GameAction.isCardInPlay(card))
+ {
+ attack[0] = card.getNetAttack();
+ defense[0] = attack[0];
+
+ card.addTempAttackBoost(attack[0]);
+ card.addTempDefenseBoost(defense[0]);
+
+ AllZone.EndOfTurn.addUntil(untilEOT);
+ }
+ }
+ };
+
+
+ ability.setDescription("2 G G : Chameleon Colossus gets +X/+X until end of turn, where X is its power." );
+ ability.setStackDescription("Chameleon Colossus gets +X/+X until end of turn, where X is its power.");
+
+ card.addSpellAbility(ability);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Figure of Destiny"))
+ {
+ Ability ability1 = new Ability(card, "RW")
+ {
+ public void resolve()
+ {
+ boolean artifact = false;
+ card.setBaseAttack(2);
+ card.setBaseDefense(2);
+
+ card.removeIntrinsicKeyword("Flying");
+ card.removeIntrinsicKeyword("First Strike");
+
+ if (card.isArtifact())
+ artifact = true;
+
+ card.setType(new ArrayList());
+ if (artifact)
+ card.addType("Artifact");
+ card.addType("Creature");
+ card.addType("Kithkin");
+ card.addType("Spirit");
+ }
+
+ public boolean canPlayAI()
+ {
+ return !card.getType().contains("Spirit");
+ }
+
+ };// ability1
+
+ ability1.setDescription("RW: Figure of Destiny becomes a 2/2 Kithkin Spirit.");
+ ability1.setStackDescription("Figure of Destiny becomes a 2/2 Kithkin Spirit.");
+ card.addSpellAbility(ability1);
+
+
+ Ability ability2 = new Ability(card, "RW RW RW")
+ {
+ public void resolve()
+ {
+ boolean artifact = false;
+ card.setBaseAttack(4);
+ card.setBaseDefense(4);
+
+ card.removeIntrinsicKeyword("Flying");
+ card.removeIntrinsicKeyword("First Strike");
+
+ if (card.isArtifact())
+ artifact = true;
+
+ card.setType(new ArrayList());
+ if (artifact)
+ card.addType("Artifact");
+ card.addType("Creature");
+ card.addType("Kithkin");
+ card.addType("Spirit");
+ card.addType("Warrior");
+ }
+
+ public boolean canPlay()
+ {
+ return card.getType().contains("Spirit");
+ }
+
+ public boolean canPlayAI()
+ {
+ return !card.getType().contains("Warrior");
+ }
+
+ };// ability2
+
+ ability2.setDescription("RW RW RW: If Figure of Destiny is a Spirit, it becomes a 4/4 Kithkin Spirit Warrior.");
+ ability2.setStackDescription("Figure of Destiny becomes a 4/4 Kithkin Spirit Warrior.");
+ card.addSpellAbility(ability2);
+
+
+ Ability ability3 = new Ability(card, "RW RW RW RW RW RW")
+ {
+ public void resolve()
+ {
+ boolean artifact = false;
+ card.setBaseAttack(8);
+ card.setBaseDefense(8);
+
+ card.addIntrinsicKeyword("Flying");
+ card.addIntrinsicKeyword("First Strike");
+
+ if (card.isArtifact())
+ artifact = true;
+
+ card.setType(new ArrayList());
+ if (artifact)
+ card.addType("Artifact");
+ card.addType("Creature");
+ card.addType("Kithkin");
+ card.addType("Spirit");
+ card.addType("Warrior");
+ card.addType("Avatar");
+ }
+ public boolean canPlay()
+ {
+ return card.getType().contains("Warrior");
+ }
+ public boolean canPlayAI()
+ {
+ return !card.getType().contains("Avatar");
+ }
+ };// ability3
+
+ ability3.setDescription("RW RW RW RW RW RW: If Figure of Destiny is a Warrior, it becomes an 8/8 Kithkin Spirit Warrior Avatar with flying and first strike. ");
+ ability3.setStackDescription("Figure of Destiny becomes an 8/8 Kithkin Spirit Warrior Avatar with flying and first strike.");
+ card.addSpellAbility(ability3);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Jenara, Asura of War"))
+ {
+
+ Ability ability2 = new Ability(card, "1 W")
+ {
+ public void resolve()
+ {
+ card.addCounter(Counters.P1P1, 1);
+ }
+ };// ability2
+
+ ability2.setStackDescription(card.getName() + " - gets a +1/+1 counter.");
+ card.addSpellAbility(ability2);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Legacy Weapon"))
+ {
+ final Ability ability = new Ability(card, "W U B R G")
+ {
+ public void resolve()
+ {
+ Card c = getTargetCard();
+
+ if (AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c))
+ {
+ AllZone.GameAction.removeFromGame(c);
+ }
+ }
+
+ public void chooseTargetAI()
+ {
+ PlayerZone hplay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList human = new CardList(hplay.getCards());
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return CardFactoryUtil.canTarget(card, c);
+ }
+ });
+
+ if (human.size() != 0)
+ {
+ setTargetCard(CardFactoryUtil.AI_getMostExpensivePermanent(human, card, true));
+ }
+ }
+
+ public boolean canPlayAI()
+ {
+ PlayerZone hplay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList human = new CardList(hplay.getCards());
+ human = human.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return CardFactoryUtil.canTarget(card, c);
+ }
+ });
+ return human.size() > 0;
+ }
+
+ };//ability
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7279903055386088569L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target permanent for " +ability.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card crd, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play) && CardFactoryUtil.canTarget(card, crd))
+ {
+ ability.setTargetCard(crd);
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ }
+ };//Input
+
+ ability.setBeforePayMana(target);
+ card.addSpellAbility(ability);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Voltaic Key"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card, "1")
+ {
+ private static final long serialVersionUID = 6097818373831898299L;
+ public void resolve()
+ {
+ Card c = getTargetCard();
+ if (AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) && c.isTapped())
+ c.untap();
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };//ability
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -7279903055386088569L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target tapped artifact for " +ability.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card crd, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Play) && CardFactoryUtil.canTarget(card, crd) && crd.isArtifact() && crd.isTapped())
+ {
+ ability.setTargetCard(crd);
+ stopSetNext(new Input_PayManaCost(ability));
+ }
+ }
+ };//Input
+
+ ability.setBeforePayMana(target);
+ card.addSpellAbility(ability);
+
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Seething Song"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+ private static final long serialVersionUID = 113811381138L;
+
+ public void resolve()
+ {
+ CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
+ list = list.getName("Mana Pool");
+ Card mp = list.getCard(0);
+ mp.addExtrinsicKeyword("ManaPool:R");
+ mp.addExtrinsicKeyword("ManaPool:R");
+ mp.addExtrinsicKeyword("ManaPool:R");
+ mp.addExtrinsicKeyword("ManaPool:R");
+ mp.addExtrinsicKeyword("ManaPool:R");
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };
+
+ spell.setStackDescription("Adds R R R R R to your mana pool");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ return card;
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Dark Ritual"))
+ {
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -8579887529151755266L;
+ public void resolve()
+ {
+ CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
+ list = list.getName("Mana Pool");
+ Card mp = list.getCard(0);
+ mp.addExtrinsicKeyword("ManaPool:B");
+ mp.addExtrinsicKeyword("ManaPool:B");
+ mp.addExtrinsicKeyword("ManaPool:B");
+ }
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+ };
+
+ spell.setStackDescription(cardName + " adds B B B to your mana pool");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ return card;
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Black Lotus"))
+ {
+ final SpellAbility ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = 8394047173115959008L;
+
+ public boolean canPlayAI(){return false;}
+
+ public void resolve()
+ {
+ if (card.getController().equals(Constant.Player.Human))
+ {
+ CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
+ list = list.getName("Mana Pool");
+ Card mp = list.getCard(0);
+
+ String color = new String();
+
+ Object o = AllZone.Display.getChoice("Choose mana color",Constant.Color.Colors);
+ color = (String)o;
+
+ if (color.equals("white"))
+ color = "W";
+ else if (color.equals("blue"))
+ color = "U";
+ else if (color.equals("black"))
+ color = "B";
+ else if (color.equals("red"))
+ color = "R";
+ else if (color.equals("green"))
+ color = "G";
+ else
+ color = "1";
+
+
+ //System.out.println("ManaPool:"+color+":");
+ for (int i = 0; i < 3; i++)
+ mp.addExtrinsicKeyword("ManaPool:"+ color);
+
+ AllZone.GameAction.sacrifice(card);
+ }
+ }
+ };
+ ability.setDescription("tap, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.");
+ ability.setStackDescription("Adds 3 mana of any one color to your mana pool");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START *********** START **************************
+ if (cardName.equals("Composite Golem"))
+ {
+ final Ability ability = new Ability(card, "0")
+ {
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0)
+ return true;
+ else
+ return false;
+ }
+ };//SpellAbility
+
+ Input runtime = new Input()
+ {
+
+ private static final long serialVersionUID = 1408675899387720506L;
+
+ public void showMessage()
+ {
+ CardList cars = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ cars = cars.getType("Caribou");
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(a2, cars, "Select a Caribou to sacrifice.", false));
+ }
+ };
+
+ card.addSpellAbility(a2);
+ a2.setDescription("Sacrifice a Caribou: You gain 1 life.");
+ a2.setStackDescription(card.getController() + " gains 1 life.");
+ a2.setBeforePayMana(runtime);
+
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+ Input runtime2 = new Input()
+ {
+
+ private static final long serialVersionUID = -6674543815905055287L;
+
+ public void showMessage()
+ {
+ PlayerZone hum = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList land = new CardList();
+ land.addAll(hum.getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isLand();
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, land, "Select target land you control", true));
+ }
+ };
+ spell.setBeforePayMana(runtime2);
+ }//*************** END ************ END **************************
+
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Leafdrake Roost"))
+ {
+
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = -4695012002471107694L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Land");
+
+ if(list.isEmpty())
+ return false;
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ card.enchantCard(c);
+
+ }//resolve()
+ };//SpellAbility
+ spell.setType("Extrinsic");
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ final SpellAbility produceDrakes = new Ability_Tap(spell.getTargetCard(), "G U")
+ {
+
+ private static final long serialVersionUID = -3849765771560556442L;
+ public void resolve()
+ {
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+ Card crd = spell.getTargetCard();
+
+ c.setName("Drake");
+ c.setImageName("G U 2 2 Drake");
+
+ c.setOwner(crd.getController());
+ c.setController(crd.getController());
+
+ c.setManaCost("G U");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Drake");
+ c.setBaseAttack(2);
+ c.setBaseDefense(2);
+ c.addIntrinsicKeyword("Flying");
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ };//SpellAbility
+
+ produceDrakes.setDescription("G U, Tap: Put a 2/2 green and blue Drake creature token with flying onto the battlefield.");
+ produceDrakes.setStackDescription("Put a 2/2 green and blue Drake creature token with flying onto the battlefield.");
+
+ Command onEnchant = new Command()
+ {
+
+ private static final long serialVersionUID = -5501311059855861341L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ //crd.clearSpellAbility();
+ crd.addSpellAbility(produceDrakes);
+
+ }
+ }//execute()
+ };//Command
+
+
+ Command onUnEnchant = new Command()
+ {
+
+ private static final long serialVersionUID = 3589766088284055294L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+
+ Card crd = card.getEnchanting().get(0);
+ crd.removeSpellAbility(produceDrakes);
+
+ }
+
+ }//execute()
+ };//Command
+
+ Command onLeavesPlay = new Command()
+ {
+
+ private static final long serialVersionUID = -3747590484749776557L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ card.unEnchantCard(crd);
+ }
+ }
+ };
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+ Input runtime = new Input()
+ {
+
+ private static final long serialVersionUID = 967525396666242309L;
+
+ public void showMessage()
+ {
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ PlayerZone hum = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList land = new CardList();
+ land.addAll(comp.getCards());
+ land.addAll(hum.getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isLand();
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, land, "Select target land", true));
+ }
+ };
+ spell.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+
+
+ //*************** START *********** START **************************
+ if(cardName.equals("Squirrel Nest"))
+ {
+
+ final SpellAbility spell = new Spell(card)
+ {
+
+ private static final long serialVersionUID = 6115713202262504968L;
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards());
+ list = list.getType("Land");
+
+ if(list.isEmpty())
+ return false;
+
+ setTargetCard(list.get(0));
+ return true;
+ }//canPlayAI()
+ public void resolve()
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(card);
+
+ Card c = getTargetCard();
+
+ if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
+ card.enchantCard(c);
+
+ }//resolve()
+ };//SpellAbility
+ spell.setType("Extrinsic");
+
+ card.clearSpellAbility();
+ card.addSpellAbility(spell);
+
+ final SpellAbility produceSquirrels = new Ability_Tap(spell.getTargetCard())
+ {
+ private static final long serialVersionUID = -4800170026789001271L;
+ public void resolve()
+ {
+ makeToken();
+ }
+ void makeToken()
+ {
+ Card c = new Card();
+ Card crd = spell.getTargetCard();
+
+ c.setName("Squirrel");
+ c.setImageName("G 1 1 Squirrel");
+
+ c.setOwner(crd.getController());
+ c.setController(crd.getController());
+
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Squirrel");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
+ play.add(c);
+ }//makeToken()
+ };//SpellAbility
+
+ produceSquirrels.setDescription("Tap: Put a 1/1 green Squirrel creature token into play.");
+ produceSquirrels.setStackDescription("Put a 1/1 green Squirrel creature token into play.");
+
+ Command onEnchant = new Command()
+ {
+
+
+ private static final long serialVersionUID = 3528675502863241126L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ //crd.clearSpellAbility();
+ crd.addSpellAbility(produceSquirrels);
+
+ }
+ }//execute()
+ };//Command
+
+
+ Command onUnEnchant = new Command()
+ {
+ private static final long serialVersionUID = -2021446345291180334L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+
+ Card crd = card.getEnchanting().get(0);
+ crd.removeSpellAbility(produceSquirrels);
+
+ }
+
+ }//execute()
+ };//Command
+
+ Command onLeavesPlay = new Command()
+ {
+
+ private static final long serialVersionUID = -4543302260602460839L;
+
+ public void execute()
+ {
+ if (card.isEnchanting())
+ {
+ Card crd = card.getEnchanting().get(0);
+ card.unEnchantCard(crd);
+ }
+ }
+ };
+
+ card.addEnchantCommand(onEnchant);
+ card.addUnEnchantCommand(onUnEnchant);
+ card.addLeavesPlayCommand(onLeavesPlay);
+
+ Input runtime = new Input()
+ {
+
+ private static final long serialVersionUID = 967525396666242309L;
+
+ public void showMessage()
+ {
+ PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ PlayerZone hum = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ CardList land = new CardList();
+ land.addAll(comp.getCards());
+ land.addAll(hum.getCards());
+ land = land.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.isLand();
+ }
+ });
+
+ stopSetNext(CardFactoryUtil.input_targetSpecific(spell, land, "Select target land", true));
+ }
+ };
+ spell.setBeforePayMana(runtime);
+ }//*************** END ************ END **************************
+ //*************** START ************ START **************************
+ if (cardName.equals("Ashnod's Transmogrant"))
+ {
+ final Ability_Tap ability = new Ability_Tap(card)
+ {
+ private static final long serialVersionUID = -401631574059431293L;
+ public void resolve()
+ {
+ if (card.getController().equals(Constant.Player.Computer))
+ AllZone.GameAction.sacrifice(card);
+ if(getTargetCard() == null || !getTargetCard().isCreature())
+ return;
+ Card crd = getTargetCard();
+ crd.addCounter(Counters.P1P1, 1);
+ if(!crd.getType().contains("Artifact"))
+ crd.addType("Artifact");
+ }
+ public boolean canPlayAI()
+ {
+ CardList list = new CardList(AllZone.Computer_Play.getCards()).filter(
+ new CardListFilter(){public boolean addCard(Card c){ return !c.isArtifact() && c.isCreature(); }});
+ Card crd = CardFactoryUtil.AI_getBestCreature(list);
+ if (crd != null)
+ setTargetCard(crd);
+ return (getTargetCard() != null);
+ }
+ };
+ Input runtime = new Input()
+ {
+ private static final long serialVersionUID = 141164423096887945L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +card);
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card c, PlayerZone zone)
+ {
+ if (!CardFactoryUtil.canTarget(ability, c))
+ {
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(c.isCreature() && !c.isArtifact() && zone.is(Constant.Zone.Play))
+ {
+ ability.setTargetCard(c);
+ AllZone.GameAction.sacrifice(card);
+ stopSetNext(new Input_NoCost_TapAbility(ability));
+ }
+ }
+ };
+ ability.setBeforePayMana(runtime);
+ ability.setDescription("T, Sacrifice Ashnod's Transmogrant: put a +1/+1 counter on target nonartifact creature. That creature becomes an artifact in addition to its other types.");
+ card.addSpellAbility(ability);
+ }//*************** END ************ END **************************
+
+ //*************** START ************ START **************************
+ if (cardName.equals("Gemstone Array"))
+ {
+ final Ability store = new Ability(card, "2"){
+ public void resolve(){card.addCounter(Counters.CHARGE, 1);}
+ public boolean canPlayAI(){ return AllZone.Phase.is(Constant.Phase.Main2, Constant.Player.Computer);}
+ };
+ store.setDescription("2: Put a charge counter on Gemstone Array.");
+ store.setStackDescription("Put a charge counter on Gemstone Array");
+ card.addSpellAbility(store);
+
+ final Ability_Mana retrieve = new Ability_Mana(card, "Remove a charge counter from Gemstone Array: Add one mana of any color to your mana pool.")
+ {
+ private static final long serialVersionUID = -2938965362221626028L;
+
+ @SuppressWarnings("unused")
+ boolean undoable = true;
+ public void undo() {card.addCounter(Counters.CHARGE, 1);}
+ public String Mana() {return this.choices_made[0].toString();}
+ public boolean canPlay() {return super.canPlay() && card.getCounters(Counters.CHARGE) > 0;}
+ public void resolve(){card.subtractCounter(Counters.CHARGE, 1); super.resolve();}
+ };
+ retrieve.choices_made = new String[1];
+ retrieve.setBeforePayMana(new Input(){
+ /**
+ *
+ */
+ private static final long serialVersionUID = 376497609786542558L;
+
+ public void showMessage()
+ {
+ retrieve.choices_made[0] = Input_PayManaCostUtil.getColor2((String)AllZone.Display.getChoiceOptional("Select a Color", Constant.Color.onlyColors));
+ if(retrieve.choices_made[0] == null)
+ retrieve.choices_made[0] = "1";
+ AllZone.Stack.add(retrieve);
+ stop();
+ }
+ });
+ card.addSpellAbility(retrieve);
+ }//*************** END ************ END **************************
+
+ //*************** START ************ START **************************
+ if (cardName.equals("Rats of Rath"))
+ {
+ final Ability ability = new Ability(card,"B")
+ {
+ public boolean canPlayAI(){return false;};
+ public void resolve(){AllZone.GameAction.destroy(getTargetCard());};
+ };
+ ability.setBeforePayMana(new Input(){
+ private static final long serialVersionUID = 7691864588170864421L;
+
+ public void showMessage()
+ {
+ CardList choices = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ choices.filter(new CardListFilter(){public boolean addCard(Card c){
+ return c.isArtifact() || c.isCreature() || c.isLand();}});
+ stopSetNext(CardFactoryUtil.input_targetSpecific(ability, choices, "Select an artifact, creature, or land you control", true));}
+ });
+ ability.setDescription("B: Destroy target artifact, creature, or land you control.");
+ card.addSpellAbility(ability);
+ }
+ //*************** END ************ END **************************
+
+ //*************** START ************ START **************************
+ if (cardName.equals("Goblin Grenade"))
+ {
+ final SpellAbility DamageCP = new Spell(card)
+ {
+ private static final long serialVersionUID = -4289150611689144985L;
+ Card check;
+
+ public boolean canPlay()
+ {
+ CardList gobs = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ gobs = gobs.getType("Goblin");
+
+ return gobs.size()>0;
+ }
+
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= 5)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= 5)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+
+ if (check == null && c != null)
+ System.out.println("Check equals null");
+ else if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ if (c != null)
+ setTargetCard(c);
+ else
+ setTargetPlayer(Constant.Player.Human);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= 5){
+ System.out.println("getFlying() returns " + flying.get(i).getName());
+ return flying.get(i);
+ }
+
+ System.out.println("getFlying() returned null");
+ return null;
+ }
+ public void resolve()
+ {
+ if (card.getController().equals(Constant.Player.Computer))
+ {
+ CardList gobs = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ gobs = gobs.getType("Goblin");
+
+ if (gobs.size()>0)
+ {
+ CardListUtil.sortAttackLowFirst(gobs);
+ AllZone.GameAction.sacrifice(gobs.get(0));
+ }
+ //TODO, if AI can't sack, break out of this
+ }
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ //c.addDamage(damage);
+ AllZone.GameAction.addDamage(c, 5);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(5);
+ //resolve()
+ }
+ }; //spellAbility
+ DamageCP.setDescription(card.getName() + " deals 5 damage to target creature or player.");
+ //DamageCP.setStackDescription(card.getName() +" deals 5 damage.");
+
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 1843037500197925110L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target Creature, Player, or Planeswalker");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card crd, PlayerZone zone)
+ {
+ if((crd.isCreature() || crd.isPlaneswalker() ) && zone.is(Constant.Zone.Play) && CardFactoryUtil.canTarget(DamageCP, crd) )
+ {
+ DamageCP.setTargetCard(crd);
+ done();
+ }
+ }//selectCard()
+ public void selectPlayer(String player)
+ {
+ DamageCP.setTargetPlayer(player);
+ done();
+ }
+ void done()
+ {
+ AllZone.Stack.add(DamageCP);
+ stop();
+ }
+ };
+
+ Input targetSac = new Input()
+ {
+
+ private static final long serialVersionUID = -6102143961778874295L;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select a Goblin to sacrifice.");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card crd, PlayerZone zone)
+ {
+ CardList choices = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
+ choices = choices.getType("Goblin");
+
+ if(choices.contains(crd))
+ {
+ AllZone.GameAction.sacrifice(crd);
+ //DamageCP.setTargetCard(crd);
+ if(DamageCP instanceof Ability_Tap && DamageCP.getManaCost().equals("0"))
+ stopSetNext(new Input_NoCost_TapAbility((Ability_Tap)DamageCP));
+ else if(DamageCP.getManaCost().equals("0"))
+ {
+ //AllZone.Stack.add(DamageCP);
+ stop();
+ }
+ else
+ stopSetNext(new Input_PayManaCost(DamageCP));
+ }
+ }//selectCard()
+ };
+
+ DamageCP.setBeforePayMana(targetSac);
+ DamageCP.setAfterPayMana(target);
+ card.clearSpellAbility();
+ card.addSpellAbility(DamageCP);
+ }//*************** END ************ END **************************
+
+
+ // Cards with Cycling abilities
+ // -1 means keyword "Cycling" not found
+ if (shouldCycle(card) != -1)
+ {
+ int n = shouldCycle(card);
+ if (n != -1)
+ {
+ String parse = card.getKeyword().get(n).toString();
+ card.removeIntrinsicKeyword(parse);
+
+ String k[] = parse.split(":");
+ final String manacost = k[1];
+
+ card.addSpellAbility(CardFactoryUtil.ability_cycle(card, manacost));
+ }
+ }//Cycling
+
+
+ return card;
+ }//getCard2
+
+
+
+ // copies stats like attack, defense, etc..
+ private Card copyStats(Object o) {
+ Card sim = (Card) o;
+ Card c = new Card();
+
+ c.setBaseAttack(sim.getBaseAttack());
+ c.setBaseDefense(sim.getBaseDefense());
+ c.setIntrinsicKeyword(sim.getKeyword());
+ c.setName(sim.getName());
+ c.setType(sim.getType());
+ c.setText(sim.getSpellText());
+ c.setManaCost(sim.getManaCost());
+
+ return c;
+ }// copyStats()
+
+ public static void main(String[] args) {
+ CardFactory f = new CardFactory("cards.txt");
+ Card c = f.getCard("Arc-Slogger", "d");
+ System.out.println(c.getOwner());
+ }
+}
\ No newline at end of file
diff --git a/src/CardFactoryUtil.java b/src/CardFactoryUtil.java
new file mode 100644
index 00000000000..70f639fe202
--- /dev/null
+++ b/src/CardFactoryUtil.java
@@ -0,0 +1,2381 @@
+import java.util.*;
+
+public class CardFactoryUtil
+{
+ private static Random random = new Random();
+
+ public final static String getPumpString(int n)
+ {
+ if(0 <= n)
+ return "+" +n;
+ else
+ return "" +n;
+ }
+
+ public static Card AI_getMostExpensivePermanent(CardList list, final Card spell, boolean targeted)
+ {
+ CardList all = list;
+ if (targeted)
+ {
+ all = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(spell, c);
+ }
+ });
+ }
+ if (all.size() == 0)
+ return null;
+
+ //get biggest Permanent
+ Card biggest = null;
+ biggest = all.get(0);
+
+ for(int i = 0; i < all.size(); i++){
+ if(CardUtil.getConvertedManaCost(biggest.getManaCost()) >= CardUtil.getConvertedManaCost(biggest.getManaCost())){
+ biggest = all.get(i);
+ }
+ }
+
+ return biggest;
+
+ }
+
+ public static Card AI_getCheapestPermanent(CardList list, final Card spell, boolean targeted)
+ {
+ CardList all = list;
+ if (targeted) {
+ all = all.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return CardFactoryUtil.canTarget(spell, c);
+ }
+ });
+ }
+ if (all.size() == 0)
+ return null;
+
+ //get cheapest card:
+ Card cheapest = null;
+ cheapest = all.get(0);
+
+ for(int i = 0; i < all.size(); i++){
+ if(CardUtil.getConvertedManaCost(cheapest.getManaCost()) <= CardUtil.getConvertedManaCost(cheapest.getManaCost())){
+ cheapest = all.get(i);
+ }
+ }
+
+ return cheapest;
+
+ }
+
+ public static Card AI_getBestLand(CardList list)
+ {
+ CardList land = list.getType("Land");
+ if (! (land.size() > 0))
+ return null;
+
+ CardList nbLand = land.filter(new CardListFilter () // prefer to target non basic lands
+ {
+ public boolean addCard(Card c)
+ {
+ return (!c.getType().contains("Basic"));
+ }
+ }
+ );
+
+ if (nbLand.size() > 0)
+ {
+ //TODO: Rank non basics?
+
+ Random r = new Random();
+ return nbLand.get(r.nextInt(nbLand.size()));
+ }
+
+ // if no non-basic lands, target the least represented basic land type
+ String names[] = {"Plains", "Island", "Swamp", "Mountain", "Forest"};
+ String sminBL = new String();
+ int iminBL = 20000; // hopefully no one will ever have more than 20000 lands of one type....
+ int n = 0;
+ for (int i = 0; i < 5; i++)
+ {
+ n = land.getType(names[i]).size();
+ if (n < iminBL && n > 0) // if two or more are tied, only the first one checked will be used
+ {
+ iminBL = n;
+ sminBL = names[i];
+ }
+ }
+ if (iminBL == 20000)
+ return null; // no basic land was a minimum
+
+ CardList BLand = land.getType(sminBL);
+ for (int i=0; i= CardUtil.getConvertedManaCost(biggest.getManaCost())){
+ biggest = all.get(i);
+ }
+ }
+
+ return biggest;
+ }
+
+
+//The AI doesn't really pick the best artifact, just the most expensive.
+ public static Card AI_getBestArtifact(CardList list)
+ {
+ CardList all = list;
+ all = all.getType("Artifact");
+ if(all.size() == 0){
+ return null;
+ }
+
+ //get biggest Artifact
+ Card biggest = null;
+ biggest = all.get(0);
+
+ for(int i = 0; i < all.size(); i++){
+ if(CardUtil.getConvertedManaCost(biggest.getManaCost()) >= CardUtil.getConvertedManaCost(biggest.getManaCost())){
+ biggest = all.get(i);
+ }
+ }
+
+ return biggest;
+ }
+
+ public static CardList AI_getHumanArtifact(final Card spell, boolean targeted)
+ {
+ CardList artifact = new CardList(AllZone.Human_Play.getCards());
+ artifact = artifact.getType("Artifact");
+ if(targeted)
+ {
+ artifact = artifact.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return canTarget(spell,c);
+ }
+ });
+ }
+ return artifact;
+ }
+
+ public static CardList AI_getHumanEnchantment(final Card spell, boolean targeted)
+ {
+ CardList enchantment = new CardList(AllZone.Human_Play.getCards());
+ enchantment = enchantment.getType("Enchantment");
+ if (targeted)
+ {
+ enchantment = enchantment.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c) {
+ return canTarget(spell,c);
+ }
+ });
+ }
+ return enchantment;
+ }
+
+
+//yes this is more hacky code
+ //Object[0] is the cardname
+ //Object[1] is the max number of times it can be used per turn
+ //Object[1] has to be an Object like Integer and not just an int
+ private static Object[][] AbilityLimits =
+ {
+ {"Azimaet Drake" , new Integer(1)},
+ {"Drake Hatchling" , new Integer(1)},
+ {"Fire Drake" , new Integer(1)},
+ {"Plated Rootwalla" , new Integer(1)},
+ {"Rootwalla" , new Integer(1)},
+ {"Spitting Drake" , new Integer(1)},
+ {"Ghor-Clan Bloodscale", new Integer(1)},
+ {"Wild Aesthir", new Integer(1)},
+ {"Viashino Slaughtermaster", new Integer(1)},
+ {"Twinblade Slasher", new Integer(1)},
+
+ {"Phyrexian Battleflies" , new Integer(2)},
+ {"Pit Imp" , new Integer(2)},
+ {"Roterothopter" , new Integer(2)},
+ {"Vampire Bats" , new Integer(2)},
+ {"Fire-Belly Changeling" , new Integer(2)},
+ {"Azusa, Lost but Seeking" , new Integer(2)}
+ };
+
+ public static boolean canUseAbility(Card card)
+ {
+ int found = -1;
+
+ //try to find card name in AbilityLimits[][]
+ for(int i = 0; i < AbilityLimits.length; i++)
+ if(AbilityLimits[i][0].equals(card.getName()))
+ found = i;
+
+ if(found == -1)
+ return true;
+
+ //card was found
+ if(card.getAbilityTurnUsed() != AllZone.Phase.getTurn())
+ {
+ card.setAbilityTurnUsed(AllZone.Phase.getTurn());
+ card.setAbilityUsed(0);
+ }
+ SpellAbility sa;
+ //this is a hack, check the stack to see if this card has an ability on the stack
+ //if so, we can't use the ability: this is to prevent using a limited ability too many times
+ for (int i=0; i (loss+2));
+ }
+ public boolean canPlay()
+ {
+ PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard ,sourceCard.getController());
+ String phase = AllZone.Phase.getPhase();
+ String activePlayer = AllZone.Phase.getActivePlayer();
+
+ return AllZone.GameAction.isCardInZone(sourceCard, grave) && (sourceCard.isInstant() ||
+ (phase.equals(Constant.Phase.Main1) || phase.equals(Constant.Phase.Main2)) &&
+ sourceCard.getController().equals(activePlayer) && AllZone.Stack.size() == 0 );
+
+ }
+
+ };
+
+ String lifecost = "";
+ if (loss != 0)
+ lifecost = ", pay " + lifeloss + " life";
+
+
+ flashback.setManaCost(manaCost);
+ flashback.setDescription("Flashback: " + manaCost + lifecost);
+ flashback.setStackDescription("Flashback: " + sourceCard.getName());
+
+ return flashback;
+
+ }//ability_Flashback()
+
+ public static SpellAbility ability_Spore_Saproling(final Card sourceCard)
+ {
+ final SpellAbility ability = new Ability(sourceCard, "0")
+ {
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i= 3 && AllZone.GameAction.isCardInPlay(sourceCard))
+ return true;
+ else
+ return false;
+ }
+ public boolean canPlayAI() {return true;}
+
+ public void resolve()
+ {
+ sourceCard.subtractCounter(Counters.SPORE, 3);
+
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, sourceCard.getController());
+
+ //make token
+ Card c = new Card();
+
+ c.setOwner(sourceCard.getController());
+ c.setController(sourceCard.getController());
+
+ c.setName("Saproling");
+ c.setImageName("G 1 1 Saproling");
+ c.setManaCost("G");
+ c.setToken(true);
+
+ c.addType("Creature");
+ c.addType("Saproling");
+ c.setBaseAttack(1);
+ c.setBaseDefense(1);
+
+ play.add(c);
+ }
+ };
+ ability.setDescription("Remove three spore counters from " +sourceCard.getName() +": Put a 1/1 green Saproling creature token into play.");
+ ability.setStackDescription(sourceCard.getName() +" - put a 1/1 green Saproling creature token into play.");
+ return ability;
+ }//ability_Spore_Saproling()
+
+ public static SpellAbility ability_Morph_Down(final Card sourceCard)
+ {
+ final String player = sourceCard.getController();
+ final SpellAbility morph_down = new Spell(sourceCard)
+ {
+ private static final long serialVersionUID = -1438810964807867610L;
+
+ public void resolve()
+ {
+ PlayerZone hand = AllZone.getZone(Constant.Zone.Hand ,player);
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play ,player);
+
+ //card.setName("Morph");
+ sourceCard.setIsFaceDown(true);
+ sourceCard.setManaCost("");
+ sourceCard.setBaseAttack(2);
+ sourceCard.setBaseDefense(2);
+ sourceCard.comesIntoPlay();
+ sourceCard.setIntrinsicKeyword(new ArrayList()); //remove all keywords
+ sourceCard.setType(new ArrayList()); //remove all types
+ sourceCard.addType("Creature");
+
+ hand.remove(sourceCard);
+ play.add(sourceCard);
+ }
+ public boolean canPlay()
+ {
+ return AllZone.Phase.getActivePlayer().equals(sourceCard.getController()) &&
+ ( AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2) ) &&
+ !AllZone.Phase.getPhase().equals("End of Turn") && !AllZone.GameAction.isCardInPlay(sourceCard);
+ }
+
+ };
+
+ morph_down.setManaCost("3");
+ morph_down.setDescription("You may play this face down as a 2/2 creature for 3. Turn it face up any time for its morph cost.");
+ morph_down.setStackDescription("Morph - Creature 2/2");
+
+ return morph_down;
+ }
+
+ public static SpellAbility ability_Spellbomb(final Card sourceCard){
+ final SpellAbility ability = new Ability(sourceCard, "1")
+ {
+ public boolean canPlay()
+ {
+ return AllZone.GameAction.isCardInPlay(sourceCard)&&!AllZone.Stack.getSourceCards().contains(sourceCard);//in play and not already activated(Sac cost problems)
+ }
+ public boolean canPlayAI() {return (AllZone.Computer_Hand.size() < 4)&&(AllZone.Computer_Library.size()>0)&&MyRandom.random.nextBoolean();}
+
+ public void resolve()
+ {
+ AllZone.GameAction.drawCard(sourceCard.getController());
+ AllZone.GameAction.sacrifice(getSourceCard());
+ }
+ };
+ ability.setDescription("1, Sacrifice "+sourceCard.getName()+": Draw a card.");
+ ability.setStackDescription(sourceCard.getName() +" - Draw a card.");
+ return ability;
+ }
+
+ public static Ability ability_Morph_Up(final Card sourceCard, String cost, String orgManaCost, int a, int d)
+ {
+ //final String player = sourceCard.getController();
+ //final String manaCost = cost;
+ final int attack = a;
+ final int defense = d;
+ final String origManaCost = orgManaCost;
+ final Ability morph_up = new Ability(sourceCard, cost)
+ {
+ private static final long serialVersionUID = -7892773658629724785L;
+
+ public void resolve()
+ {
+ //PlayerZone hand = AllZone.getZone(Constant.Zone.Hand ,player);
+ //PlayerZone play = AllZone.getZone(Constant.Zone.Play ,player);
+
+ //card.setName("Morph");
+ sourceCard.setIsFaceDown(false);
+ sourceCard.setManaCost(origManaCost);
+ sourceCard.setBaseAttack(attack);
+ sourceCard.setBaseDefense(defense);
+ sourceCard.setIntrinsicKeyword(sourceCard.getPrevIntrinsicKeyword());
+ sourceCard.setType(sourceCard.getPrevType());
+ sourceCard.turnFaceUp();
+ }
+ public boolean canPlay()
+ {
+ return sourceCard.isFaceDown() && AllZone.GameAction.isCardInPlay(sourceCard);
+ }
+
+ };//morph_up
+
+ morph_up.setManaCost(cost);
+ morph_up.setDescription(cost + " - turn this card face up.");
+ morph_up.setStackDescription(sourceCard.getName() +" - turn this card face up.");
+
+ return morph_up;
+
+ }
+ public static SpellAbility spellability_spDamageP(final Card sourceCard, final String dmg)
+ {
+ final int damage = Integer.parseInt(dmg);
+
+ final SpellAbility spDamageP = new Spell(sourceCard)
+ {
+ private static final long serialVersionUID = -1263171535312610675L;
+
+ @SuppressWarnings("unused") // check
+ Card check;
+
+ public boolean canPlayAI()
+ {
+ return false;
+ }
+
+ public void chooseTargetAI()
+ {
+ CardFactoryUtil.AI_targetHuman();
+ return;
+ }
+
+ public void resolve()
+ {
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ }
+ };
+ spDamageP.setDescription(sourceCard.getName() + " deals " + damage + " damage to target player.");
+ spDamageP.setStackDescription(sourceCard.getName() +" deals " + damage + " damage.");
+ spDamageP.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDamageP));
+ return spDamageP;
+ }//Spellability_spDamageP
+
+ public static SpellAbility spellability_spDamageCP(final Card sourceCard, final String dmg)
+ {
+ final int damage = Integer.parseInt(dmg); // converting string dmg -> int
+
+ final SpellAbility DamageCP = new Spell(sourceCard)
+ {
+ private static final long serialVersionUID = 7239608350643325111L;
+
+ Card check;
+ //Shock's code here atm
+ public boolean canPlayAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ return true;
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if (hand.size() >= 8)
+ return true;
+
+ check = getFlying();
+ return check != null;
+ }
+
+ public void chooseTargetAI()
+ {
+ if(AllZone.Human_Life.getLife() <= damage)
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+ CardList hand = new CardList(compHand.getCards());
+
+ if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
+ {
+ setTargetPlayer(Constant.Player.Human);
+ return;
+ }
+
+ Card c = getFlying();
+
+ if (check == null && c != null)
+ System.out.println("Check equals null");
+ else if((c == null) || (! check.equals(c)))
+ throw new RuntimeException(sourceCard +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check);
+
+ if (c != null)
+ setTargetCard(c);
+ else
+ setTargetPlayer(Constant.Player.Human);
+ }//chooseTargetAI()
+
+ //uses "damage" variable
+ Card getFlying()
+ {
+ CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", sourceCard, true);
+ for(int i = 0; i < flying.size(); i++)
+ if(flying.get(i).getNetDefense() <= damage){
+ System.out.println("getFlying() returns " + flying.get(i).getName());
+ return flying.get(i);
+ }
+
+ System.out.println("getFlying() returned null");
+ return null;
+ }
+ public void resolve()
+ {
+
+ if(getTargetCard() != null)
+ {
+ if(AllZone.GameAction.isCardInPlay(getTargetCard()) && canTarget(sourceCard, getTargetCard()))
+ {
+ Card c = getTargetCard();
+ //c.addDamage(damage);
+ AllZone.GameAction.addDamage(c, damage);
+ }
+ }
+ else
+ AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
+ //resolve()
+ }
+ }; //spellAbility
+ DamageCP.setDescription(sourceCard.getName() + " deals " + damage + " damage to target creature or player.");
+ DamageCP.setStackDescription(sourceCard.getName() +" deals " + damage + " damage.");
+ DamageCP.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(DamageCP, true));
+ return DamageCP;
+ }//spellability_DamageCP
+
+ public static SpellAbility ability_Merc_Search(final Card sourceCard, String cost)
+ {
+ final int intCost = Integer.parseInt(cost);
+ //final String player = sourceCard.getController();
+
+ final SpellAbility ability = new Ability_Tap(sourceCard, cost)
+ {
+ private static final long serialVersionUID = 4988299801575232348L;
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0)
+ return true;
+ else
+ return false;
+ }
+
+ public void resolve()
+ {
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, sourceCard.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, sourceCard.getController());
+
+ CardList mercs = new CardList();
+ CardList list = new CardList(lib.getCards());
+ list = list.getType("Mercenary");
+
+ if (list.size()==0)
+ return;
+
+ for (int i=0;i < list.size(); i++)
+ {
+ if (CardUtil.getConvertedManaCost(list.get(i).getManaCost()) <= intCost)
+ {
+ mercs.add(list.get(i));
+ }
+ }
+ if (mercs.size() == 0)
+ return;
+
+ if (sourceCard.getController().equals(Constant.Player.Computer))
+ {
+ Card merc = AI_getBestCreature(mercs);
+ lib.remove(merc);
+ play.add(merc);
+ }
+ else //human
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target Mercenary", mercs.toArray());
+ if (o!=null){
+ Card merc = (Card)o;
+ lib.remove(merc);
+ play.add(merc);
+ }
+ }
+ AllZone.GameAction.shuffle(sourceCard.getController());
+ }
+ };
+ ability.setDescription(cost+ ", tap: Search your library for a Mercenary permanent card with converted mana cost " +cost +" or less and put it into play. Then shuffle your library.");
+ ability.setStackDescription(sourceCard.getName() +" - search for a Mercenary and put it into play.");
+ return ability;
+ }
+
+ public static SpellAbility ability_Rebel_Search(final Card sourceCard, String cost)
+ {
+ String costMinusOne = "";
+ int a = Integer.parseInt(cost);
+ a--;
+ costMinusOne = Integer.toString(a);
+ final int converted = a;
+ //final String player = sourceCard.getController();
+
+ final SpellAbility ability = new Ability_Tap(sourceCard, cost)
+ {
+ private static final long serialVersionUID = 7219065355049285681L;
+
+ public boolean canPlay()
+ {
+ SpellAbility sa;
+ for (int i=0; i 0)
+ return true;
+ else
+ return false;
+
+ }
+
+
+ public void resolve()
+ {
+
+ PlayerZone lib = AllZone.getZone(Constant.Zone.Library, sourceCard.getController());
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play, sourceCard.getController());
+
+ CardList rebels = new CardList();
+ CardList list = new CardList(lib.getCards());
+ list = list.getType("Rebel");
+
+ if (list.size()==0)
+ return;
+
+ for (int i=0;i < list.size(); i++)
+ {
+ if (CardUtil.getConvertedManaCost(list.get(i).getManaCost()) <= converted)
+ {
+ rebels.add(list.get(i));
+ }
+ }
+ if (rebels.size() == 0)
+ return;
+
+ if (sourceCard.getController().equals(Constant.Player.Computer))
+ {
+ Card rebel = AI_getBestCreature(rebels);
+ lib.remove(rebel);
+ play.add(rebel);
+ }
+ else //human
+ {
+ Object o = AllZone.Display.getChoiceOptional("Select target Rebel", rebels.toArray());
+ if (o!=null){
+ Card rebel = (Card)o;
+ lib.remove(rebel);
+ play.add(rebel);
+ }
+ }
+ AllZone.GameAction.shuffle(sourceCard.getController());
+ }
+ };
+ ability.setDescription(cost+ ", tap: Search your library for a Rebel permanent card with converted mana cost " +costMinusOne +" or less and put it into play. Then shuffle your library.");
+ ability.setStackDescription(sourceCard.getName() +" - search for a Rebel and put it into play.");
+ return ability;
+ }
+
+ public static SpellAbility ability_cycle(final Card sourceCard, final String cycleCost)
+ {
+ final SpellAbility cycle = new Ability_Hand(sourceCard, cycleCost)
+ {
+ private static final long serialVersionUID = -4960704261761785512L;
+
+ public boolean canPlayAI() {return false;}
+
+ public void resolve()
+ {
+ AllZone.GameAction.discard(sourceCard);
+ AllZone.GameAction.drawCard(sourceCard.getController());
+ sourceCard.cycle();
+ }
+ };
+ cycle.setDescription("Cycling " +cycleCost +" (" +cycleCost +", Discard this card: Draw a card.)");
+ cycle.setStackDescription(sourceCard +" Cycling: Draw a card");
+ return cycle;
+ }//ability_cycle()
+
+
+ //CardList choices are the only cards the user can successful select
+ public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, final boolean targeted)
+ {
+ return input_targetSpecific(spell, choices, message, Command.Blank, targeted);
+ }
+
+ //CardList choices are the only cards the user can successful select
+ public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, final Command paid, final boolean targeted)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -1779224307654698954L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage(message);
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if (targeted && !canTarget(spell, card))
+ {
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(choices.contains(card))
+ {
+ spell.setTargetCard(card);
+ if(spell instanceof Ability_Tap && spell.getManaCost().equals("0"))
+ stopSetNext(new Input_NoCost_TapAbility((Ability_Tap)spell));
+ else if(spell.getManaCost().equals("0"))
+ {
+ AllZone.Stack.add(spell);
+ stop();
+ }
+ else
+ stopSetNext(new Input_PayManaCost(spell));
+
+ paid.execute();
+ }
+ }//selectCard()
+ };
+ return target;
+ }//input_targetSpecific()
+
+ public static Input input_discard(final SpellAbility spell, final int nCards)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 5101772642421944050L;
+
+ int n = 0;
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select a card to discard");
+ ButtonUtil.disableAll();
+
+ if(n == nCards || AllZone.Human_Hand.getCards().length == 0)
+ stop();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Hand))
+ {
+ AllZone.GameAction.discard(card);
+ n++;
+ if(spell.getManaCost().equals("0"))
+ {
+ AllZone.Stack.add(spell);
+ stop();
+ }
+ else
+ stopSetNext(new Input_PayManaCost(spell));
+
+ //showMessage();
+ } // if
+
+
+ }//selectCard
+
+ };
+ return target;
+
+ }
+
+ public static Input input_discard()
+ {
+ return input_discard(1);
+ }
+
+ public static Input input_discard(final int nCards)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -329993322080934435L;
+
+ int n = 0;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select a card to discard");
+ ButtonUtil.disableAll();
+
+ //in case no more cards in hand
+ if(n == nCards || AllZone.Human_Hand.getCards().length == 0)
+ stop();
+ }
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(zone.is(Constant.Zone.Hand))
+ {
+ AllZone.GameAction.discard(card);
+ n++;
+ showMessage();
+ }
+ }
+ };
+ return target;
+ }//input_discard()
+
+
+
+ //cardType is like "Creature", "Land", "Artifact", "Goblin", "Legendary"
+ //cardType can also be "All", which will allow any permanent to be selected
+ public static Input input_targetType(final SpellAbility spell, final String cardType)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 4944828318048780429L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target " +cardType);
+
+ if(cardType.equals("All"))
+ AllZone.Display.showMessage("Select target permanent");
+
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(((card.getType().contains(cardType) || card.getKeyword().contains("Changeling")) || cardType.equals("All")) &&
+ zone.is(Constant.Zone.Play) && canTarget(spell, card))
+ {
+ spell.setTargetCard(card);
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ }
+ };
+ return target;
+ }//input_targetType()
+
+
+ public static Input input_targetCreature(final SpellAbility spell)
+ {
+ return input_targetCreature(spell, Command.Blank);
+ }
+
+ public static Input input_targetCreature(final SpellAbility spell, final Command paid)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 141164423096887945L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature for " +spell.getSourceCard());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if (!canTarget(spell, card))
+ {
+ AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
+ }
+ else if(card.isCreature() && zone.is(Constant.Zone.Play))
+ {
+ spell.setTargetCard(card);
+ done();
+ }
+ }
+ void done()
+ {
+ if(spell instanceof Ability_Tap && spell.getManaCost().equals("0"))
+ stopSetNext(new Input_NoCost_TapAbility((Ability_Tap)spell));
+ else if(spell.getManaCost().equals("0"))//for "sacrifice this card" abilities
+ {
+ AllZone.Stack.add(spell);
+ stop();
+ }
+ else
+ stopSetNext(new Input_PayManaCost(spell));
+
+ paid.execute();
+ }
+ };
+ return target;
+ }//input_targetCreature()
+
+ public static Input input_targetCreature_NoCost_TapAbility(final Ability_Tap spell)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 6027194502614341779L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card.isCreature() && zone.is(Constant.Zone.Play) && canTarget(spell, card))
+ {
+ spell.setTargetCard(card);
+ spell.getSourceCard().tap();
+ AllZone.Stack.push(spell);
+ stop();
+ }
+ }
+ };
+ return target;
+ }//input_targetCreature()
+
+ public static Input input_targetCreature_NoCost_TapAbility_NoTargetSelf(final Ability_Tap spell)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = -6310420275914649718L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target creature other than "+spell.getSourceCard().getName());
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectCard(Card card, PlayerZone zone)
+ {
+ if(card == spell.getSourceCard()){
+ AllZone.Display.showMessage("You must select a target creature other than "+spell.getSourceCard().getName());
+ }
+ else if(card.isCreature() && zone.is(Constant.Zone.Play) && !card.getKeyword().contains("Shroud"))
+ {
+ spell.setTargetCard(card);
+ spell.getSourceCard().tap();
+ AllZone.Stack.push(spell);
+ stop();
+ }
+ }
+ };
+ return target;
+ }//input_targetCreature_NoCost_TapAbility_NoTargetSelf
+
+
+
+ public static Input input_targetPlayer(final SpellAbility spell)
+ {
+ Input target = new Input()
+ {
+ private static final long serialVersionUID = 8736682807625129068L;
+
+ public void showMessage()
+ {
+ AllZone.Display.showMessage("Select target player");
+ ButtonUtil.enableOnlyCancel();
+ }
+ public void selectButtonCancel() {stop();}
+ public void selectPlayer(String player)
+ {
+ spell.setTargetPlayer(player);
+ if(spell.getManaCost().equals("0"))
+ {
+ AllZone.Stack.add(spell);
+ stop();
+ }
+ else
+ stopSetNext(new Input_PayManaCost(spell));
+ }
+ };
+ return target;
+ }//input_targetPlayer()
+
+ public static CardList AI_getHumanCreature(final Card spell, boolean targeted)
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.getType("Creature");
+ if (targeted)
+ {
+ creature = creature.filter(new CardListFilter(){
+ public boolean addCard(Card c) {
+ return canTarget(spell, c);
+ }
+ });
+ }
+ return creature;
+ }
+ public static CardList AI_getHumanCreature(final String keyword, final Card spell, final boolean targeted)
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(targeted)
+ return c.isCreature() && c.getKeyword().contains(keyword) && canTarget(spell, c);
+ else
+ return c.isCreature() && c.getKeyword().contains(keyword);
+ }
+ });
+ return creature;
+ }//AI_getHumanCreature()
+ public static CardList AI_getHumanCreature(final int toughness, final Card spell, final boolean targeted)
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(targeted)
+ return c.isCreature() && (c.getNetDefense() <= toughness) && canTarget(spell, c);
+ else
+ return c.isCreature() && (c.getNetDefense() <= toughness);
+ }
+ });
+ return creature;
+ }//AI_getHumanCreature()
+
+ public static CardList AI_getHumanCreature(final boolean lower, final int manaCost,final Card spell, final boolean targeted)
+ {
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if(targeted && lower)
+ return c.isCreature() && (CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) && canTarget(spell, c);
+ else if (lower)
+ return c.isCreature() && (CardUtil.getConvertedManaCost(c.getManaCost()) <= 3);
+
+ else if (targeted && !lower)
+ return c.isCreature() && (CardUtil.getConvertedManaCost(c.getManaCost()) >= 3) && canTarget(spell, c);
+ else //if !targeted && !lower
+ return c.isCreature() && (CardUtil.getConvertedManaCost(c.getManaCost()) >= 3);
+ }
+ });
+ return creature;
+ }//AI_getHumanCreature()
+
+ public static CommandArgs AI_targetHumanCreatureOrPlayer()
+ {
+ return new CommandArgs()
+ {
+ private static final long serialVersionUID = 1530080942899792553L;
+
+ public void execute(Object o)
+ {
+ SpellAbility sa = (SpellAbility)o;
+
+ CardList creature = new CardList(AllZone.Human_Play.getCards());
+ creature = creature.getType("Creature");
+ Card c = getRandomCard(creature);
+
+ if((c == null) || random.nextBoolean())
+ {
+ sa.setTargetPlayer(Constant.Player.Human);
+ }
+ else
+ {
+ sa.setTargetCard(c);
+ }
+ }
+ };//CommandArgs
+ }//human_creatureOrPlayer()
+ public static CommandArgs AI_targetHuman()
+ {
+ return new CommandArgs()
+ {
+ private static final long serialVersionUID = 8406907523134006697L;
+
+ public void execute(Object o)
+ {
+ SpellAbility sa = (SpellAbility)o;
+ sa.setTargetPlayer(Constant.Player.Human);
+ }
+ };
+ }//targetHuman()
+
+ //is it the computer's main phase before attacking?
+ public static boolean AI_isMainPhase()
+ {
+ return AllZone.Phase.getPhase().equals(Constant.Phase.Main1) &&
+ AllZone.Phase.getActivePlayer().equals(Constant.Player.Computer);
+ }
+ public static CommandArgs AI_targetComputer()
+ {
+ return new CommandArgs()
+ {
+ private static final long serialVersionUID = -445231553588926627L;
+
+ public void execute(Object o)
+ {
+ SpellAbility sa = (SpellAbility)o;
+ sa.setTargetPlayer(Constant.Player.Computer);
+ }
+ };
+ }//targetComputer()
+
+ //type can also be "All"
+ public static CommandArgs AI_targetType(final String type, final PlayerZone zone)
+ {
+ return new CommandArgs()
+ {
+ private static final long serialVersionUID = 6475810798098105603L;
+
+ public void execute(Object o)
+ {
+ CardList filter = new CardList(zone.getCards());
+
+ if(! type.equals("All"))
+ filter = filter.getType(type);
+
+ Card c = getRandomCard(filter);
+ if(c != null)
+ {
+ SpellAbility sa = (SpellAbility)o;
+ sa.setTargetCard(c);
+
+ //doesn't work for some reason
+// if(shouldAttack && CombatUtil.canAttack(c))
+// AllZone.Combat.addAttacker(c);
+ }
+ }//execute()
+ };
+ }//targetInPlay()
+
+ public static int getNumberOfPermanentsByColor(String color)
+ {
+ CardList cards = new CardList();
+ cards.addAll(AllZone.Human_Play.getCards());
+ cards.addAll(AllZone.Computer_Play.getCards());
+
+ CardList coloredPerms = new CardList();
+
+ for (int i=0; i= 2;
+ }
+
+ });
+
+ return list.size() >= 1;
+
+ }
+
+ public static int getNumberOfManaSymbolsControlledByColor(String colorAbb, String player)
+ {
+ PlayerZone play = AllZone.getZone(Constant.Zone.Play,player);
+
+ CardList cards = new CardList();
+ cards.addAll(play.getCards());
+
+ int count = 0;
+ for(int i=0;i list = target.getKeyword();
+
+ String kw = "";
+ for (int i=0;i list = target.getKeyword();
+
+ String kw = "";
+ for (int i=0;i list = receiver.getKeyword();
+
+ String kw = "";
+ for (int i=0;i 1)
+ m[0] = l[1];
+ final String [] sq;
+ sq = l[0].split("\\.");
+
+ CardList someCards = new CardList();
+
+ //Complex counting methods
+
+ // Count$Domain
+ if (sq[0].contains("Domain"))
+ {
+ someCards.addAll(myField.getCards());
+ String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"};
+
+ for(int i = 0; i < basic.length; i++)
+ if (! someCards.getType(basic[i]).isEmpty())
+ n++;
+
+ return doXMath(n, m);
+ }
+
+ // Count$YourLifeTotal
+ if (sq[0].contains("YourLifeTotal"))
+ {
+ if (cardController.equals(Constant.Player.Computer))
+ return doXMath(AllZone.Computer_Life.getLife(), m);
+ else if (cardController.equals(Constant.Player.Human))
+ return doXMath(AllZone.Human_Life.getLife(), m);
+
+ return 0;
+ }
+
+ // Count$OppLifeTotal
+ if (sq[0].contains("OppLifeTotal"))
+ {
+ if (oppController.equals(Constant.Player.Computer))
+ return doXMath(AllZone.Computer_Life.getLife(), m);
+ else if (oppController.equals(Constant.Player.Human))
+ return doXMath(AllZone.Human_Life.getLife(), m);
+
+ return 0;
+ }
+
+ // Count$Chroma.
+ if (sq[0].contains("Chroma"))
+ return doXMath(getNumberOfManaSymbolsControlledByColor(sq[1], cardController), m);
+
+ // Count$Hellbent..
+ if (sq[0].contains("Hellbent"))
+ if (myHand.size() <= 1)
+ return doXMath(Integer.parseInt(sq[1]), m); // Hellbent
+ else
+ return doXMath(Integer.parseInt(sq[2]), m); // not Hellbent
+
+
+ //Generic Zone-based counting
+ // Count$QualityAndZones.Subquality
+
+ // build a list of cards in each possible specified zone
+
+ // if a card was ever written to count two different zones,
+ // make sure they don't get added twice.
+ boolean MF = false, MY = false, MH = false;
+ boolean OF = false, OY = false, OH = false;
+
+ if (sq[0].contains("YouCtrl"))
+ if (MF == false)
+ {
+ someCards.addAll(myField.getCards());
+ MF = true;
+ }
+
+ if (sq[0].contains("InYourYard"))
+ if (MY == false)
+ {
+ someCards.addAll(myYard.getCards());
+ MY = true;
+ }
+
+ if (sq[0].contains("InYourHand"))
+ if (MH == false)
+ {
+ someCards.addAll(myHand.getCards());
+ MH = true;
+ }
+
+ if (sq[0].contains("OppCtrl"))
+ if (OF == false)
+ {
+ someCards.addAll(opField.getCards());
+ OF = true;
+ }
+
+ if (sq[0].contains("InOppYard"))
+ if (OY == false)
+ {
+ someCards.addAll(opYard.getCards());
+ OY = true;
+ }
+
+ if (sq[0].contains("InOppHand"))
+ if (OH == false)
+ {
+ someCards.addAll(opHand.getCards());
+ OH = true;
+ }
+
+ if (sq[0].contains("OnBattlefield"))
+ {
+ if (MF == false)
+ someCards.addAll(myField.getCards());
+ if (OF == false)
+ someCards.addAll(opField.getCards());
+ }
+
+ if (sq[0].contains("InAllYards"))
+ {
+ if (MY == false)
+ someCards.addAll(myYard.getCards());
+ if (OY = false)
+ someCards.addAll(opYard.getCards());
+ }
+
+ if (sq[0].contains("InAllHands"))
+ {
+ if (MH == false)
+ someCards.addAll(myHand.getCards());
+ if (OH == false)
+ someCards.addAll(opHand.getCards());
+ }
+
+ // filter lists based on the specified quality
+
+ // "Clerics you control" - Count$TypeYouCtrl.Cleric
+ if (sq[0].contains("Type"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if (c.getType().contains(sq[1]) || c.getKeyword().contains("Changeling"))
+ return true;
+
+ return false;
+ }
+ });
+ }
+
+ // "Named in all graveyards" - Count$NamedAllYards.
+
+ if (sq[0].contains("Named"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ if (c.getName().equals(sq[1]))
+ return true;
+
+ return false;
+ }
+ });
+ }
+
+ // Refined qualities
+
+ // "Untapped Lands" - Count$UntappedTypeYouCtrl.Land
+ if (sq[0].contains("Untapped"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return !c.isTapped();}
+ });
+ }
+
+ if (sq[0].contains("Tapped"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return c.isTapped();}
+ });
+ }
+
+ // "White Creatures" - Count$WhiteTypeYouCtrl.Creature
+ if (sq[0].contains("White"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return CardUtil.getColor(c) == Constant.Color.White;}
+ });
+ }
+
+ if (sq[0].contains("Blue"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return CardUtil.getColor(c) == Constant.Color.Blue;}
+ });
+ }
+
+ if (sq[0].contains("Black"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return CardUtil.getColor(c) == Constant.Color.Black;}
+ });
+ }
+
+ if (sq[0].contains("Red"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return CardUtil.getColor(c) == Constant.Color.Red;}
+ });
+ }
+
+ if (sq[0].contains("Green"))
+ {
+ someCards = someCards.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c){
+ return CardUtil.getColor(c) == Constant.Color.Green;}
+ });
+ }
+
+ if (sq[0].contains("Multicolor"))
+ someCards = someCards.filter(new CardListFilter ()
+ {
+ public boolean addCard(Card c){
+ return (CardUtil.getColors(c).size() > 1);
+ }
+ });
+
+ if (sq[0].contains("Monocolor"))
+ someCards = someCards.filter(new CardListFilter ()
+ {
+ public boolean addCard(Card c){
+ return (CardUtil.getColors(c).size() == 1);
+ }
+ });
+
+ n = someCards.size();
+
+ return doXMath(n, m);
+ }
+
+ private static int doXMath(int num, String[] m)
+ {
+ if (m[0].equals("none"))
+ return num;
+
+ String[] s = m[0].split("\\.");
+
+ if (s[0].contains("Plus"))
+ return num + Integer.parseInt(s[1]);
+ else if (s[0].contains("NMinus"))
+ return Integer.parseInt(s[1]) - num;
+ else if (s[0].contains("Minus"))
+ return num - Integer.parseInt(s[1]);
+ else if (s[0].contains("Twice"))
+ return num * 2;
+ else if (s[0].contains("HalfUp"))
+ return (int) (Math.ceil(num / 2));
+ else if (s[0].contains("HalfDown"))
+ return (int) (Math.floor(num / 2));
+
+ return num;
+ }
+
+
+ public static void doDrawBack(String DB, int nDB, String cardController, String Opp, String TgtP, Card Src, Card TgtC)
+ {
+ // Drawbacks may be any simple additional effect a spell or ability may have
+ // not just the negative ones
+
+ String d[] = DB.split("/");
+ int X;
+ if (d[1].equals("X"))
+ X = nDB;
+ else
+ X = Integer.parseInt(d[1]);
+
+ String dbPlayer = new String();
+ if (d[0].contains("You"))
+ dbPlayer = cardController;
+ else if (d[0].contains("Opp"))
+ dbPlayer = Opp;
+ else if (d[0].contains("Tgt"))
+ dbPlayer = TgtP;
+
+ if (d[0].contains("Damage"))
+ AllZone.GameAction.addDamage(dbPlayer, X);
+
+ if (d[0].contains("GainLife"))
+ AllZone.GameAction.addLife(dbPlayer, X);
+
+ if (d[0].contains("LoseLife"))
+ AllZone.GameAction.subLife(TgtP, X);
+
+ if (d[0].contains("Discard"))
+ {
+ if (d.length > 2)
+ {
+ if (d[2].contains("UnlessDiscardType"))
+ {
+ String dd[] = d[2].split("\\.");
+ AllZone.GameAction.discardUnless(dbPlayer, X, dd[1]);
+ }
+ if (d[2].contains("AtRandom"))
+ AllZone.GameAction.discardRandom(dbPlayer, X);
+ } else
+ AllZone.GameAction.discard(dbPlayer, X);
+ }
+
+ if (d[0].contains("HandToLibrary"))
+ AllZone.GameAction.handToLibrary(dbPlayer, X, d[2]);
+
+ if (d[0].contains("Draw"))
+ for (int i=0; i < X; i++)
+ AllZone.GameAction.drawCard(dbPlayer);
+
+ if (d[0].contains("GenToken")) // placeholder for effect
+ X = X + 0;
+
+ if (d[0].contains("ReturnFromYard")) // placeholder for effect
+ X = X + 0;
+
+ if (d[0].contains("Sacrifice")) // placeholder for effect
+ X = X + 0;
+ }
+ public static int getNumberOfMostProminentCreatureType(CardList list, String type)
+ {
+ list = list.getType(type);
+ return list.size();
+ }
+
+ public static String getMostProminentCreatureType(CardList list)
+ {
+
+ Map map = new HashMap();
+ String s = "";
+
+ for (int i=0;i typeList = c.getType();
+
+ for (String var : typeList)
+ {
+ if (var.equals("Creature") || var.equals("Artifact") || var.equals("Land") || var.equals("Tribal") || var.equals("Enchantment") ||
+ var.equals("Legendary") )
+ ;
+ else if (!map.containsKey(var))
+ map.put(var, 1);
+ else
+ {
+ map.put(var, map.get(var)+1);
+ }
+ }
+ }//for
+
+ int max = 0;
+ String maxType = "";
+
+ for (int i=0;i iter = map.keySet().iterator();
+ while(iter.hasNext()) {
+ String type = iter.next();
+ System.out.println(type + " - " + map.get(type));
+
+ if (max < map.get(type))
+ {
+ max = map.get(type);
+ maxType = type;
+ }
+ }
+ }
+ s = maxType;
+ return s;
+ }
+
+
+ public static String chooseCreatureTypeAI(Card c)
+ {
+ String s = "";
+ //TODO, take into account what human has
+
+ PlayerZone humanPlayZone = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
+ PlayerZone humanLibZone = AllZone.getZone(Constant.Zone.Library, Constant.Player.Human);
+
+ CardList humanPlay = new CardList(humanPlayZone.getCards());
+ CardList humanLib = new CardList(humanLibZone.getCards());
+
+ PlayerZone compPlayZone = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
+ PlayerZone compLibZone = AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer);
+ PlayerZone compHandZone = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
+
+ CardList compPlay = new CardList(compPlayZone.getCards());
+ CardList compLib = new CardList(compLibZone.getCards());
+ CardList compHand = new CardList(compHandZone.getCards());
+
+ humanPlay = humanPlay.getType("Creature");
+ humanLib = humanLib.getType("Creature");
+
+ compPlay = compPlay.getType("Creature");
+ compLib = compLib.getType("Creature");
+
+ //Buffs
+ if (c.getName().equals("Conspiracy") || c.getName().equals("Cover of Darkness") || c.getName().equals("Belbe's Portal") ||
+ c.getName().equals("Steely Resolve") || c.getName().equals("Shared Triumph"))
+ {
+
+ String type = "";
+ int number = 0;
+ if ((c.getName().equals("Shared Triumph") || c.getName().equals("Cover of Darkness") || c.getName().equals("Steely Resolve") )&& compPlay.size() > 7)
+ {
+ type = getMostProminentCreatureType(compPlay);
+ number = getNumberOfMostProminentCreatureType(compPlay, type);
+
+ }
+
+ if (number >= 3)
+ s = type;
+ else {
+ type = getMostProminentCreatureType(compLib);
+ number = getNumberOfMostProminentCreatureType(compLib, type);
+ if (number >= 5)
+ s = type;
+
+ }
+
+ CardList turnTimber = new CardList();
+ turnTimber.addAll(compPlay.toArray());
+ turnTimber.addAll(compLib.toArray());
+ turnTimber.addAll(compHand.toArray());
+
+ turnTimber = turnTimber.getName("Turntimber Ranger");
+
+ if (c.getName().equals("Conspiracy") && turnTimber.size() > 0 )
+ s = "Ally";
+
+ }
+ //Debuffs
+ else if(c.getName().equals("Engineered Plague"))
+ {
+ String type = "";
+ int number = 0;
+ if (c.getName().equals("Engineered Plague") && humanPlay.size() > 6)
+ {
+ type = getMostProminentCreatureType(humanPlay);
+ number = getNumberOfMostProminentCreatureType(humanPlay, type);
+ if (number >= 3)
+ s = type;
+ else if (humanLib.size()>0)
+ {
+ type = getMostProminentCreatureType(humanLib);
+ number = getNumberOfMostProminentCreatureType(humanLib, type);
+ if (number >=5)
+ s = type;
+ }
+ }
+ }
+ return s;
+ }
+
+
+ //may return null
+ static public Card getRandomCard(CardList list)
+ {
+ if(list.size() == 0)
+ return null;
+
+ int index = random.nextInt(list.size());
+ return list.get(index);
+ }
+ //may return null
+ static public Card getRandomCard(PlayerZone zone)
+ {
+ return getRandomCard(new CardList(zone.getCards()));
+ }
+
+ public static void main(String[] args)
+ {
+
+ CardList in = AllZone.CardFactory.getAllCards();
+
+ CardList list = new CardList();
+ list.addAll(CardListUtil.getColor(in, "black").toArray());
+ list = list.getType("Creature");
+
+ System.out.println("Most prominent creature type: " + getMostProminentCreatureType(list));
+ }
+
+}
\ No newline at end of file
diff --git a/src/CardList.java b/src/CardList.java
new file mode 100644
index 00000000000..56518e055f3
--- /dev/null
+++ b/src/CardList.java
@@ -0,0 +1,216 @@
+import java.util.*;
+
+public class CardList implements Iterable
+{
+
+ public Iterator iterator() {
+ return list.iterator();
+ }
+
+ private ArrayList list = new ArrayList();
+ //private LinkedList list = new LinkedList();
+
+ public CardList() {}
+ public CardList(Card c[]) { addAll(c);}
+ public CardList(Object c[]) {addAll(c);}
+
+// cardColor is like "R" or "G", returns a new CardList that is a subset of current CardList
+ public CardList getColor(String cardColor)
+ {
+ CardList c = new CardList();
+ Card card;
+ for(int i = 0; i < size(); i++)
+ {
+ card = getCard(i);
+
+ if(0 < card.getManaCost().indexOf(cardColor))//hopefully this line works
+ c.add(getCard(i));
+ }
+ return c;
+ }//getColor()
+
+ public void reverse()
+ {
+ Collections.reverse(list);
+ }
+
+ public boolean equals(CardList a)
+ {
+ if(list.size() != a.size())
+ return false;
+
+ for(int i = 0; i < list.size(); i++)
+ if(! list.get(i).equals(a.get(i)))
+ return false;
+
+ return true;
+ }
+
+ //removes one copy of that card
+ public void remove(final String cardName)
+ {
+ CardList find = this.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return c.getName().equals(cardName);
+ }
+ });
+
+ if(0 < find.size())
+ this.remove(find.get(0));
+ else
+ throw new RuntimeException("CardList : remove(String cardname), error - card name not found: " +cardName +" - contents of Arraylist:" +list);
+
+ }//remove(String cardName)
+
+ public int size() {return list.size();}
+ public void add(Card c) {list.add(c);}
+ public void add(int n, Card c) {list.add(n, c);}
+ public boolean contains(Card c) {return list.contains(c);}
+
+ //probably remove getCard() in the future
+ public Card getCard(int index){return (Card)list.get(index);}
+ public Card get(int i) {return getCard(i);}
+
+ public void addAll(Object c[])
+ {
+ for(int i = 0; i < c.length; i++)
+ list.add((Card)c[i]);
+ }
+ public boolean containsName(Card c)
+ {
+ return containsName(c.getName());
+ }
+ public boolean containsName(String name)
+ {
+ for(int i = 0; i < size(); i++)
+ if(getCard(i).getName().equals(name))
+ return true;
+
+ return false;
+ }
+ //returns new subset of all the cards with the same name
+ public CardList getName(String name)
+ {
+ CardList c = new CardList();
+
+ for(int i = 0; i < size(); i++)
+ if(getCard(i).getName().equals(name))
+ c.add(getCard(i));
+
+ return c;
+ }
+ //cardType is like "Land" or "Goblin", returns a new CardList that is a subset of current CardList
+ public CardList getType(String cardType)
+ {
+ CardList c = new CardList();
+ Card card;
+ for(int i = 0; i < size(); i++)
+ {
+ card = getCard(i);
+ if(card.getType().contains(cardType) ||
+ ( (card.isCreature() || (card.isTribal() && !cardType.equals("Creature")) ) && !cardType.equals("Legendary") && !cardType.equals("Planeswalker") && !cardType.equals("Basic") &&
+ !cardType.equals("Enchantment") && !cardType.equals("Land") && !cardType.equals("Sorcery") && !cardType.equals("Instant") &&
+ !cardType.equals("Artifact") && !cardType.equals("Plains") && !cardType.equals("Mountain") && !cardType.equals("Island") &&
+ !cardType.equals("Forest") && !cardType.equals("Swamp") && card.getKeyword().contains("Changeling") ) )//changelings, see Lorwyn FAQ
+ c.add(getCard(i));
+ }
+ return c;
+ }//getType()
+ public CardList filter(CardListFilter f)
+ {
+ CardList c = new CardList();
+ for(int i = 0; i < size(); i++)
+ if(f.addCard(getCard(i)))
+ c.add(getCard(i));
+
+ return c;
+ }
+ public final Card[] toArray()
+ {
+ Card[] c = new Card[list.size()];
+ list.toArray(c);
+ return c;
+ }
+ public String toString() {return list.toString();}
+ public boolean isEmpty() {return list.isEmpty();}
+ public Card remove(int i) {return (Card)list.remove(i);}
+ public void remove(Card c) {list.remove(c);}
+ public void clear() {list.clear();}
+
+ public void shuffle()
+ {
+ Collections.shuffle(list, MyRandom.random);
+ Collections.shuffle(list, MyRandom.random);
+ Collections.shuffle(list, MyRandom.random);
+ }
+
+ public void sort(Comparator c) {Collections.sort(list, c);}
+
+ public CardList getValidCards(String Restrictions[])
+ {
+ CardList tmpList = new CardList(toArray());
+ CardList retList = new CardList();
+
+ for (int i=0;i 1)
+ {
+ final String excR = incR[1];
+ tmpList = tmpList.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ boolean r = true;
+ String exR[] = excR.split("\\+"); // Exclusive Restrictions are ...
+ for (int j=0;j 1);
+ else if (exR[j].contains("with")) // ... Card keywords
+ if (exR[j].startsWith("without"))
+ r = r && (! c.getKeyword().contains(exR[j].substring(7)));
+ else
+ r = r && (c.getKeyword().contains(exR[j].substring(4)));
+ //TODO: converted mana cost
+ //TODO: tapped
+ //TODO: enchanted
+ //TODO: enchanting
+ //TODO: token
+ //TODO: counters
+ else
+ if (exR[j].startsWith("non")) // ... Other Card types
+ r = r && (! c.getType().contains(exR[j].substring(3)));
+ else
+ r = r && (c.getType().contains(exR[j]));
+ }
+ return r;
+ }
+ });
+ }
+ retList.addAll(tmpList.toArray());
+ }
+ return retList;
+ }//getValidCards
+
+
+}
\ No newline at end of file
diff --git a/src/CardListFilter.java b/src/CardListFilter.java
new file mode 100644
index 00000000000..0ba3aa2f3e5
--- /dev/null
+++ b/src/CardListFilter.java
@@ -0,0 +1,4 @@
+public interface CardListFilter
+{
+ public boolean addCard(Card c);
+}
diff --git a/src/CardListUtil.java b/src/CardListUtil.java
new file mode 100644
index 00000000000..fadaf89f1d9
--- /dev/null
+++ b/src/CardListUtil.java
@@ -0,0 +1,183 @@
+import java.util.*;
+
+public class CardListUtil
+{
+ public static CardList filterToughness(CardList in, int atLeastToughness)
+ {
+ CardList out = new CardList();
+ for(int i = 0; i < in.size(); i++)
+ if(in.get(i).getNetDefense() <= atLeastToughness)
+ out.add(in.get(i));
+
+ return out;
+ }
+
+ //the higher the defense the better
+ @SuppressWarnings("unchecked") // Comparator needs
+public static void sortDefense(CardList list)
+ {
+ Comparator com = new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ return b.getNetDefense() - a.getNetDefense();
+ }
+ };
+ list.sort(com);
+ }//sortDefense()
+
+ //the higher the attack the better
+ @SuppressWarnings("unchecked") // Comparator needs type
+public static void sortAttack(CardList list)
+ {
+ Comparator com = new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ if (CombatUtil.isDoranInPlay())
+ return b.getNetDefense() - a.getNetDefense();
+ else
+ return b.getNetAttack() - a.getNetAttack();
+ }
+ };
+ list.sort(com);
+ }//sortAttack()
+
+
+ //the lower the attack the better
+ @SuppressWarnings("unchecked") // Comparator needs
+public static void sortAttackLowFirst(CardList list)
+ {
+ Comparator com = new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ if (CombatUtil.isDoranInPlay())
+ return a.getNetDefense() - b.getNetDefense();
+ else
+ return a.getNetAttack() - b.getNetAttack();
+ }
+ };
+ list.sort(com);
+ }//sortAttackLowFirst()
+
+ public static void sortNonFlyingFirst(CardList list)
+ {
+ sortFlying(list);
+ list.reverse();
+ }//sortNonFlyingFirst
+
+ //the creature with flying are better
+ @SuppressWarnings("unchecked") // Comparator needs
+public static void sortFlying(CardList list)
+ {
+ Comparator com = new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ if(a.getKeyword().contains("Flying") && b.getKeyword().contains("Flying"))
+ return 0;
+ else if(a.getKeyword().contains("Flying"))
+ return -1;
+ else if(b.getKeyword().contains("Flying"))
+ return 1;
+
+ return 0;
+ }
+ };
+ list.sort(com);
+ }//sortFlying()
+
+ @SuppressWarnings("unchecked") // Comparator needs
+ public static void sortCMC(CardList list)
+ {
+ Comparator com = new Comparator()
+ {
+ public int compare(Object a1, Object b1)
+ {
+ Card a = (Card)a1;
+ Card b = (Card)b1;
+
+ int cmcA = CardUtil.getConvertedManaCost(a.getManaCost());
+ int cmcB = CardUtil.getConvertedManaCost(b.getManaCost());
+
+ if (cmcA == cmcB)
+ return 0;
+ if (cmcA > cmcB)
+ return -1;
+ if (cmcB > cmcA)
+ return 1;
+
+ return 0;
+ }
+ };
+ list.sort(com);
+ }//sortCMC
+
+
+ public static CardList getColor(CardList list, final String color)
+ {
+ return list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return CardUtil.getColor(c).equals(color);
+ }
+ });
+ }//getColor()
+
+ public static CardList getGoldCards(CardList list)
+ {
+ return list.filter(new CardListFilter()
+ {
+ public boolean addCard(Card c)
+ {
+ return CardUtil.getColors(c).size() >= 2;
+ }
+ });
+ }
+
+ public static int sumAttack(CardList c)
+ {
+ int attack = 0;
+
+ for(int i = 0; i < c.size(); i++){
+ if(c.get(i).isCreature() && (!c.get(i).hasFirstStrike() || (c.get(i).hasDoubleStrike() && c.get(i).hasFirstStrike())) ) {
+ if (!CombatUtil.isDoranInPlay())
+ attack += c.get(i).getNetAttack();
+ else if(CombatUtil.isDoranInPlay())
+ attack += c.get(i).getNetDefense();
+ }
+ }
+ //System.out.println("Total attack: " +attack);
+ return attack;
+ }//sumAttack()
+
+ public static int sumFirstStrikeAttack(CardList c)
+ {
+ int attack = 0;
+
+ for(int i = 0; i < c.size(); i++){
+ if(c.get(i).isCreature() && (c.get(i).hasFirstStrike() || c.get(i).hasDoubleStrike())) {
+ if (!CombatUtil.isDoranInPlay())
+ attack += c.get(i).getNetAttack();
+ else if(CombatUtil.isDoranInPlay())
+ attack += c.get(i).getNetDefense();
+ }
+ }
+ System.out.println("Total First Strike attack: " +attack);
+ return attack;
+ }//sumFirstStrikeAttack()
+}
\ No newline at end of file
diff --git a/src/CardPanel.java b/src/CardPanel.java
new file mode 100644
index 00000000000..949422e2951
--- /dev/null
+++ b/src/CardPanel.java
@@ -0,0 +1,20 @@
+import javax.swing.*;
+
+public class CardPanel extends JPanel
+{
+ private static final long serialVersionUID = 509877513760665415L;
+private Card card;
+
+ public CardPanel(Card card)
+ {
+ this.card = card;
+ }
+ public Card getCard()
+ {
+ return card;
+ }
+
+ //~
+ public CardPanel connectedCard;
+ //~
+}
diff --git a/src/CardUtil.java b/src/CardUtil.java
new file mode 100644
index 00000000000..e0b88b0ba4e
--- /dev/null
+++ b/src/CardUtil.java
@@ -0,0 +1,184 @@
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+public class CardUtil
+{
+ public final static Random r = new Random();
+
+
+ public static int getRandomIndex(Object[] o)
+ {
+ if(o == null || o.length == 0)
+ throw new RuntimeException("CardUtil : getRandomIndex() argument is null or length is 0");
+
+ return r.nextInt(o.length);
+ }
+ public static Card getRandom(Card[] o)
+ {
+ return o[getRandomIndex(o)];
+ }
+ public static int getRandomIndex(SpellAbilityList list)
+ {
+ if(list == null || list.size() == 0)
+ throw new RuntimeException("CardUtil : getRandomIndex(SpellAbilityList) argument is null or length is 0");
+
+ return r.nextInt(list.size());
+ }
+ public static int getRandomIndex(CardList c)
+ {return r.nextInt(c.size());}
+
+ //returns Card Name (unique number) attack/defense
+ //example: Big Elf (12) 2/3
+ public static String toText(Card c)
+ {
+ return c.getName() +" (" +c.getUniqueNumber() +") " +c.getNetAttack() +"/" +c.getNetDefense();
+ }
+ public static Card[] toCard(Collection col)
+ {
+ Object o[] = col.toArray();
+ Card c[] = new Card[o.length];
+
+ for(int i = 0; i < c.length; i++)
+ {
+ Object swap = o[i];
+ if(swap instanceof Card)
+ c[i] = (Card)o[i];
+ else
+ throw new RuntimeException("CardUtil : toCard() invalid class, should be Card - " +o[i].getClass() +" - toString() - " +o[i].toString());
+ }
+
+ return c;
+ }
+ public static Card[] toCard(ArrayList list)
+ {
+ Card[] c = new Card[list.size()];
+ list.toArray(c);
+ return c;
+ }
+ public static ArrayList toList(Card c[])
+ {
+ ArrayList a = new ArrayList();
+ for(int i = 0; i < c.length; i++)
+ a.add(c[i]);
+ return a;
+ }
+ //returns "G", longColor is Constant.Color.Green and the like
+ public static String getShortColor(String longColor)
+ {
+ Map map = new HashMap();
+ map.put(Constant.Color.Black, "B");
+ map.put(Constant.Color.Blue , "U");
+ map.put(Constant.Color.Green, "G");
+ map.put(Constant.Color.Red , "R");
+ map.put(Constant.Color.White, "W");
+
+ Object o = map.get(longColor);
+ if(o == null)
+ throw new RuntimeException("CardUtil : getShortColor() invalid argument - " +longColor);
+
+ return (String)o;
+ }
+
+
+ //returns something like Constant.Color.Green or something
+ public static String getColor(Card c)
+ {
+ String manaCost = c.getManaCost();
+
+ if(-1 != manaCost.indexOf("G"))
+ return Constant.Color.Green;
+ else if(-1 != manaCost.indexOf("W"))
+ return Constant.Color.White;
+ else if(-1 != manaCost.indexOf("B"))
+ return Constant.Color.Black;
+ else if(-1 != manaCost.indexOf("U"))
+ return Constant.Color.Blue;
+ else if(-1 != manaCost.indexOf("R"))
+ return Constant.Color.Red;
+ else
+ return Constant.Color.Colorless;
+ }
+ public static ArrayList getColors(Card c)
+ {
+ String m = c.getManaCost();
+ Set colors = new HashSet();
+
+ for(int i = 0; i < m.length(); i++)
+ {
+ switch(m.charAt(i))
+ {
+ case ' ': break;
+ case 'G': colors.add(Constant.Color.Green); break;
+ case 'W': colors.add(Constant.Color.White); break;
+ case 'B': colors.add(Constant.Color.Black); break;
+ case 'U': colors.add(Constant.Color.Blue); break;
+ case 'R': colors.add(Constant.Color.Red); break;
+ }
+ }
+ if(colors.isEmpty())
+ colors.add(Constant.Color.Colorless);
+
+ return new ArrayList(colors);
+ }
+ public static boolean hasCardName(String cardName, ArrayList list)
+ {
+ Card c;
+ boolean b = false;
+
+ for(int i = 0; i < list.size(); i++)
+ {
+ c = (Card)list.get(i);
+ if(c.getName().equals(cardName))
+ {
+ b = true;
+ break;
+ }
+ }
+ return b;
+ }//hasCardName()
+
+ //probably should put this somewhere else, but not sure where
+ static public int getConvertedManaCost(SpellAbility sa)
+ {
+ return getConvertedManaCost(sa.getManaCost());
+ }
+
+ static public int getConvertedManaCost(String manaCost)
+ {
+ //see if the mana cost is all colorless, like "2", "0", or "12"
+
+ if(manaCost.equals(""))
+ return 0;
+
+ if (!manaCost.matches(".*[A-Z]+.*"))
+ {
+ try{
+ return Integer.parseInt(manaCost);
+ }
+ catch(NumberFormatException ex) { ErrorViewer.showError(ex); }
+ }
+
+ //see if mana cost is colored and colorless like "2 B" or "1 U U"
+ StringTokenizer tok = new StringTokenizer(manaCost);
+ int cost = 0;
+ try{
+ //get the int from the mana cost like "1 U", get the 1
+ cost = Integer.parseInt(tok.nextToken());
+ //count colored mana cost
+ cost += tok.countTokens();
+ return cost;
+ }
+ //catches in case the cost has no colorless mana requirements like "U U"
+ catch(NumberFormatException ex) {}
+
+ //the mana cost is all colored mana like "U" or "B B B"
+ tok = new StringTokenizer(manaCost);
+ return tok.countTokens();
+ }
+}
\ No newline at end of file
diff --git a/src/Combat.java b/src/Combat.java
new file mode 100644
index 00000000000..4aa94b623f8
--- /dev/null
+++ b/src/Combat.java
@@ -0,0 +1,409 @@
+import java.util.*;
+
+public class Combat
+{
+ //key is attacker Card
+ //value is CardList of blockers
+ private Map map = new HashMap();
+ private Set blocked = new HashSet