mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38: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:
@@ -215,39 +215,21 @@ public abstract class GameEntity extends MyObservable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValid(final String Restriction, 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;
|
||||
public boolean isValid(final String Restrictions[], final Player sourceController, final Card source) {
|
||||
|
||||
for (int i = 0; i < Restrictions.length; i++) {
|
||||
if (isValid(Restrictions[i], sourceController, source)) return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}//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