From 226e335aacbaa09e8a7a26a29ee6e41c64a1ade5 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 04:41:36 +0000 Subject: [PATCH] - Added Life from the Loam (based on Ranger of Eos code). - Some other fixes (can't remember exactly). --- res/cards.txt | 6 ++ src/forge/CardFactory.java | 99 ++++++++++++++++++++++++++++++++ src/forge/CardFactory_Lands.java | 7 +++ src/forge/CardListUtil.java | 21 +++++++ src/forge/Input_Mulligan.java | 3 + 5 files changed, 136 insertions(+) diff --git a/res/cards.txt b/res/cards.txt index de62b9ecd4c..db6f8ac599a 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,9 @@ +Life from the Loam +1 G +Sorcery +Return up to three target land cards from your graveyard to your hand. +Dredge 3 + Sedraxis Specter U B R Creature Specter diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index a1be8428b2c..073a0e230b3 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -20895,6 +20895,105 @@ public class CardFactory implements NewConstants { }//*************** END ************ END ************************** + //*************** START *********** START ************************** + if(cardName.equals("Life from the Loam")) { + final SpellAbility spell = new Spell(card) { + + private static final long serialVersionUID = 9071771496065272936L; + + @Override + public void resolve() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); + PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController()); + + CardList cards = new CardList(grave.getCards()); + CardList lands = new CardList(); + + for(int i = 0; i < cards.size(); i++) { + if(cards.get(i).getType().contains("Land")) { + lands.add(cards.get(i)); + } + } + + String controller = card.getController(); + + if(lands.size() == 0) return; + + if(controller.equals(Constant.Player.Human)) { + Object o = AllZone.Display.getChoiceOptional("Select First Land", lands.toArray()); + if(o != null) { + //ability.setTargetCard((Card)o); + //AllZone.Stack.add(ability); + Card c1 = (Card) o; + grave.remove(c1); + hand.add(c1); + lands.remove(c1); + + if(lands.size() == 0) return; + + o = AllZone.Display.getChoiceOptional("Select Second Land", lands.toArray()); + + if(o != null) { + Card c2 = (Card) o; + grave.remove(c2); + hand.add(c2); + lands.remove(c2); + + if(lands.size() == 0) return; + + o = AllZone.Display.getChoiceOptional("Select Third Land", lands.toArray()); + + if(o != null) { + Card c3 = (Card) o; + grave.remove(c3); + hand.add(c3); + lands.remove(c3); + } + } + } + AllZone.GameAction.shuffle(controller); + } else //computer + { + lands.shuffle(); + if(lands.size() >= 1) { + Card c1 = lands.getCard(0); + grave.remove(c1); + hand.add(c1); + lands.remove(c1); + + if(lands.size() >= 1) { + Card c2 = lands.getCard(0); + grave.remove(c2); + hand.add(c2); + lands.remove(c2); + + if(lands.size() >= 1) { + Card c3 = lands.getCard(0); + grave.remove(c3); + hand.add(c3); + lands.remove(c3); + + } + } + + } + //ability.setTargetCard(powerTwoCreatures.get(0)); + //AllZone.Stack.add(ability); + AllZone.GameAction.shuffle(controller); + } + + + //... + + }//resolve() + }; + card.clearSpellAbility(); + card.addSpellAbility(spell); + + + }//*************** END ************ END ************************** + + // Cards with Cycling abilities // -1 means keyword "Cycling" not found if(hasKeyword(card, "Cycling") != -1) { diff --git a/src/forge/CardFactory_Lands.java b/src/forge/CardFactory_Lands.java index 6592056c54e..50ffd5465b4 100644 --- a/src/forge/CardFactory_Lands.java +++ b/src/forge/CardFactory_Lands.java @@ -940,6 +940,7 @@ class CardFactory_Lands { return c.getType().contains(land1[0]) || c.getType().contains(land2[0]); } }); + if(super.canPlay() && list.size() > 0 && AllZone.GameAction.isCardInPlay(card)) return true; else return false; @@ -964,6 +965,12 @@ class CardFactory_Lands { } }); + + CardListUtil.sortBySelectable(full, land1[0]); + + for (Card c:full) + System.out.println(c); + Object o = AllZone.Display.getChoiceOptional("Choose a " + land1[0] + " or " + land2[0], full.toArray()); if(o != null) { diff --git a/src/forge/CardListUtil.java b/src/forge/CardListUtil.java index a02b69b803f..a70a462ef16 100644 --- a/src/forge/CardListUtil.java +++ b/src/forge/CardListUtil.java @@ -208,6 +208,27 @@ public class CardListUtil list.sort(com); } + public static void sortBySelectable(CardList list, String type) + { + final String t = type; + Comparator com = new Comparator() + { + public int compare(Card a, Card b) + { + if( a.getType().contains(t) && b.getType().contains(t)) + return 0; + else if(a.getKeyword().contains(t)) + return 1; + else if(b.getKeyword().contains(t)) + return -1; + + return 0; + } + }; + list.sort(com); + } + + //Sorts from high to low public static void sortCMC(CardList list) { diff --git a/src/forge/Input_Mulligan.java b/src/forge/Input_Mulligan.java index a3c0c4fc78b..fb3638514f5 100644 --- a/src/forge/Input_Mulligan.java +++ b/src/forge/Input_Mulligan.java @@ -23,6 +23,8 @@ public class Input_Mulligan extends Input { @Override public void selectButtonCancel() { + AllZone.GameInfo.setHumanMulliganedToZero(false); + Card[] hand = AllZone.Human_Hand.getCards(); for(int i = 0; i < hand.length; i++) { AllZone.Human_Library.add(hand[i]); @@ -34,6 +36,7 @@ public class Input_Mulligan extends Input { int newHand = hand.length - 1; + AllZone.GameInfo.addHumanNumberOfTimesMulliganed(1); //System.out.println("Mulliganed this turn:" + AllZone.GameInfo.getHumanNumberOfTimesMulliganed());