From 6da0ac6b9ebcdb35ee728391a36c60fffd1eef8c Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:15:49 +0000 Subject: [PATCH] - Black Lotus will get sacked before its ability resolves. - Hopefully fixed Thopter Foundry for AI. --- res/main.properties | 2 +- src/forge/Card.java | 13 +++++++++++ src/forge/CardFactory.java | 34 +++++++++++++++++++++++----- src/forge/CardFactory_Creatures.java | 1 + src/forge/CardFactory_Lands.java | 33 --------------------------- src/forge/GameAction.java | 7 ++++++ src/forge/GameActionUtil.java | 10 ++++---- src/forge/SpellAbility.java | 4 ++++ 8 files changed, 60 insertions(+), 44 deletions(-) diff --git a/res/main.properties b/res/main.properties index 92edb92bd23..70f69493e4b 100644 --- a/res/main.properties +++ b/res/main.properties @@ -1,6 +1,6 @@ program/mail=mtgerror@yahoo.com program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26 -program/version=Forge -- official beta: 10/01/17, SVN revision: 295 +program/version=Forge -- official beta: 10/01/17, SVN revision: 297 tokens--file=AllTokens.txt diff --git a/src/forge/Card.java b/src/forge/Card.java index 6b8e68d2e2f..8985b5290f8 100644 --- a/src/forge/Card.java +++ b/src/forge/Card.java @@ -436,6 +436,19 @@ public class Card extends MyObservable } return res; } + + public ArrayList getAdditionalCostSpells() + { + ArrayList s = new ArrayList(spellAbility); + ArrayList res = new ArrayList(); + + for (SpellAbility sa : s) + { + if (sa.isSpell() && !sa.getAdditionalManaCost().equals("") ) + res.add(sa); + } + return res; + } //shield = regeneration diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index e0188986ba1..64d71fe9a6d 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -6216,6 +6216,7 @@ public class CardFactory implements NewConstants { }//resolve() };//SpellAbility spell_two.setManaCost("4 U U"); + spell_two.setAdditionalManaCost("3"); 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."); @@ -6297,6 +6298,7 @@ public class CardFactory implements NewConstants { } };//SpellAbility spell_two.setManaCost("5 U"); + spell_two.setAdditionalManaCost("5"); spell_one.setDescription("Draw a card."); spell_one.setStackDescription(cardName + " - " +card.getController() + " draws a card."); @@ -6414,6 +6416,7 @@ public class CardFactory implements NewConstants { }//resolve() };//SpellAbility spell_two.setManaCost("4 G"); + spell_two.setManaCost("4"); 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."); @@ -6494,6 +6497,7 @@ public class CardFactory implements NewConstants { spell_one.setManaCost("B"); spell_two.setManaCost("4 B"); + spell_two.setAdditionalManaCost("4"); 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."); @@ -6565,6 +6569,7 @@ public class CardFactory implements NewConstants { spell_one.setManaCost("1 G"); spell_two.setManaCost("4 G"); + spell_two.setAdditionalManaCost("3"); spell_one.setDescription("Put a 1/1 green Saproling token into play."); spell_two.setDescription("Buyback 3 - Pay 4G, put this card into your hand as it resolves."); @@ -15609,7 +15614,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); //*************** START *********** START ************************** else if (cardName.equals("Black Lotus")) { - final SpellAbility ability = new Ability_Tap(card) + final Ability_Tap ability = new Ability_Tap(card, "0") { private static final long serialVersionUID = 8394047173115959008L; @@ -15646,12 +15651,26 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); for (int i = 0; i < 3; i++) mp.addExtrinsicKeyword("ManaPool:"+ color); - AllZone.GameAction.sacrifice(card); + //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"); + + + Input sac = new Input() + { + private static final long serialVersionUID = -4503945947115838818L; + public void showMessage() + { + AllZone.GameAction.sacrifice(card); + ability.resolve(); + stop(); + } + };//Input + ability.setBeforePayMana(sac); + card.addSpellAbility(ability); }//*************** END ************ END ************************** @@ -16421,6 +16440,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }; kicker.setManaCost("8 W W W"); + kicker.setAdditionalManaCost("6"); kicker.setDescription("Kicker 6: If Conqueror's Pledge was kicked, put twelve of those tokens onto the battlefield instead."); kicker.setStackDescription(card.getName() + " - " + card.getController() + " puts twelve 1/1 white Kor Soldier creature tokens onto the battlefield."); @@ -16813,7 +16833,8 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); c = meek.get(0); else c = getArtifact(); - setTargetCard(c); + if (c != null) + setTargetCard(c); } public Card getArtifact() @@ -16827,7 +16848,8 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); { public boolean addCard(Card c) { - return c.isArtifact() && !c.isToken() && (CardUtil.getConvertedManaCost(c.getManaCost()) <= 1 || c.getName().equals("Sword of the Meek")); + return c.isArtifact() && !c.isToken() && (CardUtil.getConvertedManaCost(c.getManaCost()) <= 1 && !c.equals(card) + || c.getName().equals("Sword of the Meek")); } }); @@ -16837,13 +16859,13 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); } else return null; - }//getAttacker() + } public boolean canPlayAI() { String phase = AllZone.Phase.getPhase(); - return phase.equals(Constant.Phase.Main2); + return phase.equals(Constant.Phase.Main2) && getArtifact() != null; } public void resolve() diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 2f7d22a63a8..b5a6181d5d2 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -19497,6 +19497,7 @@ public class CardFactory_Creatures { }; kicker.setManaCost("B B B"); + kicker.setAdditionalManaCost("B"); kicker.setDescription("Kicker B"); kicker.setStackDescription(card.getName() + " - Creature 2/2 (Kicked)"); card.addSpellAbility(kicker); diff --git a/src/forge/CardFactory_Lands.java b/src/forge/CardFactory_Lands.java index 3d220b4bca4..cffa6b13ddf 100644 --- a/src/forge/CardFactory_Lands.java +++ b/src/forge/CardFactory_Lands.java @@ -645,39 +645,6 @@ class CardFactory_Lands { a2[0].setDescription("tap: Target Assembly-Worker gets +1/+1 until end of turn."); - @SuppressWarnings("unused") // target unused - final Input target = new Input() - { - private static final long serialVersionUID = 8913477363141356082L; - - public void showMessage() - { - ButtonUtil.enableOnlyCancel(); - AllZone.Display.showMessage("Select Assembly-Worker to get +1/+1"); - } - 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() && c.getType().contains("Assembly-Worker")) - { - card.tap(); - AllZone.Human_Play.updateObservers(); - - a2[0].setTargetCard(c);//since setTargetCard() changes stack description - a2[0].setStackDescription(c +" gets +1/+1 until EOT"); - - AllZone.InputControl.resetInput(); - AllZone.Stack.add(a2[0]); - } - }//selectCard() - public void selectButtonCancel() - { - card.untap(); - stop(); - } - };//Input target a2[0].setBeforePayMana(CardFactoryUtil.input_targetType(a2[0], "Assembly-Worker")); }//*************** END ************ END ************************** diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index b7bb80a942d..10c7aec05e7 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -1341,6 +1341,13 @@ private int getDifferentLand(CardList list, String land) //SpellAbility[] choices = (SpellAbility[]) c.getSpells().toArray(); ArrayList choices = c.getBasicSpells(); SpellAbility sa; + + //TODO: add Buyback, Kicker, ... , spells here + ArrayList additional = c.getAdditionalCostSpells(); + for (SpellAbility s : additional) + { + + } /* System.out.println(choices.length); for(int i = 0; i < choices.length; i++) diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 9dd34870448..d7b661203da 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -147,7 +147,7 @@ public class GameActionUtil public static void playCard_Cascade(Card c) { - if (c.getKeyword().contains("Cascade") || c.getName().equals("Bituminous Blast")) + if (c.getKeyword().contains("Cascade") || c.getName().equals("Bituminous Blast")) //keyword gets cleared for Bitumonous Blast { final String controller = c.getController(); final PlayerZone lib = AllZone.getZone(Constant.Zone.Library, controller); @@ -181,8 +181,7 @@ public class GameActionUtil AllZone.Display.getChoiceOptional("Revealed cards:", revealed.toArray()); if (cascadedCard != null && !cascadedCard.isUnCastable()) { - revealed.remove(cascadedCard); - + if (cascadedCard.getController().equals(Constant.Player.Human)) { String[] choices = { "Yes", "No" }; @@ -191,8 +190,10 @@ public class GameActionUtil q = AllZone.Display.getChoiceOptional("Cast " + cascadedCard.getName() + "?", choices); if (q != null) { - if (q.equals("Yes")) + if (q.equals("Yes")) { AllZone.GameAction.playCardNoCost(cascadedCard); + revealed.remove(cascadedCard); + } } } else @@ -204,6 +205,7 @@ public class GameActionUtil if (sa.canPlayAI()) { ComputerUtil.playStackFree(sa); + revealed.remove(cascadedCard); break; } } diff --git a/src/forge/SpellAbility.java b/src/forge/SpellAbility.java index c5656c98fc7..5ec65201b8c 100644 --- a/src/forge/SpellAbility.java +++ b/src/forge/SpellAbility.java @@ -14,6 +14,7 @@ public abstract class SpellAbility private String targetPlayer = ""; private String stackDescription = ""; private String manaCost = ""; + private String additionalManaCost= ""; private String type = "Intrinsic"; //set to Intrinsic by default @@ -81,6 +82,9 @@ public void execute(Object o) {}}; public String getManaCost() {return manaCost;} public void setManaCost(String cost) {manaCost = cost;} + + public String getAdditionalManaCost() {return additionalManaCost;} + public void setAdditionalManaCost(String cost) { additionalManaCost = cost; } public boolean isSpell() {return spell; } public boolean isAbility() {return ! isSpell(); }