mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
eliminated duplicate code of requirementsCheck() in Trigger and ReplacementEffect
some references changed to basic class
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
import com.esotericsoftware.minlog.Log;
|
||||||
|
|
||||||
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.replacement.ReplacementEffect;
|
import forge.card.replacement.ReplacementEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.staticability.StaticAbility;
|
import forge.card.staticability.StaticAbility;
|
||||||
@@ -236,7 +237,7 @@ public class StaticEffects {
|
|||||||
stA.setTemporarilySuppressed(false);
|
stA.setTemporarilySuppressed(false);
|
||||||
}
|
}
|
||||||
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
||||||
for (final ReplacementEffect rE : replacementEffects) {
|
for (final TriggerReplacementBase rE : replacementEffects) {
|
||||||
rE.setTemporarilySuppressed(false);
|
rE.setTemporarilySuppressed(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
package forge.card;
|
package forge.card;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
import forge.CardLists;
|
||||||
|
import forge.CardUtil;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.util.Expressions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Triggers and ReplacementEffects.
|
* Base class for Triggers and ReplacementEffects.
|
||||||
@@ -144,4 +153,174 @@ public abstract class TriggerReplacementBase {
|
|||||||
public final boolean isSuppressed() {
|
public final boolean isSuppressed() {
|
||||||
return (this.suppressed || this.temporarilySuppressed);
|
return (this.suppressed || this.temporarilySuppressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean meetsCommonRequirements(Map<String, String> params) {
|
||||||
|
|
||||||
|
Player hostController = this.getHostCard().getController();
|
||||||
|
|
||||||
|
if ("True".equalsIgnoreCase(params.get("Metalcraft")) && !hostController.hasMetalcraft()) return false;
|
||||||
|
if ("True".equalsIgnoreCase(params.get("Threshold")) && !hostController.hasThreshold()) return false;
|
||||||
|
if ("True".equalsIgnoreCase(params.get("Hellbent")) && !hostController.hasHellbent()) return false;
|
||||||
|
if ("True".equalsIgnoreCase(params.get("Bloodthirst")) && !hostController.hasBloodthirst()) return false;
|
||||||
|
if ("True".equalsIgnoreCase(params.get("FatefulHour")) && hostController.getLife() > 5) return false;
|
||||||
|
|
||||||
|
if ("You".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getPoisonCounters() == 0) return false;
|
||||||
|
if ("Opponent".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getOpponent().getPoisonCounters() == 0) return false;
|
||||||
|
if ("Each".equalsIgnoreCase(params.get("PlayersPoisoned"))) {
|
||||||
|
for( Player p : Singletons.getModel().getGame().getPlayers())
|
||||||
|
if( p.getPoisonCounters() == 0 )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("LifeTotal")) {
|
||||||
|
final String player = params.get("LifeTotal");
|
||||||
|
String lifeCompare = "GE1";
|
||||||
|
int life = 1;
|
||||||
|
|
||||||
|
if (player.equals("You")) {
|
||||||
|
life = hostController.getLife();
|
||||||
|
}
|
||||||
|
if (player.equals("Opponent")) {
|
||||||
|
life = hostController.getOpponent().getLife();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("LifeAmount")) {
|
||||||
|
lifeCompare = params.get("LifeAmount");
|
||||||
|
}
|
||||||
|
|
||||||
|
int right = 1;
|
||||||
|
final String rightString = lifeCompare.substring(2);
|
||||||
|
try {
|
||||||
|
right = Integer.parseInt(rightString);
|
||||||
|
} catch (final NumberFormatException nfe) {
|
||||||
|
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar(rightString));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Expressions.compare(life, lifeCompare, right)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (params.containsKey("IsPresent")) {
|
||||||
|
final String sIsPresent = params.get("IsPresent");
|
||||||
|
String presentCompare = "GE1";
|
||||||
|
ZoneType presentZone = ZoneType.Battlefield;
|
||||||
|
String presentPlayer = "Any";
|
||||||
|
if (params.containsKey("PresentCompare")) {
|
||||||
|
presentCompare = params.get("PresentCompare");
|
||||||
|
}
|
||||||
|
if (params.containsKey("PresentZone")) {
|
||||||
|
presentZone = ZoneType.smartValueOf(params.get("PresentZone"));
|
||||||
|
}
|
||||||
|
if (params.containsKey("PresentPlayer")) {
|
||||||
|
presentPlayer = params.get("PresentPlayer");
|
||||||
|
}
|
||||||
|
List<Card> list = new ArrayList<Card>();
|
||||||
|
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
||||||
|
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
||||||
|
}
|
||||||
|
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
||||||
|
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
||||||
|
|
||||||
|
int right = 1;
|
||||||
|
final String rightString = presentCompare.substring(2);
|
||||||
|
if (rightString.equals("X")) {
|
||||||
|
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
||||||
|
} else {
|
||||||
|
right = Integer.parseInt(presentCompare.substring(2));
|
||||||
|
}
|
||||||
|
final int left = list.size();
|
||||||
|
|
||||||
|
if (!Expressions.compare(left, presentCompare, right)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("IsPresent2")) {
|
||||||
|
final String sIsPresent = params.get("IsPresent2");
|
||||||
|
String presentCompare = "GE1";
|
||||||
|
ZoneType presentZone = ZoneType.Battlefield;
|
||||||
|
String presentPlayer = "Any";
|
||||||
|
if (params.containsKey("PresentCompare2")) {
|
||||||
|
presentCompare = params.get("PresentCompare2");
|
||||||
|
}
|
||||||
|
if (params.containsKey("PresentZone2")) {
|
||||||
|
presentZone = ZoneType.smartValueOf(params.get("PresentZone2"));
|
||||||
|
}
|
||||||
|
if (params.containsKey("PresentPlayer2")) {
|
||||||
|
presentPlayer = params.get("PresentPlayer2");
|
||||||
|
}
|
||||||
|
List<Card> list = new ArrayList<Card>();
|
||||||
|
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
||||||
|
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
||||||
|
}
|
||||||
|
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
||||||
|
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
||||||
|
|
||||||
|
int right = 1;
|
||||||
|
final String rightString = presentCompare.substring(2);
|
||||||
|
if (rightString.equals("X")) {
|
||||||
|
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
||||||
|
} else {
|
||||||
|
right = Integer.parseInt(presentCompare.substring(2));
|
||||||
|
}
|
||||||
|
final int left = list.size();
|
||||||
|
|
||||||
|
if (!Expressions.compare(left, presentCompare, right)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("CheckSVar")) {
|
||||||
|
final int sVar = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()), params.get("CheckSVar"), null);
|
||||||
|
String comparator = "GE1";
|
||||||
|
if (params.containsKey("SVarCompare")) {
|
||||||
|
comparator = params.get("SVarCompare");
|
||||||
|
}
|
||||||
|
final String svarOperator = comparator.substring(0, 2);
|
||||||
|
final String svarOperand = comparator.substring(2);
|
||||||
|
final int operandValue = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()),
|
||||||
|
svarOperand, null);
|
||||||
|
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("ManaSpent")) {
|
||||||
|
if (!this.getHostCard().getColorsPaid().contains(params.get("ManaSpent"))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("ManaNotSpent")) {
|
||||||
|
if (this.getHostCard().getColorsPaid().contains(params.get("ManaNotSpent"))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("WerewolfTransformCondition")) {
|
||||||
|
if (CardUtil.getLastTurnCast("Card", this.getHostCard()).size() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("WerewolfUntransformCondition")) {
|
||||||
|
final List<Card> you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard());
|
||||||
|
final List<Card> opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard());
|
||||||
|
if (!((you.size() > 1) || (opp.size() > 1))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import forge.CardLists;
|
|||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.replacement.ReplacementEffect;
|
import forge.card.replacement.ReplacementEffect;
|
||||||
@@ -234,7 +235,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// give back suppressed replacement effects
|
// give back suppressed replacement effects
|
||||||
for (final ReplacementEffect re : removedReplacements) {
|
for (final TriggerReplacementBase re : removedReplacements) {
|
||||||
re.setTemporarilySuppressed(false);
|
re.setTemporarilySuppressed(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import forge.Card;
|
|||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.replacement.ReplacementEffect;
|
import forge.card.replacement.ReplacementEffect;
|
||||||
@@ -255,7 +256,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// give back suppressed replacement effects
|
// give back suppressed replacement effects
|
||||||
for (final ReplacementEffect re : removedReplacements) {
|
for (final TriggerReplacementBase re : removedReplacements) {
|
||||||
re.setTemporarilySuppressed(false);
|
re.setTemporarilySuppressed(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package forge.card.replacement;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.TriggerReplacementBase;
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
@@ -31,7 +29,6 @@ import forge.card.cardfactory.CardFactoryUtil;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.zone.ZoneType;
|
|
||||||
import forge.util.Expressions;
|
import forge.util.Expressions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,46 +172,24 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean requirementsCheck() {
|
public boolean requirementsCheck() {
|
||||||
|
return this.requirementsCheck(this.getMapParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean requirementsCheck(Map<String,String> params) {
|
||||||
|
|
||||||
if (this.isSuppressed()) {
|
if (this.isSuppressed()) {
|
||||||
return false; // Effect removed by effect
|
return false; // Effect removed by effect
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Metalcraft")) {
|
if (params.containsKey("PlayerTurn")) {
|
||||||
if (this.getMapParams().get("Metalcraft").equals("True")
|
if (params.get("PlayerTurn").equals("True") && !Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
|
||||||
&& !this.getHostCard().getController().hasMetalcraft()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Threshold")) {
|
if (params.containsKey("ActivePhases")) {
|
||||||
if (this.getMapParams().get("Threshold").equals("True")
|
|
||||||
&& !this.getHostCard().getController().hasThreshold()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Hellbent")) {
|
|
||||||
if (this.getMapParams().get("Hellbent").equals("True") && !this.getHostCard().getController().hasHellbent()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Bloodthirst")) {
|
|
||||||
if (this.getMapParams().get("Bloodthirst").equals("True") && !this.getHostCard().getController().hasBloodthirst()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("PlayerTurn")) {
|
|
||||||
if (this.getMapParams().get("PlayerTurn").equals("True") && !Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("ActivePhases")) {
|
|
||||||
boolean isPhase = false;
|
boolean isPhase = false;
|
||||||
List<PhaseType> aPhases = PhaseType.parseRange(this.getMapParams().get("ActivePhases"));
|
List<PhaseType> aPhases = PhaseType.parseRange(params.get("ActivePhases"));
|
||||||
final PhaseType currPhase = Singletons.getModel().getGame().getPhaseHandler().getPhase();
|
final PhaseType currPhase = Singletons.getModel().getGame().getPhaseHandler().getPhase();
|
||||||
for (final PhaseType s : aPhases) {
|
for (final PhaseType s : aPhases) {
|
||||||
if (s == currPhase) {
|
if (s == currPhase) {
|
||||||
@@ -226,171 +201,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
|
|||||||
return isPhase;
|
return isPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("PlayersPoisoned")) {
|
return meetsCommonRequirements(params);
|
||||||
if (this.getMapParams().get("PlayersPoisoned").equals("You")
|
|
||||||
&& (this.getHostCard().getController().getPoisonCounters() == 0)) {
|
|
||||||
return false;
|
|
||||||
} else if (this.getMapParams().get("PlayersPoisoned").equals("Opponent")
|
|
||||||
&& (this.getHostCard().getController().getOpponent().getPoisonCounters() == 0)) {
|
|
||||||
return false;
|
|
||||||
} else if (this.getMapParams().get("PlayersPoisoned").equals("Each")
|
|
||||||
&& !((this.getHostCard().getController().getPoisonCounters() != 0) && (this.getHostCard()
|
|
||||||
.getController().getPoisonCounters() != 0))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("LifeTotal")) {
|
|
||||||
final String player = this.getMapParams().get("LifeTotal");
|
|
||||||
String lifeCompare = "GE1";
|
|
||||||
int life = 1;
|
|
||||||
|
|
||||||
if (player.equals("You")) {
|
|
||||||
life = this.getHostCard().getController().getLife();
|
|
||||||
}
|
|
||||||
if (player.equals("Opponent")) {
|
|
||||||
life = this.getHostCard().getController().getOpponent().getLife();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("LifeAmount")) {
|
|
||||||
lifeCompare = this.getMapParams().get("LifeAmount");
|
|
||||||
}
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = lifeCompare.substring(2);
|
|
||||||
try {
|
|
||||||
right = Integer.parseInt(rightString);
|
|
||||||
} catch (final NumberFormatException nfe) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar(rightString));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Expressions.compare(life, lifeCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("IsPresent")) {
|
|
||||||
final String sIsPresent = this.getMapParams().get("IsPresent");
|
|
||||||
String presentCompare = "GE1";
|
|
||||||
ZoneType presentZone = ZoneType.Battlefield;
|
|
||||||
String presentPlayer = "Any";
|
|
||||||
if (this.getMapParams().containsKey("PresentCompare")) {
|
|
||||||
presentCompare = this.getMapParams().get("PresentCompare");
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentZone")) {
|
|
||||||
presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone"));
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentPlayer")) {
|
|
||||||
presentPlayer = this.getMapParams().get("PresentPlayer");
|
|
||||||
}
|
|
||||||
List<Card> list = new ArrayList<Card>();
|
|
||||||
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
|
|
||||||
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = presentCompare.substring(2);
|
|
||||||
if (rightString.equals("X")) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
|
||||||
} else {
|
|
||||||
right = Integer.parseInt(presentCompare.substring(2));
|
|
||||||
}
|
|
||||||
final int left = list.size();
|
|
||||||
|
|
||||||
if (!Expressions.compare(left, presentCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("IsPresent2")) {
|
|
||||||
final String sIsPresent = this.getMapParams().get("IsPresent2");
|
|
||||||
String presentCompare = "GE1";
|
|
||||||
ZoneType presentZone = ZoneType.Battlefield;
|
|
||||||
String presentPlayer = "Any";
|
|
||||||
if (this.getMapParams().containsKey("PresentCompare2")) {
|
|
||||||
presentCompare = this.getMapParams().get("PresentCompare2");
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentZone2")) {
|
|
||||||
presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone2"));
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentPlayer2")) {
|
|
||||||
presentPlayer = this.getMapParams().get("PresentPlayer2");
|
|
||||||
}
|
|
||||||
List<Card> list = new ArrayList<Card>();
|
|
||||||
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
|
|
||||||
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = presentCompare.substring(2);
|
|
||||||
if (rightString.equals("X")) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
|
||||||
} else {
|
|
||||||
right = Integer.parseInt(presentCompare.substring(2));
|
|
||||||
}
|
|
||||||
final int left = list.size();
|
|
||||||
|
|
||||||
if (!Expressions.compare(left, presentCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("CheckSVar")) {
|
|
||||||
final int sVar = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()), this
|
|
||||||
.getMapParams().get("CheckSVar"), null);
|
|
||||||
String comparator = "GE1";
|
|
||||||
if (this.getMapParams().containsKey("SVarCompare")) {
|
|
||||||
comparator = this.getMapParams().get("SVarCompare");
|
|
||||||
}
|
|
||||||
final String svarOperator = comparator.substring(0, 2);
|
|
||||||
final String svarOperand = comparator.substring(2);
|
|
||||||
final int operandValue = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()),
|
|
||||||
svarOperand, null);
|
|
||||||
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("ManaSpent")) {
|
|
||||||
if (!this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaSpent"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("ManaNotSpent")) {
|
|
||||||
if (this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaNotSpent"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("WerewolfTransformCondition")) {
|
|
||||||
if (CardUtil.getLastTurnCast("Card", this.getHostCard()).size() > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("WerewolfUntransformCondition")) {
|
|
||||||
final List<Card> you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard());
|
|
||||||
final List<Card> opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard());
|
|
||||||
if (!((you.size() > 1) || (opp.size() > 1))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import forge.CardUtil;
|
|||||||
import forge.StaticEffect;
|
import forge.StaticEffect;
|
||||||
import forge.StaticEffects;
|
import forge.StaticEffects;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
@@ -436,7 +437,7 @@ public class StaticAbilityContinuous {
|
|||||||
stA.setTemporarilySuppressed(true);
|
stA.setTemporarilySuppressed(true);
|
||||||
}
|
}
|
||||||
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
||||||
for (final ReplacementEffect rE : replacementEffects) {
|
for (final TriggerReplacementBase rE : replacementEffects) {
|
||||||
rE.setTemporarilySuppressed(true);
|
rE.setTemporarilySuppressed(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,19 +24,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
|
||||||
import forge.CardLists;
|
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.TriggerReplacementBase;
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.AbilityUtils;
|
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Expressions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -276,77 +271,7 @@ public abstract class Trigger extends TriggerReplacementBase {
|
|||||||
* a {@link java.util.HashMap} object.
|
* a {@link java.util.HashMap} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean requirementsCheck(final java.util.Map<String, Object> runParams2) {
|
public final boolean requirementsCheck(final Map<String, Object> runParams2) {
|
||||||
if (this.getMapParams().containsKey("FatefulHour")) {
|
|
||||||
if (this.getMapParams().get("FatefulHour").equals("True")
|
|
||||||
&& !(this.getHostCard().getController().getLife() <= 5)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Metalcraft")) {
|
|
||||||
if (this.getMapParams().get("Metalcraft").equals("True")
|
|
||||||
&& !this.getHostCard().getController().hasMetalcraft()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Threshold")) {
|
|
||||||
if (this.getMapParams().get("Threshold").equals("True")
|
|
||||||
&& !this.getHostCard().getController().hasThreshold()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("Hellbent")) {
|
|
||||||
if (this.getMapParams().get("Hellbent").equals("True") && !this.getHostCard().getController().hasHellbent()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("PlayersPoisoned")) {
|
|
||||||
if (this.getMapParams().get("PlayersPoisoned").equals("You")
|
|
||||||
&& (this.getHostCard().getController().getPoisonCounters() == 0)) {
|
|
||||||
return false;
|
|
||||||
} else if (this.getMapParams().get("PlayersPoisoned").equals("Opponent")
|
|
||||||
&& (this.getHostCard().getController().getOpponent().getPoisonCounters() == 0)) {
|
|
||||||
return false;
|
|
||||||
} else if (this.getMapParams().get("PlayersPoisoned").equals("Each")
|
|
||||||
&& !((this.getHostCard().getController().getPoisonCounters() != 0) && (this.getHostCard()
|
|
||||||
.getController().getPoisonCounters() != 0))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("LifeTotal")) {
|
|
||||||
final String player = this.getMapParams().get("LifeTotal");
|
|
||||||
String lifeCompare = "GE1";
|
|
||||||
int life = 1;
|
|
||||||
|
|
||||||
if (player.equals("You")) {
|
|
||||||
life = this.getHostCard().getController().getLife();
|
|
||||||
}
|
|
||||||
if (player.equals("Opponent")) {
|
|
||||||
life = this.getHostCard().getController().getOpponent().getLife();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("LifeAmount")) {
|
|
||||||
lifeCompare = this.getMapParams().get("LifeAmount");
|
|
||||||
}
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = lifeCompare.substring(2);
|
|
||||||
try {
|
|
||||||
right = Integer.parseInt(rightString);
|
|
||||||
} catch (final NumberFormatException nfe) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar(rightString));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Expressions.compare(life, lifeCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("APlayerHasMoreLifeThanEachOther")) {
|
if (this.getMapParams().containsKey("APlayerHasMoreLifeThanEachOther")) {
|
||||||
int highestLife = -50; // Negative base just in case a few Lich's or Platinum Angels are running around
|
int highestLife = -50; // Negative base just in case a few Lich's or Platinum Angels are running around
|
||||||
@@ -387,126 +312,9 @@ public abstract class Trigger extends TriggerReplacementBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("IsPresent")) {
|
if ( !meetsCommonRequirements(getMapParams()))
|
||||||
final String sIsPresent = this.getMapParams().get("IsPresent");
|
return false;
|
||||||
String presentCompare = "GE1";
|
|
||||||
ZoneType presentZone = ZoneType.Battlefield;
|
|
||||||
String presentPlayer = "Any";
|
|
||||||
if (this.getMapParams().containsKey("PresentCompare")) {
|
|
||||||
presentCompare = this.getMapParams().get("PresentCompare");
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentZone")) {
|
|
||||||
presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone"));
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentPlayer")) {
|
|
||||||
presentPlayer = this.getMapParams().get("PresentPlayer");
|
|
||||||
}
|
|
||||||
List<Card> list = new ArrayList<Card>();
|
|
||||||
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
|
|
||||||
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = presentCompare.substring(2);
|
|
||||||
if (rightString.equals("X")) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
|
||||||
} else {
|
|
||||||
right = Integer.parseInt(presentCompare.substring(2));
|
|
||||||
}
|
|
||||||
final int left = list.size();
|
|
||||||
|
|
||||||
if (!Expressions.compare(left, presentCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("IsPresent2")) {
|
|
||||||
final String sIsPresent = this.getMapParams().get("IsPresent2");
|
|
||||||
String presentCompare = "GE1";
|
|
||||||
ZoneType presentZone = ZoneType.Battlefield;
|
|
||||||
String presentPlayer = "Any";
|
|
||||||
if (this.getMapParams().containsKey("PresentCompare2")) {
|
|
||||||
presentCompare = this.getMapParams().get("PresentCompare2");
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentZone2")) {
|
|
||||||
presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone2"));
|
|
||||||
}
|
|
||||||
if (this.getMapParams().containsKey("PresentPlayer2")) {
|
|
||||||
presentPlayer = this.getMapParams().get("PresentPlayer2");
|
|
||||||
}
|
|
||||||
List<Card> list = new ArrayList<Card>();
|
|
||||||
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
|
|
||||||
list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone));
|
|
||||||
}
|
|
||||||
|
|
||||||
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard());
|
|
||||||
|
|
||||||
int right = 1;
|
|
||||||
final String rightString = presentCompare.substring(2);
|
|
||||||
if (rightString.equals("X")) {
|
|
||||||
right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X"));
|
|
||||||
} else {
|
|
||||||
right = Integer.parseInt(presentCompare.substring(2));
|
|
||||||
}
|
|
||||||
final int left = list.size();
|
|
||||||
|
|
||||||
if (!Expressions.compare(left, presentCompare, right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("CheckSVar")) {
|
|
||||||
final int sVar = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()), this
|
|
||||||
.getMapParams().get("CheckSVar"), null);
|
|
||||||
String comparator = "GE1";
|
|
||||||
if (this.getMapParams().containsKey("SVarCompare")) {
|
|
||||||
comparator = this.getMapParams().get("SVarCompare");
|
|
||||||
}
|
|
||||||
final String svarOperator = comparator.substring(0, 2);
|
|
||||||
final String svarOperand = comparator.substring(2);
|
|
||||||
final int operandValue = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()),
|
|
||||||
svarOperand, null);
|
|
||||||
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("ManaSpent")) {
|
|
||||||
if (!this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaSpent"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("ManaNotSpent")) {
|
|
||||||
if (this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaNotSpent"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("WerewolfTransformCondition")) {
|
|
||||||
if (CardUtil.getLastTurnCast("Card", this.getHostCard()).size() > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("WerewolfUntransformCondition")) {
|
|
||||||
final List<Card> you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard());
|
|
||||||
final List<Card> opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard());
|
|
||||||
if (!((you.size() > 1) || (opp.size() > 1))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getMapParams().containsKey("EvolveCondition")) {
|
if (this.getMapParams().containsKey("EvolveCondition")) {
|
||||||
if (this.getMapParams().get("EvolveCondition").equals("True")) {
|
if (this.getMapParams().get("EvolveCondition").equals("True")) {
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ import forge.CounterType;
|
|||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.card.CardSplitType;
|
import forge.card.CardSplitType;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
|
import forge.card.TriggerReplacementBase;
|
||||||
import forge.card.ability.effects.AttachEffect;
|
import forge.card.ability.effects.AttachEffect;
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.card.replacement.ReplacementEffect;
|
|
||||||
import forge.card.replacement.ReplacementResult;
|
import forge.card.replacement.ReplacementResult;
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.AbilityActivated;
|
import forge.card.spellability.AbilityActivated;
|
||||||
@@ -164,7 +164,7 @@ public class GameAction {
|
|||||||
for (final Trigger trigger : copied.getTriggers()) {
|
for (final Trigger trigger : copied.getTriggers()) {
|
||||||
trigger.setHostCard(copied);
|
trigger.setHostCard(copied);
|
||||||
}
|
}
|
||||||
for (final ReplacementEffect repl : copied.getReplacementEffects()) {
|
for (final TriggerReplacementBase repl : copied.getReplacementEffects()) {
|
||||||
repl.setHostCard(copied);
|
repl.setHostCard(copied);
|
||||||
}
|
}
|
||||||
if (c.getName().equals("Skullbriar, the Walking Grave")) {
|
if (c.getName().equals("Skullbriar, the Walking Grave")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user