mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- Cleanup.
This commit is contained in:
@@ -7939,10 +7939,40 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||||
|
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||||
|
HashMap<String, String> params = re.getMapParams();
|
||||||
|
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("ValidSource")
|
||||||
|
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("ValidTarget")
|
||||||
|
&& !this.isValid(params.get("ValidTarget"), ca.getController(), ca)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("IsCombat")) {
|
||||||
|
if (params.get("IsCombat").equals("True")) {
|
||||||
|
if (!isCombat) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isCombat) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int restDamage = damage - possiblePrvenetion;
|
int restDamage = damage - possiblePrvenetion;
|
||||||
|
|
||||||
restDamage = this.staticDamagePrevention(restDamage, source, isCombat, true);
|
restDamage = this.staticDamagePrevention(restDamage, source, isCombat);
|
||||||
|
|
||||||
return restDamage;
|
return restDamage;
|
||||||
}
|
}
|
||||||
@@ -7963,7 +7993,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int staticDamagePrevention(final int damageIn, final Card source, final boolean isCombat, boolean predict) {
|
public final int staticDamagePrevention(final int damageIn, final Card source, final boolean isCombat) {
|
||||||
|
|
||||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||||
return damageIn;
|
return damageIn;
|
||||||
@@ -8033,36 +8063,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
for (final StaticAbility stAb : staticAbilities) {
|
for (final StaticAbility stAb : staticAbilities) {
|
||||||
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat);
|
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat);
|
||||||
}
|
}
|
||||||
if (!predict) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
|
||||||
HashMap<String, String> params = re.getMapParams();
|
|
||||||
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("ValidSource")
|
|
||||||
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("ValidTarget")
|
|
||||||
&& !this.isValid(params.get("ValidTarget"), ca.getController(), ca)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("IsCombat")) {
|
|
||||||
if (params.get("IsCombat").equals("True")) {
|
|
||||||
if (!isCombat) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isCombat) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// specific Cards
|
// specific Cards
|
||||||
@@ -8120,7 +8120,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
restDamage = this.staticDamagePrevention(restDamage, source, isCombat, false);
|
restDamage = this.staticDamagePrevention(restDamage, source, isCombat);
|
||||||
|
|
||||||
if (restDamage == 0) {
|
if (restDamage == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public abstract class GameEntity extends MyObservable {
|
|||||||
int restDamage = damage;
|
int restDamage = damage;
|
||||||
|
|
||||||
restDamage = this.staticReplaceDamage(restDamage, source, isCombat);
|
restDamage = this.staticReplaceDamage(restDamage, source, isCombat);
|
||||||
restDamage = this.staticDamagePrevention(restDamage, source, isCombat, true);
|
restDamage = this.staticDamagePrevention(restDamage, source, isCombat);
|
||||||
|
|
||||||
return restDamage;
|
return restDamage;
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public abstract class GameEntity extends MyObservable {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int staticDamagePrevention(final int damage, final Card source, final boolean isCombat, boolean predict) {
|
public int staticDamagePrevention(final int damage, final Card source, final boolean isCombat) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -581,7 +581,39 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
int restDamage = damage;
|
int restDamage = damage;
|
||||||
|
|
||||||
restDamage = this.staticReplaceDamage(restDamage, source, isCombat);
|
restDamage = this.staticReplaceDamage(restDamage, source, isCombat);
|
||||||
restDamage = this.staticDamagePrevention(restDamage, source, isCombat, true);
|
|
||||||
|
// Predict replacement effects
|
||||||
|
for (final Card ca : game.getCardsIn(ZoneType.Battlefield)) {
|
||||||
|
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||||
|
HashMap<String,String> params = re.getMapParams();
|
||||||
|
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("ValidSource")
|
||||||
|
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("ValidTarget")
|
||||||
|
&& !this.isValid(params.get("ValidTarget"), ca.getController(), ca)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (params.containsKey("IsCombat")) {
|
||||||
|
if (params.get("IsCombat").equals("True")) {
|
||||||
|
if (!isCombat) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isCombat) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
restDamage = this.staticDamagePrevention(restDamage, source, isCombat);
|
||||||
|
|
||||||
return restDamage;
|
return restDamage;
|
||||||
}
|
}
|
||||||
@@ -602,7 +634,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int staticDamagePrevention(final int damage, final Card source, final boolean isCombat, boolean predict) {
|
public final int staticDamagePrevention(final int damage, final Card source, final boolean isCombat) {
|
||||||
|
|
||||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||||
return damage;
|
return damage;
|
||||||
@@ -641,36 +673,6 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
for (final StaticAbility stAb : staticAbilities) {
|
for (final StaticAbility stAb : staticAbilities) {
|
||||||
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat);
|
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat);
|
||||||
}
|
}
|
||||||
if (!predict) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
|
||||||
HashMap<String,String> params = re.getMapParams();
|
|
||||||
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("ValidSource")
|
|
||||||
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("ValidTarget")
|
|
||||||
&& !this.isValid(params.get("ValidTarget"), ca.getController(), ca)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (params.containsKey("IsCombat")) {
|
|
||||||
if (params.get("IsCombat").equals("True")) {
|
|
||||||
if (!isCombat) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isCombat) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -851,7 +853,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
restDamage = this.staticDamagePrevention(restDamage, source, isCombat, false);
|
restDamage = this.staticDamagePrevention(restDamage, source, isCombat);
|
||||||
|
|
||||||
if (restDamage >= this.getPreventNextDamage()) {
|
if (restDamage >= this.getPreventNextDamage()) {
|
||||||
restDamage = restDamage - this.getPreventNextDamage();
|
restDamage = restDamage - this.getPreventNextDamage();
|
||||||
|
|||||||
Reference in New Issue
Block a user