From 50bf5ca9dbd09195418bc6cbe3828409c8eefb68 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 11:06:28 +0000 Subject: [PATCH] -add support to AF_GainControl to destroy target on certain conditions. -add Merieke Ri Berit (from Ice Age) --- .gitattributes | 1 + res/cardsfolder/merieke_ri_berit.txt | 10 ++++ src/forge/AbilityFactory_GainControl.java | 56 ++++++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 res/cardsfolder/merieke_ri_berit.txt diff --git a/.gitattributes b/.gitattributes index b1e5c436ac0..8759147383d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2881,6 +2881,7 @@ res/cardsfolder/merfolk_of_the_pearl_trident.txt -text svneol=native#text/plain res/cardsfolder/merfolk_seastalkers.txt -text svneol=native#text/plain res/cardsfolder/merfolk_seer.txt -text svneol=native#text/plain res/cardsfolder/merfolk_sovereign.txt -text svneol=native#text/plain +res/cardsfolder/merieke_ri_berit.txt -text svneol=native#text/plain res/cardsfolder/merrow_grimeblotter.txt -text svneol=native#text/plain res/cardsfolder/merrow_harbinger.txt -text svneol=native#text/plain res/cardsfolder/merrow_levitator.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/merieke_ri_berit.txt b/res/cardsfolder/merieke_ri_berit.txt new file mode 100644 index 00000000000..f7b9700914b --- /dev/null +++ b/res/cardsfolder/merieke_ri_berit.txt @@ -0,0 +1,10 @@ +Name:Merieke Ri Berit +ManaCost:W U B +Types:Legendary Creature Human +Text:no text +PT:1/1 +K:CARDNAME doesn't untap during your untap step. +A:AB$GainControl|Cost$T|Tgt$TgtC|LoseControl$LeavesPlay,LoseControl|DestroyTgt$LeavesPlay,LoseControl,Untap|NoRegen$True|SpellDescription$Gain control of target creature for as long as you control CARDNAME. When CARDNAME leaves the battlefield or becomes untapped, destroy that creature. It can't be regenerated. +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/merieke_ri_berit.jpg +End diff --git a/src/forge/AbilityFactory_GainControl.java b/src/forge/AbilityFactory_GainControl.java index 9e0d44fe86d..4a0387a33d3 100644 --- a/src/forge/AbilityFactory_GainControl.java +++ b/src/forge/AbilityFactory_GainControl.java @@ -4,16 +4,19 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$[Untap],[PowerGT],[LoseControl]|UntilEOT$True|SpellDescription$Gain control of target xxxxxxx +//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|UntilEOT$True|SpellDescription$Gain control of target xxxxxxx //GainControl specific params: // LoseControl - the lose control conditions (as a comma separated list) // -Untap - source card becomes untapped // -LoseControl - you lose control of source card +// -LeavesPlay - source card leaves the battlefield // -PowerGT - (not implemented yet for Old Man of the Sea) // AddKWs - Keywords to add to the controlled card (as a "&"-separated list; like Haste, Sacrifice CARDNAME at EOT, any standard keyword) // OppChoice - set to True if opponent chooses creature (for Preacher) - not implemented yet // Untap - set to True if target card should untap when control is taken +// DestroyTgt - actions upon which the tgt should be destroyed. same list as LoseControl +// NoRegen - set if destroyed creature can't be regenerated. used only with DestroyTgt public class AbilityFactory_GainControl { @@ -23,6 +26,8 @@ public class AbilityFactory_GainControl { private HashMap params = null; private Card hostCard = null; private ArrayList lose = null; + private ArrayList destroyOn = null; + private boolean bNoRegen = false; private boolean bUntap = false; private boolean bTapOnLose = false; private ArrayList kws = null; @@ -43,6 +48,12 @@ public class AbilityFactory_GainControl { if(params.containsKey("AddKWs")) { kws = new ArrayList(Arrays.asList(params.get("AddKWs").split(" & "))); } + if (params.containsKey("DestroyTgt")) { + destroyOn = new ArrayList(Arrays.asList(params.get("DestroyTgt").split(","))); + } + if(params.containsKey("NoRegen")) { + bNoRegen = true; + } } public SpellAbility getSpell() { @@ -208,13 +219,25 @@ public class AbilityFactory_GainControl { if(lose.contains("Untap")) { hostCard.addUntapCommand(getLoseControlCommand(j)); } - if(lose.contains("ChangeController")) { + if(lose.contains("LoseControl")) { hostCard.addChangeControllerCommand(getLoseControlCommand(j)); } if(lose.contains("EOT")) { AllZone.EndOfTurn.addAt(getLoseControlCommand(j)); } } + + if (destroyOn != null){ + if(destroyOn.contains("LeavesPlay")) { + hostCard.addLeavesPlayCommand(getDestroyCommand(j)); + } + if(destroyOn.contains("Untap")) { + hostCard.addUntapCommand(getDestroyCommand(j)); + } + if(destroyOn.contains("LoseControl")) { + hostCard.addChangeControllerCommand(getDestroyCommand(j)); + } + } }//end foreach target @@ -230,6 +253,35 @@ public class AbilityFactory_GainControl { } + private Command getDestroyCommand(final int i) { + final Command destroy = new Command() { + private static final long serialVersionUID = 878543373519872418L; + + public void execute() { + final Card c = movedCards[i]; + Ability ability = new Ability(hostCard, "0") { + public void resolve() { + + if(bNoRegen) { + AllZone.GameAction.destroyNoRegeneration(c); + } + else { + AllZone.GameAction.destroy(c); + } + } + }; + StringBuilder sb = new StringBuilder(); + sb.append(hostCard).append(" - destroy ").append(c.getName()).append("."); + if(bNoRegen) sb.append(" It can't be regenerated."); + ability.setStackDescription(sb.toString()); + + AllZone.Stack.add(ability); + } + + }; + return destroy; + } + private Command getLoseControlCommand(final int i) { final Command loseControl = new Command() { private static final long serialVersionUID = 878543373519872418L;