mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
merge latest trunk
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.CardPredicates.Presets;
|
||||
@@ -206,28 +207,28 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private String miracleCost = null;
|
||||
private String chosenType = "";
|
||||
// private String chosenColor = "";
|
||||
private ArrayList<String> chosenColor = new ArrayList<String>();
|
||||
private List<String> chosenColor = new ArrayList<String>();
|
||||
private String namedCard = "";
|
||||
private int chosenNumber;
|
||||
private Player chosenPlayer;
|
||||
private ArrayList<Card> chosenCard = new ArrayList<Card>();
|
||||
private List<Card> chosenCard = new ArrayList<Card>();
|
||||
|
||||
private Card cloneOrigin = null;
|
||||
private final ArrayList<Card> clones = new ArrayList<Card>();
|
||||
private final ArrayList<Card> gainControlTargets = new ArrayList<Card>();
|
||||
private final ArrayList<Command> gainControlReleaseCommands = new ArrayList<Command>();
|
||||
private final List<Card> clones = new ArrayList<Card>();
|
||||
private final List<Card> gainControlTargets = new ArrayList<Card>();
|
||||
private final List<Command> gainControlReleaseCommands = new ArrayList<Command>();
|
||||
|
||||
private final ArrayList<AbilityTriggered> zcTriggers = new ArrayList<AbilityTriggered>();
|
||||
private final ArrayList<Command> equipCommandList = new ArrayList<Command>();
|
||||
private final ArrayList<Command> unEquipCommandList = new ArrayList<Command>();
|
||||
private final ArrayList<Command> enchantCommandList = new ArrayList<Command>();
|
||||
private final ArrayList<Command> unEnchantCommandList = new ArrayList<Command>();
|
||||
private final ArrayList<Command> untapCommandList = new ArrayList<Command>();
|
||||
private final ArrayList<Command> changeControllerCommandList = new ArrayList<Command>();
|
||||
private final List<AbilityTriggered> zcTriggers = new ArrayList<AbilityTriggered>();
|
||||
private final List<Command> equipCommandList = new ArrayList<Command>();
|
||||
private final List<Command> unEquipCommandList = new ArrayList<Command>();
|
||||
private final List<Command> enchantCommandList = new ArrayList<Command>();
|
||||
private final List<Command> unEnchantCommandList = new ArrayList<Command>();
|
||||
private final List<Command> untapCommandList = new ArrayList<Command>();
|
||||
private final List<Command> changeControllerCommandList = new ArrayList<Command>();
|
||||
|
||||
private static String[] storableSVars = { "ChosenX", "ChosenY" };
|
||||
private final static ImmutableList<String> storableSVars = ImmutableList.of("ChosenX", "ChosenY" );
|
||||
|
||||
private final ArrayList<Card> hauntedBy = new ArrayList<Card>();
|
||||
private final List<Card> hauntedBy = new ArrayList<Card>();
|
||||
private Card haunting = null;
|
||||
private Card effectSource = null;
|
||||
|
||||
@@ -561,7 +562,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return a String array
|
||||
*/
|
||||
public static String[] getStorableSVars() {
|
||||
public static List<String> getStorableSVars() {
|
||||
return Card.storableSVars;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1159,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<Card> getClones() {
|
||||
public final List<Card> getClones() {
|
||||
return this.clones;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1171,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @param c
|
||||
* a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final void setClones(final ArrayList<Card> c) {
|
||||
public final void setClones(final Collection<Card> c) {
|
||||
this.clones.clear();
|
||||
this.clones.addAll(c);
|
||||
}
|
||||
@@ -1908,7 +1909,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return an ArrayList<String> object.
|
||||
*/
|
||||
public final ArrayList<String> getChosenColor() {
|
||||
public final List<String> getChosenColor() {
|
||||
return this.chosenColor;
|
||||
}
|
||||
|
||||
@@ -1920,7 +1921,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @param s
|
||||
* an ArrayList<String> object.
|
||||
*/
|
||||
public final void setChosenColor(final ArrayList<String> s) {
|
||||
public final void setChosenColor(final List<String> s) {
|
||||
this.chosenColor = s;
|
||||
}
|
||||
|
||||
@@ -1931,7 +1932,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return an ArrayList<Card> object.
|
||||
*/
|
||||
public final ArrayList<Card> getChosenCard() {
|
||||
public final List<Card> getChosenCard() {
|
||||
return this.chosenCard;
|
||||
}
|
||||
|
||||
@@ -2001,7 +2002,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return a list of cards this card has gained control of
|
||||
*/
|
||||
public final ArrayList<Card> getGainControlTargets() {
|
||||
public final List<Card> getGainControlTargets() {
|
||||
return this.gainControlTargets;
|
||||
}
|
||||
|
||||
@@ -2035,7 +2036,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<Command> getGainControlReleaseCommands() {
|
||||
public final List<Command> getGainControlReleaseCommands() {
|
||||
return this.gainControlReleaseCommands;
|
||||
}
|
||||
|
||||
@@ -5976,7 +5977,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasKeyword(final String keyword) {
|
||||
String kw = new String(keyword);
|
||||
String kw = keyword;
|
||||
if (kw.startsWith("HIDDEN")) {
|
||||
kw = kw.substring(7);
|
||||
}
|
||||
@@ -8604,7 +8605,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return the haunted by
|
||||
*/
|
||||
public final ArrayList<Card> getHauntedBy() {
|
||||
public final List<Card> getHauntedBy() {
|
||||
return this.hauntedBy;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class CardUtil {
|
||||
return !kw.startsWith("Protection") && !Constant.Keywords.NON_STACKING_LIST.contains(kw);
|
||||
}
|
||||
|
||||
public static String getShortColorsString(final ArrayList<String> colors) {
|
||||
public static String getShortColorsString(final Iterable<String> colors) {
|
||||
StringBuilder colorDesc = new StringBuilder();
|
||||
for (final String col : colors) {
|
||||
colorDesc.append(getShortColor(col));
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constant interface.
|
||||
@@ -79,10 +81,10 @@ public final class Constant {
|
||||
public static final String COLORLESS = "colorless";
|
||||
// color order "wubrg"
|
||||
/** The Colors. */
|
||||
public static final String[] COLORS = { Color.WHITE, Color.BLUE, Color.BLACK, Color.RED, Color.GREEN, Color.COLORLESS };
|
||||
public static final ImmutableList<String> COLORS = ImmutableList.of(Color.WHITE, Color.BLUE, Color.BLACK, Color.RED, Color.GREEN, Color.COLORLESS);
|
||||
|
||||
/** The only colors. */
|
||||
public static final String[] ONLY_COLORS = { Color.WHITE, Color.BLUE, Color.BLACK, Color.RED, Color.GREEN };
|
||||
public static final ImmutableList<String> ONLY_COLORS = ImmutableList.of(Color.WHITE, Color.BLUE, Color.BLACK, Color.RED, Color.GREEN);
|
||||
|
||||
/** The Snow. */
|
||||
public static final String SNOW = "snow";
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -236,7 +237,7 @@ public class StaticEffects {
|
||||
stA.setTemporarilySuppressed(false);
|
||||
}
|
||||
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
||||
for (final ReplacementEffect rE : replacementEffects) {
|
||||
for (final TriggerReplacementBase rE : replacementEffects) {
|
||||
rE.setTemporarilySuppressed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ final class CardFace implements ICardFace {
|
||||
|
||||
|
||||
// these implement ICardCharacteristics
|
||||
@Override public final String getOracleText() { return oracleText; }
|
||||
@Override public final int getIntPower() { return iPower; }
|
||||
@Override public final int getIntToughness() { return iToughness; }
|
||||
@Override public final String getPower() { return power; }
|
||||
@Override public final String getToughness() { return toughness; }
|
||||
@Override public String getOracleText() { return oracleText; }
|
||||
@Override public int getIntPower() { return iPower; }
|
||||
@Override public int getIntToughness() { return iToughness; }
|
||||
@Override public String getPower() { return power; }
|
||||
@Override public String getToughness() { return toughness; }
|
||||
@Override public int getInitialLoyalty() { return initialLoyalty; }
|
||||
@Override public final String getName() { return this.name; }
|
||||
@Override public final CardType getType() { return this.type; }
|
||||
@Override public final ManaCost getManaCost() { return this.manaCost; }
|
||||
@Override public final ColorSet getColor() { return this.color; }
|
||||
@Override public String getName() { return this.name; }
|
||||
@Override public CardType getType() { return this.type; }
|
||||
@Override public ManaCost getManaCost() { return this.manaCost; }
|
||||
@Override public ColorSet getColor() { return this.color; }
|
||||
|
||||
// these are raw and unparsed used for Card creation
|
||||
@Override public final Iterable<String> getKeywords() { return keywords; }
|
||||
@Override public final Iterable<String> getAbilities() { return abilities; }
|
||||
@Override public final Iterable<String> getStaticAbilities() { return staticAbilities; }
|
||||
@Override public final Iterable<String> getTriggers() { return triggers; }
|
||||
@Override public final Iterable<String> getReplacements() { return replacements; }
|
||||
@Override public final String getNonAbilityText() { return nonAbilityText; }
|
||||
@Override public final Iterable<Entry<String, String>> getVariables() { return variables.entrySet(); }
|
||||
@Override public Iterable<String> getKeywords() { return keywords; }
|
||||
@Override public Iterable<String> getAbilities() { return abilities; }
|
||||
@Override public Iterable<String> getStaticAbilities() { return staticAbilities; }
|
||||
@Override public Iterable<String> getTriggers() { return triggers; }
|
||||
@Override public Iterable<String> getReplacements() { return replacements; }
|
||||
@Override public String getNonAbilityText() { return nonAbilityText; }
|
||||
@Override public Iterable<Entry<String, String>> getVariables() { return variables.entrySet(); }
|
||||
|
||||
public CardFace(String name0) {
|
||||
this.name = name0;
|
||||
@@ -74,11 +74,11 @@ final class CardFace implements ICardFace {
|
||||
throw new RuntimeException("Card name is empty");
|
||||
}
|
||||
// Here come setters to allow parser supply values
|
||||
public final void setType(CardType type0) { this.type = type0; }
|
||||
public final void setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; }
|
||||
public final void setColor(ColorSet color0) { this.color = color0; }
|
||||
public final void setOracleText(String text) { this.oracleText = text; }
|
||||
public final void setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
||||
public void setType(CardType type0) { this.type = type0; }
|
||||
public void setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; }
|
||||
public void setColor(ColorSet color0) { this.color = color0; }
|
||||
public void setOracleText(String text) { this.oracleText = text; }
|
||||
public void setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
||||
|
||||
public void setPtText(String value) {
|
||||
final int slashPos = value.indexOf('/');
|
||||
@@ -92,13 +92,13 @@ final class CardFace implements ICardFace {
|
||||
}
|
||||
|
||||
// Raw fields used for Card creation
|
||||
public final void setNonAbilityText(String value) { this.nonAbilityText = value; }
|
||||
public final void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<String>(); } this.keywords.add(value); }
|
||||
public final void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<String>(); } this.abilities.add(value);}
|
||||
public final void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<String>(); } this.triggers.add(value);}
|
||||
public final void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<String>(); } this.staticAbilities.add(value);}
|
||||
public final void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<String>(); } this.replacements.add(value);}
|
||||
public final void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
|
||||
public void setNonAbilityText(String value) { this.nonAbilityText = value; }
|
||||
public void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<String>(); } this.keywords.add(value); }
|
||||
public void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<String>(); } this.abilities.add(value);}
|
||||
public void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<String>(); } this.triggers.add(value);}
|
||||
public void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<String>(); } this.staticAbilities.add(value);}
|
||||
public void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<String>(); } this.replacements.add(value);}
|
||||
public void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
|
||||
|
||||
|
||||
public void assignMissingFields() { // Most scripts do not specify color explicitly
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
|
||||
/**
|
||||
* Base class for Triggers and ReplacementEffects.
|
||||
@@ -144,4 +153,174 @@ public abstract class TriggerReplacementBase {
|
||||
public final boolean isSuppressed() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,7 +980,7 @@ public class AbilityUtils {
|
||||
|
||||
// Replace AnyColor with the 5 colors
|
||||
if (choices.contains("AnyColor")) {
|
||||
gains.addAll(Arrays.asList(Constant.Color.ONLY_COLORS));
|
||||
gains.addAll(Constant.Color.ONLY_COLORS);
|
||||
choices = choices.replaceAll("AnyColor,?", "");
|
||||
}
|
||||
// Add any remaining choices
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -26,7 +25,7 @@ import forge.game.zone.ZoneType;
|
||||
|
||||
public class ProtectAi extends SpellAbilityAi {
|
||||
private static boolean hasProtectionFrom(final Card card, final String color) {
|
||||
final ArrayList<String> onlyColors = new ArrayList<String>(Arrays.asList(Constant.Color.ONLY_COLORS));
|
||||
final ArrayList<String> onlyColors = new ArrayList<String>(Constant.Color.ONLY_COLORS);
|
||||
|
||||
// make sure we have a valid color
|
||||
if (!onlyColors.contains(color)) {
|
||||
|
||||
@@ -18,11 +18,6 @@ import forge.util.MyRandom;
|
||||
public class TapAi extends TapAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
|
||||
final PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final Player turn = phase.getPlayerTurn();
|
||||
@@ -38,6 +33,12 @@ public class TapAi extends TapAiBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
|
||||
if (tgt == null) {
|
||||
final List<Card> defined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
@@ -59,50 +60,4 @@ public class TapAi extends TapAiBase {
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(AIPlayer ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (tgt == null) {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: use Defined to determine, if this is an unfavorable result
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (tapPrefTargeting(ai, source, tgt, sa, mandatory)) {
|
||||
return true;
|
||||
} else if (mandatory) {
|
||||
// not enough preferred targets, but mandatory so keep going:
|
||||
return tapUnpreferredTargeting(ai, sa, mandatory);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, AIPlayer ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
if (tgt == null) {
|
||||
// either self or defined, either way should be fine
|
||||
} else {
|
||||
// target section, maybe pull this out?
|
||||
tgt.resetTargets();
|
||||
if (!tapPrefTargeting(ai, source, tgt, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.phase.CombatUtil;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -269,4 +270,50 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(AIPlayer ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (tgt == null) {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: use Defined to determine, if this is an unfavorable result
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (tapPrefTargeting(ai, source, tgt, sa, mandatory)) {
|
||||
return true;
|
||||
} else if (mandatory) {
|
||||
// not enough preferred targets, but mandatory so keep going:
|
||||
return tapUnpreferredTargeting(ai, sa, mandatory);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, AIPlayer ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
if (tgt == null) {
|
||||
// either self or defined, either way should be fine
|
||||
} else {
|
||||
// target section, maybe pull this out?
|
||||
tgt.resetTargets();
|
||||
if (!tapPrefTargeting(ai, source, tgt, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,49 +47,6 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(AIPlayer ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (tgt == null) {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: use Defined to determine if this is an unfavorable result
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (tapPrefTargeting(ai, source, tgt, sa, mandatory)) {
|
||||
return true;
|
||||
} else if (mandatory) {
|
||||
// not enough preferred targets, but mandatory so keep going:
|
||||
return tapUnpreferredTargeting(ai, sa, mandatory);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, AIPlayer ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
if (tgt == null) {
|
||||
// either self or defined, either way should be fine
|
||||
} else {
|
||||
// target section, maybe pull this out?
|
||||
tgt.resetTargets();
|
||||
if (!tapPrefTargeting(ai, source, tgt, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -234,7 +235,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// give back suppressed replacement effects
|
||||
for (final ReplacementEffect re : removedReplacements) {
|
||||
for (final TriggerReplacementBase re : removedReplacements) {
|
||||
re.setTemporarilySuppressed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import forge.Card;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -255,7 +256,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// give back suppressed replacement effects
|
||||
for (final ReplacementEffect re : removedReplacements) {
|
||||
for (final TriggerReplacementBase re : removedReplacements) {
|
||||
re.setTemporarilySuppressed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package forge.card.ability.effects;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
@@ -46,8 +48,8 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
if (sa.hasParam("OrColors")) {
|
||||
String[] choices = Constant.Color.ONLY_COLORS;
|
||||
final List<String> o = GuiChoose.getChoices("Choose a color or colors", 1, choices.length, choices);
|
||||
ImmutableList<String> choices = Constant.Color.ONLY_COLORS;
|
||||
final List<String> o = GuiChoose.getChoices("Choose a color or colors", 1, choices.size(), choices);
|
||||
card.setChosenColor(new ArrayList<String>(o));
|
||||
} else if (sa.hasParam("TwoColors")) {
|
||||
final List<String> o = GuiChoose.getChoices("Choose two colors", 2, 2, Constant.Color.ONLY_COLORS);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.card.ability.effects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
@@ -47,12 +48,12 @@ public class ManaEffect extends SpellAbilityEffect {
|
||||
//String colorsNeeded = abMana.getExpressChoice();
|
||||
String[] colorsProduced = abMana.getComboColors().split(" ");
|
||||
final StringBuilder choiceString = new StringBuilder();
|
||||
String[] colorMenu = null;
|
||||
List<String> colorMenu = null;
|
||||
if (!abMana.isAnyMana()) {
|
||||
colorMenu = new String[colorsProduced.length];
|
||||
colorMenu = new ArrayList<String>();
|
||||
//loop through colors to make menu
|
||||
for (int nColor = 0; nColor < colorsProduced.length; nColor++) {
|
||||
colorMenu[nColor] = forge.card.MagicColor.toLongString(colorsProduced[nColor]);
|
||||
colorMenu.add(forge.card.MagicColor.toLongString(colorsProduced[nColor]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -113,12 +114,12 @@ public class ManaEffect extends SpellAbilityEffect {
|
||||
choice = colorsNeeded;
|
||||
}
|
||||
else {
|
||||
String[] colorMenu = null;
|
||||
List<String> colorMenu = null;
|
||||
if (colorsNeeded.length() > 1 && colorsNeeded.length() < 5) {
|
||||
colorMenu = new String[colorsNeeded.length()];
|
||||
colorMenu = new ArrayList<String>();
|
||||
//loop through colors to make menu
|
||||
for (int nChar = 0; nChar < colorsNeeded.length(); nChar++) {
|
||||
colorMenu[nChar] = forge.card.MagicColor.toLongString(colorsNeeded.substring(nChar, nChar + 1));
|
||||
colorMenu.add(forge.card.MagicColor.toLongString(colorsNeeded.substring(nChar, nChar + 1)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -337,10 +337,10 @@ public class ManaPool {
|
||||
totalMana += normalMana[i];
|
||||
totalMana += snowMana[i];
|
||||
if (normalMana[i] > 0) {
|
||||
alChoice.add(Constant.Color.COLORS[i] + "(" + normalMana[i] + ")");
|
||||
alChoice.add(Constant.Color.COLORS.get(i) + "(" + normalMana[i] + ")");
|
||||
}
|
||||
if (snowMana[i] > 0) {
|
||||
alChoice.add("{S}" + Constant.Color.COLORS[i] + "(" + snowMana[i] + ")");
|
||||
alChoice.add("{S}" + Constant.Color.COLORS.get(i) + "(" + snowMana[i] + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
*/
|
||||
package forge.card.replacement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
@@ -31,7 +29,6 @@ import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
|
||||
/**
|
||||
@@ -175,46 +172,24 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean requirementsCheck() {
|
||||
return this.requirementsCheck(this.getMapParams());
|
||||
}
|
||||
|
||||
public boolean requirementsCheck(Map<String,String> params) {
|
||||
|
||||
if (this.isSuppressed()) {
|
||||
return false; // Effect removed by effect
|
||||
}
|
||||
|
||||
if (this.getMapParams().containsKey("Metalcraft")) {
|
||||
if (this.getMapParams().get("Metalcraft").equals("True")
|
||||
&& !this.getHostCard().getController().hasMetalcraft()) {
|
||||
if (params.containsKey("PlayerTurn")) {
|
||||
if (params.get("PlayerTurn").equals("True") && !Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
|
||||
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("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")) {
|
||||
if (params.containsKey("ActivePhases")) {
|
||||
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();
|
||||
for (final PhaseType s : aPhases) {
|
||||
if (s == currPhase) {
|
||||
@@ -226,171 +201,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
|
||||
return isPhase;
|
||||
}
|
||||
|
||||
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("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;
|
||||
return meetsCommonRequirements(params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.Singletons;
|
||||
import forge.StaticEffect;
|
||||
import forge.StaticEffects;
|
||||
import forge.card.CardType;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -143,7 +144,7 @@ public class StaticAbilityContinuous {
|
||||
|
||||
if (params.containsKey("AddKeyword")) {
|
||||
addKeywords = params.get("AddKeyword").split(" & ");
|
||||
final ArrayList<String> chosencolors = hostCard.getChosenColor();
|
||||
final List<String> chosencolors = hostCard.getChosenColor();
|
||||
for (final String color : chosencolors) {
|
||||
for (int w = 0; w < addKeywords.length; w++) {
|
||||
addKeywords[w] = addKeywords[w].replaceAll("ChosenColor", color.substring(0, 1).toUpperCase().concat(color.substring(1, color.length())));
|
||||
@@ -435,7 +436,7 @@ public class StaticAbilityContinuous {
|
||||
stA.setTemporarilySuppressed(true);
|
||||
}
|
||||
final ArrayList<ReplacementEffect> replacementEffects = affectedCard.getReplacementEffects();
|
||||
for (final ReplacementEffect rE : replacementEffects) {
|
||||
for (final TriggerReplacementBase rE : replacementEffects) {
|
||||
rE.setTemporarilySuppressed(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,19 +23,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -275,77 +270,7 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
* a {@link java.util.HashMap} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean requirementsCheck(final java.util.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;
|
||||
}
|
||||
|
||||
}
|
||||
public final boolean requirementsCheck(final Map<String, Object> runParams2) {
|
||||
|
||||
if (this.getMapParams().containsKey("APlayerHasMoreLifeThanEachOther")) {
|
||||
int highestLife = -50; // Negative base just in case a few Lich's or Platinum Angels are running around
|
||||
@@ -387,125 +312,8 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
if ( !meetsCommonRequirements(getMapParams()))
|
||||
return false;
|
||||
|
||||
if (this.getMapParams().containsKey("EvolveCondition")) {
|
||||
if (this.getMapParams().get("EvolveCondition").equals("True")) {
|
||||
|
||||
@@ -37,11 +37,11 @@ import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.CardType;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.effects.AttachEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.replacement.ReplacementResult;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -166,7 +166,7 @@ public class GameAction {
|
||||
for (final Trigger trigger : copied.getTriggers()) {
|
||||
trigger.setHostCard(copied);
|
||||
}
|
||||
for (final ReplacementEffect repl : copied.getReplacementEffects()) {
|
||||
for (final TriggerReplacementBase repl : copied.getReplacementEffects()) {
|
||||
repl.setHostCard(copied);
|
||||
}
|
||||
if (c.getName().equals("Skullbriar, the Walking Grave")) {
|
||||
|
||||
@@ -980,7 +980,7 @@ public final class GameActionUtil {
|
||||
for (final Card oldman : list) {
|
||||
if (!oldman.getGainControlTargets().isEmpty()) {
|
||||
if (oldman.getNetAttack() < oldman.getGainControlTargets().get(0).getNetAttack()) {
|
||||
final ArrayList<Command> coms = oldman.getGainControlReleaseCommands();
|
||||
final List<Command> coms = oldman.getGainControlReleaseCommands();
|
||||
for (int i = 0; i < coms.size(); i++) {
|
||||
coms.get(i).execute();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ public class SealedDeck extends LimitedDeck {
|
||||
int green = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_GREEN));
|
||||
|
||||
final int[] colorCounts = { white, blue, black, red, green };
|
||||
final String[] colors = Constant.Color.ONLY_COLORS;
|
||||
int[] countsCopy = Arrays.copyOf(colorCounts, 5);
|
||||
Arrays.sort(countsCopy);
|
||||
|
||||
@@ -68,9 +67,9 @@ public class SealedDeck extends LimitedDeck {
|
||||
List<String> secondColors = new ArrayList<String>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (countsCopy[4] == colorCounts[i]) {
|
||||
maxColors.add(colors[i]);
|
||||
maxColors.add(Constant.Color.ONLY_COLORS.get(i));
|
||||
} else if (countsCopy[3] == colorCounts[i]) {
|
||||
secondColors.add(colors[i]);
|
||||
secondColors.add(Constant.Color.ONLY_COLORS.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public class Untap extends Phase {
|
||||
String prompt = "Untap " + c.getName() + "?";
|
||||
boolean defaultChoice = true;
|
||||
if (c.getGainControlTargets().size() > 0) {
|
||||
final ArrayList<Card> targets = c.getGainControlTargets();
|
||||
final List<Card> targets = c.getGainControlTargets();
|
||||
prompt += "\r\n" + c + " is controlling: ";
|
||||
for (final Card target : targets) {
|
||||
prompt += target;
|
||||
@@ -166,7 +166,7 @@ public class Untap extends Phase {
|
||||
// leave it tapped
|
||||
// if not, untap it
|
||||
if (c.getGainControlTargets().size() > 0) {
|
||||
final ArrayList<Card> targets = c.getGainControlTargets();
|
||||
final List<Card> targets = c.getGainControlTargets();
|
||||
boolean untap = true;
|
||||
for (final Card target : targets) {
|
||||
if (target.isInPlay()) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import forge.Singletons;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.home.quest.VSubmenuQuestPrefs.PrefInput;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
|
||||
/**
|
||||
* Controls the quest preferences submenu in the home UI.
|
||||
@@ -43,79 +42,15 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
||||
public static void validateAndSave(PrefInput i0) {
|
||||
if (i0.getText().equals(i0.getPreviousText())) { return; }
|
||||
final QuestPreferences prefs = Singletons.getModel().getQuestPreferences();
|
||||
int temp1, temp2;
|
||||
|
||||
int val = Integer.parseInt(i0.getText());
|
||||
resetErrors();
|
||||
|
||||
switch (i0.getQPref()) {
|
||||
case STARTING_CREDITS_EASY: case STARTING_CREDITS_MEDIUM:
|
||||
case STARTING_CREDITS_HARD: case STARTING_CREDITS_EXPERT:
|
||||
case REWARDS_MILLED: case REWARDS_MULLIGAN0:
|
||||
case REWARDS_ALTERNATIVE: case REWARDS_TURN5:
|
||||
if (val > 500) {
|
||||
showError(i0, "Value too large (maximum 500).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_COMMONS:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_UNCOMMONS:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_RARES:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case REWARDS_TURN1:
|
||||
if (val > 2000) {
|
||||
showError(i0, "Value too large (maximum 2000).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SHOP_STARTING_PACKS:
|
||||
case SHOP_SINGLES_COMMON: case SHOP_SINGLES_UNCOMMON: case SHOP_SINGLES_RARE:
|
||||
if (val < 0) {
|
||||
showError(i0, "Value too small (minimum 0).");
|
||||
return;
|
||||
} else if (val > 15) {
|
||||
showError(i0, "Value too large (maximum 15).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SHOP_WINS_FOR_ADDITIONAL_PACK: case SHOP_MAX_PACKS:
|
||||
if (val < 1) {
|
||||
showError(i0, "Value too small (minimum 1).");
|
||||
return;
|
||||
} else if (val > 25) {
|
||||
showError(i0, "Value too large (maximum 25).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (val > 100) {
|
||||
showError(i0, "Value too large (maximum 100).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
String validationError = QuestPreferencesHandler.validatePreference(i0.getQPref(), val, prefs);
|
||||
if( null != validationError)
|
||||
{
|
||||
showError(i0, validationError);
|
||||
return;
|
||||
}
|
||||
|
||||
prefs.setPref(i0.getQPref(), i0.getText());
|
||||
|
||||
@@ -323,7 +323,7 @@ public class QuestPreferencesHandler extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private int temp1, temp2;
|
||||
|
||||
/**
|
||||
* Checks validity of values entered into prefInputs.
|
||||
* @param i0   a PrefInput object
|
||||
@@ -334,74 +334,11 @@ public class QuestPreferencesHandler extends JPanel {
|
||||
int val = Integer.parseInt(i0.getText());
|
||||
resetErrors();
|
||||
|
||||
switch (i0.getQPref()) {
|
||||
case STARTING_CREDITS_EASY: case STARTING_CREDITS_MEDIUM:
|
||||
case STARTING_CREDITS_HARD: case STARTING_CREDITS_EXPERT:
|
||||
case REWARDS_MILLED: case REWARDS_MULLIGAN0:
|
||||
case REWARDS_ALTERNATIVE: case REWARDS_TURN5:
|
||||
if (val > 500) {
|
||||
showError(i0, "Value too large (maximum 500).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_COMMONS:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_UNCOMMONS:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BOOSTER_RARES:
|
||||
temp1 = prefs.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = prefs.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
showError(i0, "Booster packs must have maximum 15 cards.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case REWARDS_TURN1:
|
||||
if (val > 2000) {
|
||||
showError(i0, "Value too large (maximum 2000).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SHOP_STARTING_PACKS:
|
||||
case SHOP_SINGLES_COMMON: case SHOP_SINGLES_UNCOMMON: case SHOP_SINGLES_RARE:
|
||||
if (val < 0) {
|
||||
showError(i0, "Value too small (minimum 0).");
|
||||
return;
|
||||
} else if (val > 15) {
|
||||
showError(i0, "Value too large (maximum 15).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SHOP_WINS_FOR_ADDITIONAL_PACK: case SHOP_MAX_PACKS:
|
||||
if (val < 1) {
|
||||
showError(i0, "Value too small (minimum 1).");
|
||||
return;
|
||||
} else if (val > 25) {
|
||||
showError(i0, "Value too large (maximum 25).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (val > 100) {
|
||||
showError(i0, "Value too large (maximum 100).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
String validationError = validatePreference(i0.getQPref(), val, prefs);
|
||||
if( null != validationError)
|
||||
{
|
||||
showError(i0, validationError);
|
||||
return;
|
||||
}
|
||||
|
||||
prefs.setPref(i0.getQPref(), i0.getText());
|
||||
@@ -409,6 +346,70 @@ public class QuestPreferencesHandler extends JPanel {
|
||||
i0.setPreviousText(i0.getText());
|
||||
}
|
||||
|
||||
public static String validatePreference(QPref qpref, int val, QuestPreferences current) {
|
||||
int temp1, temp2;
|
||||
switch (qpref) {
|
||||
case STARTING_CREDITS_EASY: case STARTING_CREDITS_MEDIUM:
|
||||
case STARTING_CREDITS_HARD: case STARTING_CREDITS_EXPERT:
|
||||
case REWARDS_MILLED: case REWARDS_MULLIGAN0:
|
||||
case REWARDS_ALTERNATIVE: case REWARDS_TURN5:
|
||||
if (val > 500) {
|
||||
return "Value too large (maximum 500).";
|
||||
}
|
||||
break;
|
||||
case BOOSTER_COMMONS:
|
||||
temp1 = current.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
temp2 = current.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
return "Booster packs must have maximum 15 cards.";
|
||||
}
|
||||
break;
|
||||
case BOOSTER_UNCOMMONS:
|
||||
temp1 = current.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = current.getPrefInt(QPref.BOOSTER_RARES);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
return "Booster packs must have maximum 15 cards.";
|
||||
}
|
||||
break;
|
||||
case BOOSTER_RARES:
|
||||
temp1 = current.getPrefInt(QPref.BOOSTER_COMMONS);
|
||||
temp2 = current.getPrefInt(QPref.BOOSTER_UNCOMMONS);
|
||||
|
||||
if (temp1 + temp2 + val > 15) {
|
||||
return "Booster packs must have maximum 15 cards.";
|
||||
}
|
||||
break;
|
||||
case REWARDS_TURN1:
|
||||
if (val > 2000) {
|
||||
return "Value too large (maximum 2000).";
|
||||
}
|
||||
break;
|
||||
case SHOP_STARTING_PACKS:
|
||||
case SHOP_SINGLES_COMMON: case SHOP_SINGLES_UNCOMMON: case SHOP_SINGLES_RARE:
|
||||
if (val < 0) {
|
||||
return "Value too small (minimum 0).";
|
||||
} else if (val > 15) {
|
||||
return "Value too large (maximum 15).";
|
||||
}
|
||||
break;
|
||||
case SHOP_WINS_FOR_ADDITIONAL_PACK: case SHOP_MAX_PACKS:
|
||||
if (val < 1) {
|
||||
return "Value too small (minimum 1).";
|
||||
} else if (val > 25) {
|
||||
return "Value too large (maximum 25).";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (val > 100) {
|
||||
return "Value too large (maximum 100).";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void showError(PrefInput i0, String s0) {
|
||||
String s = "Save failed: " + s0;
|
||||
switch(i0.getErrType()) {
|
||||
|
||||
Reference in New Issue
Block a user