From 37624e5e65eb61cee856eb5bc82fea2a02b579ff Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 20:03:02 +0000 Subject: [PATCH] - Adding DamageSource$ parameter for AF_DealDamage - Adding Repentance as an example. --- .gitattributes | 1 + res/cardsfolder/repentance.txt | 10 ++++++++++ src/forge/AbilityFactory_DealDamage.java | 21 ++++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 res/cardsfolder/repentance.txt diff --git a/.gitattributes b/.gitattributes index 3a04304a12a..ef20ba2fe22 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5057,6 +5057,7 @@ res/cardsfolder/repay_in_kind.txt -text svneol=native#text/plain res/cardsfolder/repeal.txt -text svneol=native#text/plain res/cardsfolder/repel.txt -text svneol=native#text/plain res/cardsfolder/repel_the_darkness.txt -text svneol=native#text/plain +res/cardsfolder/repentance.txt -text svneol=native#text/plain res/cardsfolder/repentant_blacksmith.txt -text svneol=native#text/plain res/cardsfolder/repentant_vampire.txt -text svneol=native#text/plain res/cardsfolder/repercussion.txt svneol=native#text/plain diff --git a/res/cardsfolder/repentance.txt b/res/cardsfolder/repentance.txt new file mode 100644 index 00000000000..eb32ce68407 --- /dev/null +++ b/res/cardsfolder/repentance.txt @@ -0,0 +1,10 @@ +Name:Repentance +ManaCost:2 W +Types:Sorcery +Text:no text +A:SP$DealDamage | Cost$ 2 W | Tgt$ TgtC | DamageSource$ Targeted | NumDmg$ X | SpellDescription$ Target creature deals damage to itself equal to its power. +SVar:X:Targeted$CardPower +SVar:RemAIDeck:True +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/repentance.jpg +End \ No newline at end of file diff --git a/src/forge/AbilityFactory_DealDamage.java b/src/forge/AbilityFactory_DealDamage.java index 1af8eb97ef1..f49f0afd5fd 100644 --- a/src/forge/AbilityFactory_DealDamage.java +++ b/src/forge/AbilityFactory_DealDamage.java @@ -123,7 +123,15 @@ public class AbilityFactory_DealDamage { if (!(sa instanceof Ability_Sub)) sb.append(name).append(" - "); - sb.append("Deals ").append(dmg).append(" damage to "); + ArrayList definedSources = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams().get("DamageSource"), sa); + Card source = definedSources.get(0); + + if (source != sa.getSourceCard()) + sb.append(source.toString()).append(" deals"); + else + sb.append("Deals"); + + sb.append(" ").append(dmg).append(" damage to "); for(int i = 0; i < tgts.size(); i++){ if (i != 0) @@ -494,15 +502,18 @@ public class AbilityFactory_DealDamage { tgts = saMe.getTarget().getTargets(); boolean targeted = (AF.getAbTgt() != null); + + ArrayList definedSources = AbilityFactory.getDefinedCards(saMe.getSourceCard(), params.get("DamageSource"), saMe); + Card source = definedSources.get(0); for(Object o : tgts){ if (o instanceof Card){ Card c = (Card)o; if(AllZone.GameAction.isCardInPlay(c) && (!targeted || CardFactoryUtil.canTarget(AF.getHostCard(), c))) { if (noPrevention) - c.addDamageWithoutPrevention(dmg, AF.getHostCard()); + c.addDamageWithoutPrevention(dmg, source); else - c.addDamage(dmg, AF.getHostCard()); + c.addDamage(dmg, source); } } @@ -510,9 +521,9 @@ public class AbilityFactory_DealDamage { Player p = (Player) o; if (!targeted || p.canTarget(AF.getHostCard())) { if (noPrevention) - p.addDamageWithoutPrevention(dmg, AF.getHostCard()); + p.addDamageWithoutPrevention(dmg, source); else - p.addDamage(dmg, AF.getHostCard()); + p.addDamage(dmg, source); } } }