From 5d092225b101ab27d56cada95f093cfbc2bb5561 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 13:37:31 +0000 Subject: [PATCH] add Tangle Wire (from Nemesis) - should be the last large piece for the Tinker decks. --- .gitattributes | 1 + res/cardsfolder/tangle_wire.txt | 8 ++++++ src/forge/CardFactoryUtil.java | 47 ++++++++++++++++++++++++++++++-- src/forge/GameActionUtil.java | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 res/cardsfolder/tangle_wire.txt diff --git a/.gitattributes b/.gitattributes index 503e9acbd17..bb27786b7f6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4796,6 +4796,7 @@ res/cardsfolder/talruum_minotaur.txt -text svneol=native#text/plain res/cardsfolder/tangle_asp.txt -text svneol=native#text/plain res/cardsfolder/tangle_golem.txt -text svneol=native#text/plain res/cardsfolder/tangle_spider.txt -text svneol=native#text/plain +res/cardsfolder/tangle_wire.txt -text svneol=native#text/plain res/cardsfolder/tanglebloom.txt -text svneol=native#text/plain res/cardsfolder/taoist_hermit.txt -text svneol=native#text/plain res/cardsfolder/taoist_mystic.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/tangle_wire.txt b/res/cardsfolder/tangle_wire.txt new file mode 100644 index 00000000000..e2177f5288b --- /dev/null +++ b/res/cardsfolder/tangle_wire.txt @@ -0,0 +1,8 @@ +Name:Tangle Wire +ManaCost:3 +Types:Artifact +Text:At the beginning of each player's upkeep, that player taps an untapped artifact, creature, or land he or she controls for each fade counter on CARDNAME. +K:Fading:4 +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/tangle_wire.jpg +End \ No newline at end of file diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 6b9b9198878..206e593f79d 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -590,7 +590,7 @@ public class CardFactoryUtil { return biggest; } - //returns null if list.size() == 0 + //returns null if list.size() == 0 public static Card AI_getWorstCreature(CardList list) { CardList all = list; all = all.getType("Creature"); @@ -606,6 +606,45 @@ public class CardFactoryUtil { return smallest; } + public static Card AI_getWorstPermanent(final CardList list, boolean biasEnch, boolean biasLand, boolean biasArt, boolean biasCreature) { + if(list.size() == 0) return null; + + if(biasEnch && list.getType("Enchantment").size() > 0) { + return AI_getCheapestPermanent(list.getType("Enchantment"), null, false); + } + + if(biasArt && list.getType("Artifact").size() > 0) { + return AI_getCheapestPermanent(list.getType("Artifact"), null, false); + } + + if(biasLand && list.getType("Land").size() > 0) { + return getWorstLand(list.getType("Land")); + } + + if(biasCreature && list.getType("Creature").size() > 0) { + return AI_getWorstCreature(list.getType("Creature")); + } + + if(list.getType("Land").size() > 6) { + return getWorstLand(list.getType("Land")); + } + + if(list.getType("Artifact").size() > 0 || list.getType("Enchantment").size() > 0) { + return AI_getCheapestPermanent(list.filter(new CardListFilter() { + public boolean addCard(Card c) { + return c.isArtifact() || c.isEnchantment(); + } + }), null, false); + } + + if(list.getType("Creature").size() > 0) { + return AI_getWorstCreature(list.getType("Creature")); + } + + //Planeswalkers fall through to here, lands will fall through if there aren't very many + return AI_getCheapestPermanent(list, null, false); + } + public static Input input_targetCreaturePlayer(final SpellAbility spell, boolean targeted, boolean free) { return input_targetCreaturePlayer(spell, Command.Blank, targeted, free); } @@ -4464,8 +4503,12 @@ public class CardFactoryUtil { * @return the worst land found based on the description above */ public static Card getWorstLand(Player player) { - Card worstLand = null; CardList lands = AllZoneUtil.getPlayerLandsInPlay(player); + return getWorstLand(lands); + }//end getWorstLand + + public static Card getWorstLand(CardList lands) { + Card worstLand = null; //first, check for tapped, basic lands for( int i = 0; i < lands.size(); i++ ) { Card tmp = lands.get(i); diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 0075f9f7b0b..d410afcd707 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -48,6 +48,7 @@ public class GameActionUtil { upkeep_Honden_of_Infinite_Rage(); upkeep_Vensers_Journal(); upkeep_Land_Tax(); + upkeep_Tangle_Wire(); upkeep_Mana_Vault(); upkeep_Feedback(); upkeep_Farmstead(); @@ -10114,6 +10115,53 @@ public class GameActionUtil { AllZone.Stack.add(ability); }//foreach(Card) }//upkeep_Shapeshifter + + private static void upkeep_Tangle_Wire() { + final Player player = AllZone.Phase.getPlayerTurn(); + CardList wires = AllZoneUtil.getCardsInPlay("Tangle Wire"); + + for(final Card source:wires) { + SpellAbility ability = new Ability(source, "0") { + @Override + public void resolve() { + final int num = source.getCounters(Counters.FADE); + final CardList list = AllZoneUtil.getPlayerCardsInPlay(player).filter(new CardListFilter() { + public boolean addCard(Card c) { + return (c.isArtifact() || c.isLand() || c.isEnchantment()) && c.isUntapped(); + } + }); + for(int i = 0; i < num; i++) { + if(player.isComputer()) { + Card toTap = CardFactoryUtil.AI_getWorstPermanent(list, false, false, false, false); + if(null != toTap) { + toTap.tap(); + list.remove(toTap); + } + } + else { + AllZone.InputControl.setInput(new Input() { + private static final long serialVersionUID = 5313424586016061612L; + public void showMessage() { + if(list.size() == 0) stop(); + AllZone.Display.showMessage(source.getName()+" - Select "+num+" untapped artifact(s), creature(s), or land(s) you control"); + ButtonUtil.disableAll(); + } + public void selectCard(Card card, PlayerZone zone) { + if(zone.is(Constant.Zone.Battlefield, AllZone.HumanPlayer) && list.contains(card)) { + card.tap(); + list.remove(card); + stop(); + } + } + }); + } + } + } + }; + ability.setStackDescription(source.getName()+" - "+player+" taps X artifacts, creatures or lands he or she controls."); + AllZone.Stack.add(ability); + }//foreach(wire) + }//upkeep_Tangle_Wire() private static void upkeep_Pillory_of_the_Sleepless() { final Player player = AllZone.Phase.getPlayerTurn();