From d4e70e72c1bbc3d44e75bdfc6e64b26cb240df8c Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 05:17:28 +0000 Subject: [PATCH] - Added Sun Titan. --- res/cards.txt | 7 +++ src/forge/CardFactory_Creatures.java | 59 +++++++++++++++++++++++++ src/forge/CombatUtil.java | 65 ++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) diff --git a/res/cards.txt b/res/cards.txt index 4da9fe5c831..ee79a70b1f4 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,10 @@ +Sun Titan +4 W W +Creature Giant +Whenever Sun Titan enters the battlefield or attacks, you may return target permanent card with converted mana cost 3 or less from your graveyard to the battlefield. +6/6 +Vigilance + Roc Egg 2 W Creature Bird diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 80babfc4330..5711cc1cf20 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -4113,6 +4113,65 @@ public class CardFactory_Creatures { card.addComesIntoPlayCommand(intoPlay); }//*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Sun Titan")) { + final SpellAbility ability = new Ability(card, "0") { + @Override + public void resolve() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); + if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + play.add(getTargetCard()); + grave.remove(getTargetCard()); + } + }//resolve() + }; + Command intoPlay = new Command() { + + private static final long serialVersionUID = 6483805330273377116L; + + public void execute() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); + CardList graveList = new CardList(grave.getCards()); + graveList = graveList.filter(new CardListFilter() + { + public boolean addCard(Card crd) + { + return crd.isPermanent() && CardUtil.getConvertedManaCost(crd.getManaCost()) <=3; + } + }); + + if(graveList.size() == 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()); + list = list.filter(new CardListFilter(){ + public boolean addCard(Card crd) + { + return crd.isPermanent() && CardUtil.getConvertedManaCost(crd.getManaCost()) <=3; + } + }); + 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 ************************** else if(cardName.equals("Karmic Guide")) { final SpellAbility ability = new Ability(card, "0") { diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index 52f520989e7..1fa13ffa9c9 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -1582,6 +1582,71 @@ public class CombatUtil { }//Primeval Titan + else if(c.getName().equals("Sun Titan") && !c.getCreatureAttackedThisCombat()) { + final Card sun = c; + final Ability ability2 = new Ability(c, "0") { + @Override + public void resolve() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, sun.getController()); + if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, sun.getController()); + play.add(getTargetCard()); + grave.remove(getTargetCard()); + } + } + }; //Ability + + + //ability2.setStackDescription(c.getName() + " - "); + + + Command command = new Command() { + private static final long serialVersionUID = 1658050744890095441L; + + public void execute() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, sun.getController()); + CardList graveList = new CardList(grave.getCards()); + graveList = graveList.filter(new CardListFilter() + { + public boolean addCard(Card crd) + { + return crd.isPermanent() && CardUtil.getConvertedManaCost(crd.getManaCost()) <=3; + } + }); + + if(graveList.size() == 0) return; + + if(sun.getController().equals(Constant.Player.Human)) { + Object o = AllZone.Display.getChoiceOptional("Select target card", grave.getCards()); + if(o != null) { + ability2.setTargetCard((Card) o); + AllZone.Stack.add(ability2); + } + } else//computer + { + CardList list = new CardList(grave.getCards()); + list = list.filter(new CardListFilter(){ + public boolean addCard(Card crd) + { + return crd.isPermanent() && CardUtil.getConvertedManaCost(crd.getManaCost()) <=3; + } + }); + Card best = CardFactoryUtil.AI_getBestCreature(list); + + if(best == null) { + list.shuffle(); + best = list.get(0); + } + ability2.setTargetCard(best); + AllZone.Stack.add(ability2); + } + }//execute() + };//Command + command.execute(); + + }//Sun Titan + + else if(c.getName().equals("Preeminent Captain") && !c.getCreatureAttackedThisCombat()) { System.out.println("Preeminent Captain Attacks"); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getController());