- Added support for "Amount" and "Source" parameters to the PreventDamage static ability.

- Converted Daunting Defender, Energy Field and Energy Storm.
This commit is contained in:
Sloth
2011-09-25 18:24:42 +00:00
parent 5d8e414668
commit f02bb10ab0
5 changed files with 27 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ Name:Daunting Defender
ManaCost:4 W ManaCost:4 W
Types:Creature Human Cleric Types:Creature Human Cleric
Text:no text Text:no text
K:stPreventDamage:Creature.Cleric+YouCtrl:Card:1:If a source would deal damage to a Cleric creature you control, prevent 1 of that damage. S:Mode$ PreventDamage | Target$ Creature.Cleric+YouCtrl | Amount$ 1 | Description$ If a source would deal damage to a Cleric creature you control, prevent 1 of that damage.
PT:3/3 PT:3/3
SVar:Rarity:Common SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/daunting_defender.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/daunting_defender.jpg

View File

@@ -4,7 +4,7 @@ Types:Enchantment
Text:no text Text:no text
T:Mode$ ChangesZone | Origin$ Any | Destination$ Graveyard | ValidCard$ Card.YouOwn | Execute$ TrigSac | TriggerZones$ Battlefield | TriggerDescription$ When a card is put into your graveyard from anywhere, sacrifice CARDNAME. T:Mode$ ChangesZone | Origin$ Any | Destination$ Graveyard | ValidCard$ Card.YouOwn | Execute$ TrigSac | TriggerZones$ Battlefield | TriggerDescription$ When a card is put into your graveyard from anywhere, sacrifice CARDNAME.
SVar:TrigSac:AB$ Sacrifice | Cost$ 0 | Defined$ Self SVar:TrigSac:AB$ Sacrifice | Cost$ 0 | Defined$ Self
K:stPreventDamage:You:Card.YouDontCtrl:All:Prevent all damage that would be dealt to you by sources you don't control. S:Mode$ PreventDamage | Target$ You | Source$ Card.YouDontCtrl | Description$ Prevent all damage that would be dealt to you by sources you don't control.
SVar:RemAIDeck:True SVar:RemAIDeck:True
SVar:Rarity:Rare SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_field.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_field.jpg

View File

@@ -4,8 +4,7 @@ Types:Enchantment
Text:no text Text:no text
K:Cumulative upkeep:1 K:Cumulative upkeep:1
K:Permanents don't untap during their controllers' untap steps:Creature.withFlying K:Permanents don't untap during their controllers' untap steps:Creature.withFlying
K:stPreventDamage:Player:Instant,Sorcery:All:Prevent all damage that would be dealt by instant and sorcery spells. Creatures with flying don't untap during their controller's untap step. S:Mode$ PreventDamage | Source$ Instant,Sorcery | Description$ Prevent all damage that would be dealt by instant and sorcery spells. Creatures with flying don't untap during their controller's untap step.
K:stPreventDamage:Permanent:Spell:1:no text
SVar:RemRandomDeck:True SVar:RemRandomDeck:True
SVar:Rarity:Rare SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_storm.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_storm.jpg

View File

@@ -215,39 +215,21 @@ public abstract class GameEntity extends MyObservable {
return false; return false;
} }
public boolean isValid(final String Restriction, final Player sourceController, final Card source) { public boolean isValid(final String Restrictions[], final Player sourceController, final Card source) {
String incR[] = Restriction.split("\\."); for (int i = 0; i < Restrictions.length; i++) {
if (isValid(Restrictions[i], sourceController, source)) return true;
if (!incR[0].equals("Player") &&
!(incR[0].equals("Opponent") && !this.equals(sourceController)) &&
!(incR[0].equals("You") && this.equals(sourceController)))
return false;
if (incR.length > 1) {
final String excR = incR[1];
String exR[] = excR.split("\\+"); // Exclusive Restrictions are ...
for (int j = 0; j < exR.length; j++)
if (hasProperty(exR[j], sourceController, source) == false) return false;
} }
return false;
return true;
}//isValidCard
public boolean isValid(final String Restriction, final Player sourceController, final Card source) {
return false;
} }
public boolean hasProperty(String Property, final Player sourceController, final Card source) { public boolean hasProperty(String Property, final Player sourceController, final Card source) {
return false;
if (Property.equals("You")) {
if (!this.equals(sourceController)) {
return false;
}
}
else if (Property.equals("Opponent")) {
if (this.equals(sourceController)) {
return false;
}
}
return true;
} }
// GameEntities can now be Enchanted // GameEntities can now be Enchanted

View File

@@ -4,6 +4,7 @@ import java.util.HashMap;
import forge.Card; import forge.Card;
import forge.GameEntity; import forge.GameEntity;
import forge.card.cardFactory.CardFactoryUtil;
public class StaticAbility_PreventDamage { public class StaticAbility_PreventDamage {
@@ -17,11 +18,11 @@ public class StaticAbility_PreventDamage {
Card hostCard = stAb.getHostCard(); Card hostCard = stAb.getHostCard();
int restDamage = damage; int restDamage = damage;
if(params.containsKey("Source") && !source.isValid(params.get("Source"), hostCard.getController(), hostCard)) { if(params.containsKey("Source") && !source.isValid(params.get("Source").split(","), hostCard.getController(), hostCard)) {
return restDamage; return restDamage;
} }
if(params.containsKey("Target") && !target.isValid(params.get("Target"), hostCard.getController(), hostCard)) { if(params.containsKey("Target") && !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard)) {
return restDamage; return restDamage;
} }
@@ -29,6 +30,16 @@ public class StaticAbility_PreventDamage {
return 0; return 0;
} }
if(params.get("Amount").matches("[0-9][0-9]?")) {
restDamage = restDamage - Integer.parseInt(params.get("Amount"));
} else {
restDamage = restDamage - CardFactoryUtil.xCount(hostCard, hostCard.getSVar(params.get("Amount")));
}
if (restDamage < 0) {
return 0;
}
return restDamage; return restDamage;
} }