diff --git a/.gitattributes b/.gitattributes index 493e691a5e6..fe321dae8a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4528,6 +4528,7 @@ res/cardsfolder/staunch_defenders.txt -text svneol=native#text/plain res/cardsfolder/steadfast_guard.txt -text svneol=native#text/plain res/cardsfolder/steadfastness.txt -text svneol=native#text/plain res/cardsfolder/steady_progress.txt -text svneol=native#text/plain +res/cardsfolder/steal_artifact.txt -text svneol=native#text/plain res/cardsfolder/steam_blast.txt -text svneol=native#text/plain res/cardsfolder/steam_frigate.txt -text svneol=native#text/plain res/cardsfolder/steam_spitter.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/steal_artifact.txt b/res/cardsfolder/steal_artifact.txt new file mode 100644 index 00000000000..da85b859be7 --- /dev/null +++ b/res/cardsfolder/steal_artifact.txt @@ -0,0 +1,9 @@ +Name:Steal Artifact +ManaCost:2 U U +Types:Enchantment Aura +Text:You control enchanted artifact. +K:Enchant artifact +K:enControlArtifact +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/steal_artifact.jpg +End \ No newline at end of file diff --git a/src/forge/CardFactory_Auras.java b/src/forge/CardFactory_Auras.java index 76c9d3c4a7d..9b898d259dc 100644 --- a/src/forge/CardFactory_Auras.java +++ b/src/forge/CardFactory_Auras.java @@ -34,6 +34,16 @@ class CardFactory_Auras { return -1; } + private static int shouldControlArtifact(Card c) { + ArrayList a = c.getKeyword(); + for (int i = 0; i < a.size(); i++) { + if (a.get(i).toString().startsWith("enControlArtifact")) return i; + //if(a.get(i).toString().startsWith("enControlLand")) return i; + } + + return -1; + } + public static Card getCard(final Card card, String cardName, Player owner) { Command standardUnenchant = new Command() { @@ -2413,6 +2423,150 @@ class CardFactory_Auras { }// SpellAbility spell }// enControlCreature + /* + * For Control Magic type of auras (targeting Land, Artifact, Enchantment) + */ + if (shouldControlArtifact(card) != -1) { + int n = shouldControlArtifact(card); + if (n != -1) { + String parse = card.getKeyword().get(n).toString(); + card.removeIntrinsicKeyword(parse); + + /* + * I borrowed this code from Control Magic aura code + */ + final SpellAbility spell = new Spell(card) { + + @Override + public boolean canPlayAI() { + + if(!super.canPlayAI()) return false; + + CardList tgts = CardFactoryUtil.AI_getHumanArtifact(card, true); + CardListUtil.sortAttack(tgts); + CardListUtil.sortFlying(tgts); + + if (tgts.isEmpty()) return false; + + else { + setTargetCard(tgts.get(0)); + return true; + } + }//canPlayAI() + + @Override + public void resolve() { + PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, 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() { + + 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_Battlefield).setTriggers(false); + ((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false); + + PlayerZone from = AllZone.getZone(crd); + from.remove(crd); + + crd.setController(card.getController()); + + PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); + to.add(crd); + + ((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true); + ((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true); + } + }//execute() + };//Command + + Command onUnEnchant = new Command() { + + 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_Battlefield).setTriggers(false); + ((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false); + + PlayerZone from = AllZone.getZone(crd); + from.remove(crd); + + AllZone.Combat.removeFromCombat(crd); + + Player opp = crd.getController().getOpponent(); + crd.setController(opp); + + PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, opp); + to.add(crd); + + ((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true); + ((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true); + } + } + + }//execute() + };//Command + + Command onLeavesPlay = new Command() { + + public void execute() { + if(card.isEnchanting()) { + Card crd = card.getEnchanting().get(0); + card.unEnchantCard(crd); + } + } + };//Command + + Input runtime = new Input() { + + @Override + public void showMessage() { + CardList perms = AllZoneUtil.getCardsInPlay(); + perms = perms.filter(new CardListFilter() { + public boolean addCard(Card c) { + return c.isArtifact() && CardFactoryUtil.canTarget(card, c); + } + }); + + stopSetNext(CardFactoryUtil.input_targetSpecific(spell, perms, "Select target artifact", true, false)); + } + }; + + card.setSVar("PlayMain1", "TRUE"); + + card.addEnchantCommand(onEnchant); + card.addUnEnchantCommand(onUnEnchant); + card.addLeavesPlayCommand(onLeavesPlay); + + spell.setBeforePayMana(runtime); + }// SpellAbility spell + }// enControlCreature + return card; }