mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Added a new static ability "PreventDamage".
- Converted Personal Sanctuary to it.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -9991,6 +9991,7 @@ src/main/java/forge/card/spellability/Target_Selection.java svneol=native#text/p
|
|||||||
src/main/java/forge/card/spellability/package-info.java svneol=native#text/plain
|
src/main/java/forge/card/spellability/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/staticAbility/StaticAbility.java svneol=native#text/plain
|
src/main/java/forge/card/staticAbility/StaticAbility.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/staticAbility/StaticAbility_Continuous.java svneol=native#text/plain
|
src/main/java/forge/card/staticAbility/StaticAbility_Continuous.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/staticAbility/StaticAbility_PreventDamage.java -text
|
||||||
src/main/java/forge/card/staticAbility/package-info.java svneol=native#text/plain
|
src/main/java/forge/card/staticAbility/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/trigger/Trigger.java svneol=native#text/plain
|
src/main/java/forge/card/trigger/Trigger.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/trigger/TriggerHandler.java svneol=native#text/plain
|
src/main/java/forge/card/trigger/TriggerHandler.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Name:Personal Sanctuary
|
|||||||
ManaCost:2 W
|
ManaCost:2 W
|
||||||
Types:Enchantment
|
Types:Enchantment
|
||||||
Text:no text
|
Text:no text
|
||||||
S:Mode$ Continuous | Affected$ You | AddKeyword$ Prevent all damage that would be dealt to you | PlayerTurn$ True | Description$ During your turn, prevent all damage that would be dealt to you.
|
S:Mode$ PreventDamage | Target$ You | PlayerTurn$ True | Description$ During your turn, prevent all damage that would be dealt to you.
|
||||||
SVar:Rarity:Rare
|
SVar:Rarity:Rare
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/personal_sanctuary.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/personal_sanctuary.jpg
|
||||||
SetInfo:M12|Rare|http://magiccards.info/scans/en/m12/30.jpg
|
SetInfo:M12|Rare|http://magiccards.info/scans/en/m12/30.jpg
|
||||||
|
|||||||
@@ -5698,10 +5698,17 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//stPreventDamage
|
//stPreventDamage
|
||||||
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
for (Card ca : allp) {
|
for (Card ca : allp) {
|
||||||
|
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||||
|
for (StaticAbility stAb : staticAbilities) {
|
||||||
|
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage);
|
||||||
|
}
|
||||||
|
|
||||||
if (ca.hasStartOfKeyword("stPreventDamage")) {
|
if (ca.hasStartOfKeyword("stPreventDamage")) {
|
||||||
//syntax stPreventDamage:[Who is protected(You/Player/ValidCards)]:[ValidSource]:[Amount/All]
|
//syntax stPreventDamage:[Who is protected(You/Player/ValidCards)]:[ValidSource]:[Amount/All]
|
||||||
int keywordPosition = ca.getKeywordPosition("stPreventDamage");
|
int keywordPosition = ca.getKeywordPosition("stPreventDamage");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import forge.card.cardFactory.CardFactoryUtil;
|
|||||||
import forge.card.mana.ManaPool;
|
import forge.card.mana.ManaPool;
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.card.staticAbility.StaticAbility;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -411,6 +412,10 @@ public abstract class Player extends GameEntity {
|
|||||||
//stPreventDamage
|
//stPreventDamage
|
||||||
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
for (Card ca : allp) {
|
for (Card ca : allp) {
|
||||||
|
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||||
|
for (StaticAbility stAb : staticAbilities) {
|
||||||
|
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage);
|
||||||
|
}
|
||||||
if (ca.hasStartOfKeyword("stPreventDamage")) {
|
if (ca.hasStartOfKeyword("stPreventDamage")) {
|
||||||
//syntax stPreventDamage:[Who is protected(You/Player/ValidCards)]:[ValidSource]:[Amount/All]
|
//syntax stPreventDamage:[Who is protected(You/Player/ValidCards)]:[ValidSource]:[Amount/All]
|
||||||
int KeywordPosition = ca.getKeywordPosition("stPreventDamage");
|
int KeywordPosition = ca.getKeywordPosition("stPreventDamage");
|
||||||
|
|||||||
@@ -152,6 +152,22 @@ public class StaticAbility {
|
|||||||
StaticAbility_Continuous.applyContinuousAbility(this);
|
StaticAbility_Continuous.applyContinuousAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//apply the ability if it has the right mode
|
||||||
|
public int applyAbility(String mode, Card source, GameEntity target, int in) {
|
||||||
|
|
||||||
|
//don't apply the ability if it hasn't got the right mode
|
||||||
|
if (!mapParams.get("Mode").equals(mode))
|
||||||
|
return in;
|
||||||
|
|
||||||
|
if (isSuppressed() || !checkConditions())
|
||||||
|
return in;
|
||||||
|
|
||||||
|
if (mode.equals("PreventDamage"))
|
||||||
|
return StaticAbility_PreventDamage.applyPreventDamageAbility(this, source, target, in);
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkConditions() {
|
public boolean checkConditions() {
|
||||||
Player controller = hostCard.getController();
|
Player controller = hostCard.getController();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package forge.card.staticAbility;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import forge.Card;
|
||||||
|
import forge.GameEntity;
|
||||||
|
|
||||||
|
public class StaticAbility_PreventDamage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* TODO Write javadoc for this method.
|
||||||
|
* @param stAb a StaticAbility
|
||||||
|
*/
|
||||||
|
public static int applyPreventDamageAbility(final StaticAbility stAb, Card source, GameEntity target, int damage) {
|
||||||
|
HashMap<String, String> params = stAb.getMapParams();
|
||||||
|
Card hostCard = stAb.getHostCard();
|
||||||
|
int restDamage = damage;
|
||||||
|
|
||||||
|
if(params.containsKey("Source") && !source.isValid(params.get("Source"), hostCard.getController(), hostCard)) {
|
||||||
|
return restDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(params.containsKey("Target") && !target.isValid(params.get("Target"), hostCard.getController(), hostCard)) {
|
||||||
|
return restDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!params.containsKey("Amount") || params.get("Amount").equals("All")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return restDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user