mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- 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:
@@ -2,7 +2,7 @@ Name:Daunting Defender
|
||||
ManaCost:4 W
|
||||
Types:Creature Human Cleric
|
||||
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
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/daunting_defender.jpg
|
||||
|
||||
@@ -4,7 +4,7 @@ Types:Enchantment
|
||||
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.
|
||||
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:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_field.jpg
|
||||
|
||||
@@ -4,8 +4,7 @@ Types:Enchantment
|
||||
Text:no text
|
||||
K:Cumulative upkeep:1
|
||||
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.
|
||||
K:stPreventDamage:Permanent:Spell:1:no text
|
||||
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.
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_storm.jpg
|
||||
|
||||
@@ -215,39 +215,21 @@ public abstract class GameEntity extends MyObservable {
|
||||
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("\\.");
|
||||
|
||||
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;
|
||||
for (int i = 0; i < Restrictions.length; i++) {
|
||||
if (isValid(Restrictions[i], sourceController, source)) return true;
|
||||
}
|
||||
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) {
|
||||
|
||||
if (Property.equals("You")) {
|
||||
if (!this.equals(sourceController)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (Property.equals("Opponent")) {
|
||||
if (this.equals(sourceController)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// GameEntities can now be Enchanted
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
import forge.Card;
|
||||
import forge.GameEntity;
|
||||
import forge.card.cardFactory.CardFactoryUtil;
|
||||
|
||||
public class StaticAbility_PreventDamage {
|
||||
|
||||
@@ -17,11 +18,11 @@ public class StaticAbility_PreventDamage {
|
||||
Card hostCard = stAb.getHostCard();
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -29,6 +30,16 @@ public class StaticAbility_PreventDamage {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user