();
repParams.put("Event", "GainLife");
repParams.put("Affected", this);
repParams.put("LifeGained", toGain);
@@ -336,7 +337,7 @@ public abstract class Player extends GameEntity {
if (!this.canGainLife()) {
return false;
}
- int lifeGain = toGain;
+ final int lifeGain = toGain;
if (lifeGain > 0) {
this.addLife(lifeGain);
@@ -363,8 +364,8 @@ public abstract class Player extends GameEntity {
* @return a boolean.
*/
public final boolean canGainLife() {
- if (AllZoneUtil.isCardInPlay("Leyline of Punishment")
- || AllZoneUtil.isCardInPlay("Platinum Emperion", this) || AllZoneUtil.isCardInPlay("Forsaken Wastes")) {
+ if (AllZoneUtil.isCardInPlay("Leyline of Punishment") || AllZoneUtil.isCardInPlay("Platinum Emperion", this)
+ || AllZoneUtil.isCardInPlay("Forsaken Wastes")) {
return false;
}
return true;
@@ -505,9 +506,9 @@ public abstract class Player extends GameEntity {
final StringBuilder sb = new StringBuilder(
"As long as you have 0 or less life, all damage is dealt to you as though its source had infect.");
- if (this.getLife() <= 0 && !infect) {
- CardList cards = this.getCardsIn(Zone.Battlefield);
- for (Card card : cards) {
+ if ((this.getLife() <= 0) && !infect) {
+ final CardList cards = this.getCardsIn(Zone.Battlefield);
+ for (final Card card : cards) {
if (card.hasKeyword(sb.toString())) {
infect = true;
break;
@@ -645,7 +646,8 @@ public abstract class Player extends GameEntity {
// This should be also usable by the AI to forecast an effect (so it must
// not change the game state)
- // 2012/01/02: No longer used in calculating the finalized damage, but retained for damageprediction. -Hellfish
+ // 2012/01/02: No longer used in calculating the finalized damage, but
+ // retained for damageprediction. -Hellfish
/**
*
* staticReplaceDamage.
@@ -678,21 +680,21 @@ public abstract class Player extends GameEntity {
restDamage += 2;
}
}
-//
+ //
if (AllZoneUtil.isCardInPlay("Furnace of Rath")) {
final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Furnace of Rath").size();
for (int i = 0; i < amount; i++) {
restDamage += restDamage;
}
}
-//
+ //
if (AllZoneUtil.isCardInPlay("Gratuitous Violence", source.getController()) && source.isCreature()) {
final int amount = source.getController().getCardsIn(Zone.Battlefield, "Gratuitous Violence").size();
for (int i = 0; i < amount; i++) {
restDamage += restDamage;
}
}
-//
+ //
if (AllZoneUtil.isCardInPlay("Fire Servant", source.getController()) && source.isRed()
&& (source.isInstant() || source.isSorcery())) {
final int amount = source.getController().getCardsIn(Zone.Battlefield, "Fire Servant").size();
@@ -716,7 +718,7 @@ public abstract class Player extends GameEntity {
restDamage = 3;
}
-//
+ //
if (AllZoneUtil.isCardInPlay("Forethought Amulet", this) && (source.isInstant() || source.isSorcery())
&& (restDamage > 2)) {
@@ -742,8 +744,8 @@ public abstract class Player extends GameEntity {
@Override
public final int replaceDamage(final int damage, final Card source, final boolean isCombat) {
- //Replacement effects
- HashMap repParams = new HashMap();
+ // Replacement effects
+ final HashMap repParams = new HashMap();
repParams.put("Event", "DamageDone");
repParams.put("Affected", this);
repParams.put("DamageSource", source);
@@ -848,7 +850,7 @@ public abstract class Player extends GameEntity {
*/
public final int getAssignedDamage() {
int num = 0;
- for (Integer value : assignedDamage.values()) {
+ for (final Integer value : this.assignedDamage.values()) {
num += value;
}
return num;
@@ -864,15 +866,15 @@ public abstract class Player extends GameEntity {
*
* @return a int.
*/
- public final int getAssignedDamage(String type) {
- Map valueMap = new HashMap();
- for (Card c : assignedDamage.keySet()) {
+ public final int getAssignedDamage(final String type) {
+ final Map valueMap = new HashMap();
+ for (final Card c : this.assignedDamage.keySet()) {
if (c.isType(type)) {
- valueMap.put(c, assignedDamage.get(c));
+ valueMap.put(c, this.assignedDamage.get(c));
}
}
int num = 0;
- for (Integer value : valueMap.values()) {
+ for (final Integer value : valueMap.values()) {
num += value;
}
return num;
@@ -915,9 +917,11 @@ public abstract class Player extends GameEntity {
*
* addPoisonCounters.
*
- *
- * @param num a int.
- * @param source the source
+ *
+ * @param num
+ * a int.
+ * @param source
+ * the source
*/
public final void addPoisonCounters(final int num, final Card source) {
if (!this.hasKeyword("You can't get poison counters")) {
@@ -1242,8 +1246,8 @@ public abstract class Player extends GameEntity {
final CardList drawn = new CardList();
final PlayerZone library = this.getZone(Constant.Zone.Library);
- //Replacement effects
- HashMap repRunParams = new HashMap();
+ // Replacement effects
+ final HashMap repRunParams = new HashMap();
repRunParams.put("Event", "Draw");
repRunParams.put("Affected", this);
@@ -1257,10 +1261,10 @@ public abstract class Player extends GameEntity {
c = AllZone.getGameAction().moveToHand(c);
drawn.add(c);
- if (numDrawnThisTurn == 0 && this.isComputer()) {
+ if ((this.numDrawnThisTurn == 0) && this.isComputer()) {
boolean reveal = false;
- CardList cards = this.getCardsIn(Zone.Battlefield);
- for (Card card : cards) {
+ final CardList cards = this.getCardsIn(Zone.Battlefield);
+ for (final Card card : cards) {
if (card.hasKeyword("Reveal the first card you draw each turn")) {
reveal = true;
break;
@@ -1278,7 +1282,7 @@ public abstract class Player extends GameEntity {
// Run triggers
final HashMap runParams = new HashMap();
runParams.put("Card", c);
- runParams.put("Number", numDrawnThisTurn);
+ runParams.put("Number", this.numDrawnThisTurn);
AllZone.getTriggerHandler().runTrigger("Drawn", runParams);
}
// lose:
@@ -1790,7 +1794,7 @@ public abstract class Player extends GameEntity {
// etc...)
AllZone.getGameAction().checkStateEffects();
- //add to log
+ // add to log
AllZone.getGameLog().add("Land", this + " played " + land, 2);
// Run triggers
@@ -1810,7 +1814,8 @@ public abstract class Player extends GameEntity {
* @return a boolean.
*/
public final boolean canPlayLand() {
- if (Singletons.getView().getMatchView().getViewTabber().getLblUnlimitedLands().getEnabled() && this.isHuman() && Constant.Runtime.DEV_MODE[0]) {
+ if (Singletons.getView().getMatchView().getViewTabber().getLblUnlimitedLands().getEnabled() && this.isHuman()
+ && Constant.Runtime.DEV_MODE[0]) {
return PhaseHandler.canCastSorcery(this);
}
@@ -2145,8 +2150,8 @@ public abstract class Player extends GameEntity {
return false;
}
- //Replacement effects
- HashMap runParams = new HashMap();
+ // Replacement effects
+ final HashMap runParams = new HashMap();
runParams.put("Affected", this);
runParams.put("Event", "GameLoss");
@@ -2241,7 +2246,7 @@ public abstract class Player extends GameEntity {
}
if (this.lossState != GameLossReason.DidNotLoseYet) {
- return this.loseConditionMet(lossState, null);
+ return this.loseConditionMet(this.lossState, null);
}
if (this.poisonCounters >= 10) {
@@ -2374,11 +2379,11 @@ public abstract class Player extends GameEntity {
return false;
}
} else if (incR[0].equals("EnchantedController")) {
- GameEntity enchanted = source.getEnchanting();
- if (enchanted == null || !(enchanted instanceof Card)) {
+ final GameEntity enchanted = source.getEnchanting();
+ if ((enchanted == null) || !(enchanted instanceof Card)) {
return false;
}
- Card enchantedCard = (Card) enchanted;
+ final Card enchantedCard = (Card) enchanted;
if (!this.equals(enchantedCard.getController())) {
return false;
}
@@ -2730,6 +2735,9 @@ public abstract class Player extends GameEntity {
return this.mustAttackEntity;
}
+ /**
+ * Update label observers.
+ */
public final void updateLabelObservers() {
this.getZone(Zone.Hand).updateObservers();
}
diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java
index e946c133144..1bcf5d209dc 100644
--- a/src/main/java/forge/Upkeep.java
+++ b/src/main/java/forge/Upkeep.java
@@ -486,8 +486,11 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
- Singletons.getControl().getMatchControl().showMessage(
- abyss.getName() + " - Select one nonartifact creature to destroy");
+ Singletons
+ .getControl()
+ .getMatchControl()
+ .showMessage(
+ abyss.getName() + " - Select one nonartifact creature to destroy");
ButtonUtil.disableAll();
}
@@ -554,8 +557,11 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
- Singletons.getControl().getMatchControl().showMessage(
- "Yawgmoth Demon - Select one artifact to sacrifice or be dealt 2 damage");
+ Singletons
+ .getControl()
+ .getMatchControl()
+ .showMessage(
+ "Yawgmoth Demon - Select one artifact to sacrifice or be dealt 2 damage");
ButtonUtil.enableOnlyCancel();
}
@@ -2252,8 +2258,8 @@ public class Upkeep extends Phase implements java.io.Serializable {
private static void upkeepVesuvanDoppelgangerKeyword() {
final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final String keyword = "At the beginning of your upkeep, you may have this "
- + "creature become a copy of target creature except it doesn't copy that "
- + "creature's color. If you do, this creature gains this ability.";
+ + "creature become a copy of target creature except it doesn't copy that "
+ + "creature's color. If you do, this creature gains this ability.";
CardList list = player.getCardsIn(Zone.Battlefield);
list = list.getKeyword(keyword);
@@ -2261,7 +2267,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
final SpellAbility ability = new Ability(c, "0") {
@Override
public void resolve() {
- StringBuilder question = new StringBuilder();
+ final StringBuilder question = new StringBuilder();
question.append("Use triggered ability of ").append(c).append("?");
question.append("\r\n").append("(").append(keyword).append(")").append("\r\n");
if (GameActionUtil.showYesNoDialog(c, question.toString(), true)) {
@@ -2274,14 +2280,14 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (newTarget[0] != null) {
/*
- * 1. need to select new card - DONE 1a. need to
- * create the newly copied card with pic and
- * setinfo 2. need to add the leaves play
- * command 3. need to transfer the keyword 4.
- * need to update the clone origin of new card
- * and old card 5. remove clone leaves play
- * commands from old 5a. remove old from play 6.
- * add new to play
+ * 1. need to select new card - DONE 1a.
+ * need to create the newly copied card with
+ * pic and setinfo 2. need to add the leaves
+ * play command 3. need to transfer the
+ * keyword 4. need to update the clone
+ * origin of new card and old card 5. remove
+ * clone leaves play commands from old 5a.
+ * remove old from play 6. add new to play
*/
final Card newCopy = AllZone.getCardFactory().getCard(
@@ -2308,8 +2314,8 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
- Singletons.getControl().getMatchControl().showMessage(
- c.getName() + " - Select target creature.");
+ Singletons.getControl().getMatchControl()
+ .showMessage(c.getName() + " - Select target creature.");
ButtonUtil.enableOnlyCancel();
}
@@ -2382,9 +2388,14 @@ public class Upkeep extends Phase implements java.io.Serializable {
this.stop();
return;
}
- Singletons.getControl().getMatchControl().showMessage(
- source.getName() + " - Select " + num
- + " untapped artifact(s), creature(s), or land(s) you control");
+ Singletons
+ .getControl()
+ .getMatchControl()
+ .showMessage(
+ source.getName()
+ + " - Select "
+ + num
+ + " untapped artifact(s), creature(s), or land(s) you control");
ButtonUtil.disableAll();
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySplice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySplice.java
new file mode 100644
index 00000000000..858968481ff
--- /dev/null
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySplice.java
@@ -0,0 +1,490 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Forge Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package forge.card.abilityfactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import forge.AllZone;
+import forge.Card;
+import forge.ComputerUtil;
+import forge.card.cardfactory.CardFactoryUtil;
+import forge.card.cost.Cost;
+import forge.card.cost.CostUtil;
+import forge.card.spellability.AbilityActivated;
+import forge.card.spellability.AbilitySub;
+import forge.card.spellability.Spell;
+import forge.card.spellability.SpellAbility;
+import forge.card.spellability.SpellAbilityStackInstance;
+import forge.card.spellability.Target;
+import forge.card.spellability.TargetSelection;
+import forge.util.MyRandom;
+
+//Examples:
+//A:SP$ Splice | Cost$ 1 G | TargetType$ Arcane | SpellDescription$ Counter target activated ability.
+
+/**
+ *
+ * AbilityFactorySplice class.
+ *
+ *
+ * @author Forge
+ * @version $Id$
+ */
+public class AbilityFactorySplice {
+
+ private AbilityFactory abilityFactory = null;
+ private HashMap params = null;
+ private String unlessCost = null;
+
+ /**
+ *
+ * Constructor for AbilityFactorySplice.
+ *
+ *
+ * @param newAbilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ */
+ public AbilityFactorySplice(final AbilityFactory newAbilityFactory) {
+ this.abilityFactory = newAbilityFactory;
+ this.params = this.abilityFactory.getMapParams();
+
+ if (this.params.containsKey("UnlessCost")) {
+ this.unlessCost = this.params.get("UnlessCost").trim();
+ }
+
+ }
+
+ /**
+ *
+ * getAbilitySplice.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @return a {@link forge.card.spellability.SpellAbility} object.
+ */
+ public final SpellAbility getAbilitySplice(final AbilityFactory abilityFactory) {
+ final SpellAbility abilitySplice = new AbilityActivated(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
+ abilityFactory.getAbTgt()) {
+ private static final long serialVersionUID = -3895990436431818899L;
+
+ @Override
+ public String getStackDescription() {
+ // when getStackDesc is called, just build exactly what is
+ // happening
+ return AbilityFactorySplice.this
+ .spliceStackDescription(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public boolean canPlayAI() {
+ return AbilityFactorySplice.this.spliceCanPlayAI(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public void resolve() {
+ AbilityFactorySplice.this.spliceResolve(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public boolean doTrigger(final boolean mandatory) {
+ return AbilityFactorySplice.this.spliceCanPlayAI(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ };
+ return abilitySplice;
+ }
+
+ /**
+ *
+ * getSpellSplice.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @return a {@link forge.card.spellability.SpellAbility} object.
+ */
+ public final SpellAbility getSpellSplice(final AbilityFactory abilityFactory) {
+ final SpellAbility spellAbilitySplice = new Spell(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
+ abilityFactory.getAbTgt()) {
+ private static final long serialVersionUID = -4272851734871573693L;
+
+ @Override
+ public String getStackDescription() {
+ return AbilityFactorySplice.this
+ .spliceStackDescription(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public boolean canPlayAI() {
+ return AbilityFactorySplice.this.spliceCanPlayAI(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public void resolve() {
+ AbilityFactorySplice.this.spliceResolve(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ };
+ return spellAbilitySplice;
+ }
+
+ /**
+ *
+ * getDrawbackSplice.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @return a {@link forge.card.spellability.SpellAbility} object.
+ */
+ public final SpellAbility getDrawbackSplice(final AbilityFactory abilityFactory) {
+ final SpellAbility drawbackSplice = new AbilitySub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
+ private static final long serialVersionUID = -4272851734871573693L;
+
+ @Override
+ public String getStackDescription() {
+ return AbilityFactorySplice.this
+ .spliceStackDescription(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public boolean canPlayAI() {
+ return AbilityFactorySplice.this.spliceCanPlayAI(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public void resolve() {
+ AbilityFactorySplice.this.spliceResolve(AbilityFactorySplice.this.abilityFactory, this);
+ }
+
+ @Override
+ public boolean chkAIDrawback() {
+ return AbilityFactorySplice.this.spliceDoTriggerAI(AbilityFactorySplice.this.abilityFactory, this,
+ true);
+ }
+
+ @Override
+ public boolean doTrigger(final boolean mandatory) {
+ return AbilityFactorySplice.this.spliceDoTriggerAI(AbilityFactorySplice.this.abilityFactory, this,
+ mandatory);
+ }
+
+ };
+ return drawbackSplice;
+ }
+
+ /**
+ *
+ * spliceCanPlayAI.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @param spellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ * @return a boolean.
+ */
+ private boolean spliceCanPlayAI(final AbilityFactory abilityFactory, final SpellAbility spellAbility) {
+ boolean toReturn = true;
+ final Cost abCost = abilityFactory.getAbCost();
+ final Card source = spellAbility.getSourceCard();
+ if (AllZone.getStack().size() < 1) {
+ return false;
+ }
+
+ if (abCost != null) {
+ // AI currently disabled for these costs
+ if (!CostUtil.checkSacrificeCost(abCost, source)) {
+ return false;
+ }
+ if (!CostUtil.checkLifeCost(abCost, source, 4)) {
+ return false;
+ }
+ }
+
+ final Target tgt = spellAbility.getTarget();
+ if (tgt != null) {
+
+ final SpellAbility topSA = AllZone.getStack().peekAbility();
+ if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) {
+ return false;
+ }
+
+ tgt.resetTargets();
+ if (TargetSelection.matchSpellAbility(spellAbility, topSA, tgt)) {
+ tgt.addTarget(topSA);
+ } else {
+ return false;
+ }
+ }
+
+ if (this.unlessCost != null) {
+ // Is this Usable Mana Sources? Or Total Available Mana?
+ final int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.getHumanPlayer());
+ int toPay = 0;
+ boolean setPayX = false;
+ if (this.unlessCost.equals("X") && source.getSVar(this.unlessCost).equals("Count$xPaid")) {
+ setPayX = true;
+ toPay = ComputerUtil.determineLeftoverMana(spellAbility);
+ } else {
+ toPay = AbilityFactory.calculateAmount(source, this.unlessCost, spellAbility);
+ }
+
+ if (toPay == 0) {
+ return false;
+ }
+
+ if (toPay <= usableManaSources) {
+ // If this is a reusable Resource, feel free to play it most of
+ // the time
+ if (!spellAbility.getPayCosts().isReusuableResource() || (MyRandom.getRandom().nextFloat() < .4)) {
+ return false;
+ }
+ }
+
+ if (setPayX) {
+ source.setSVar("PayX", Integer.toString(toPay));
+ }
+ }
+
+ // TODO Improve AI
+
+ // Will return true if this spell can counter (or is Reusable and can
+ // force the Human into making decisions)
+
+ // But really it should be more picky about how it counters things
+
+ final AbilitySub subAb = spellAbility.getSubAbility();
+ if (subAb != null) {
+ toReturn &= subAb.chkAIDrawback();
+ }
+
+ return toReturn;
+ }
+
+ /**
+ *
+ * spliceDoTriggerAI.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @param spellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ * @param mandatory
+ * a boolean.
+ * @return a boolean.
+ */
+ private boolean spliceDoTriggerAI(final AbilityFactory abilityFactory, final SpellAbility spellAbility, final boolean mandatory) {
+ boolean toReturn = true;
+ if (AllZone.getStack().size() < 1) {
+ return false;
+ }
+
+ final Target tgt = spellAbility.getTarget();
+ if (tgt != null) {
+ final SpellAbility topSA = AllZone.getStack().peekAbility();
+ if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) {
+ return false;
+ }
+
+ tgt.resetTargets();
+ if (TargetSelection.matchSpellAbility(spellAbility, topSA, tgt)) {
+ tgt.addTarget(topSA);
+ } else {
+ return false;
+ }
+
+ final Card source = spellAbility.getSourceCard();
+ if (this.unlessCost != null) {
+ // Is this Usable Mana Sources? Or Total Available Mana?
+ final int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.getHumanPlayer());
+ int toPay = 0;
+ boolean setPayX = false;
+ if (this.unlessCost.equals("X") && source.getSVar(this.unlessCost).equals("Count$xPaid")) {
+ setPayX = true;
+ toPay = ComputerUtil.determineLeftoverMana(spellAbility);
+ } else {
+ toPay = AbilityFactory.calculateAmount(source, this.unlessCost, spellAbility);
+ }
+
+ if (toPay == 0) {
+ return false;
+ }
+
+ if (toPay <= usableManaSources) {
+ // If this is a reusable Resource, feel free to play it most
+ // of the time
+ if (!spellAbility.getPayCosts().isReusuableResource() || (MyRandom.getRandom().nextFloat() < .4)) {
+ return false;
+ }
+ }
+
+ if (setPayX) {
+ source.setSVar("PayX", Integer.toString(toPay));
+ }
+ }
+ }
+
+ // TODO Improve AI
+
+ // Will return true if this spell can counter (or is Reusable and can
+ // force the Human into making decisions)
+
+ // But really it should be more picky about how it counters things
+
+ final AbilitySub subAb = spellAbility.getSubAbility();
+ if (subAb != null) {
+ toReturn &= subAb.chkAIDrawback();
+ }
+
+ return toReturn;
+ }
+
+ /**
+ *
+ * spliceResolve.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @param spellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ */
+ private void spliceResolve(final AbilityFactory abilityFactory, final SpellAbility spellAbility) {
+
+ // TODO Before this resolves we should see if any of our targets are
+ // still on the stack
+ ArrayList sas;
+
+ final Target tgt = abilityFactory.getAbTgt();
+ if (tgt != null) {
+ sas = tgt.getTargetSAs();
+ } else {
+ sas = AbilityFactory.getDefinedSpellAbilities(spellAbility.getSourceCard(), this.params.get("Defined"), spellAbility);
+ }
+
+ if (this.params.containsKey("ForgetOtherTargets")) {
+ if (this.params.get("ForgetOtherTargets").equals("True")) {
+ abilityFactory.getHostCard().clearRemembered();
+ }
+ }
+
+ for (final SpellAbility tgtSA : sas) {
+ final Card tgtSACard = tgtSA.getSourceCard();
+
+ if (tgtSA.isSpell() && !CardFactoryUtil.isCounterable(tgtSACard)) {
+ continue;
+ }
+
+ final SpellAbilityStackInstance si = AllZone.getStack().getInstanceFromSpellAbility(tgtSA);
+ if (si == null) {
+ continue;
+ }
+
+ this.removeFromStack(tgtSA, spellAbility, si);
+
+ // Destroy Permanent may be able to be turned into a SubAbility
+ if (tgtSA.isAbility() && this.params.containsKey("DestroyPermanent")) {
+ AllZone.getGameAction().destroy(tgtSACard);
+ }
+
+ if (this.params.containsKey("RememberTargets")) {
+ if (this.params.get("RememberTargets").equals("True")) {
+ abilityFactory.getHostCard().addRemembered(tgtSACard);
+ }
+ }
+ }
+ } // end spliceResolve
+
+ /**
+ *
+ * spliceStackDescription.
+ *
+ *
+ * @param abilityFactory
+ * a {@link forge.card.abilityfactory.AbilityFactory} object.
+ * @param spellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ * @return a {@link java.lang.String} object.
+ */
+ private String spliceStackDescription(final AbilityFactory abilityFactory, final SpellAbility spellAbility) {
+
+ final StringBuilder sb = new StringBuilder();
+
+ if (!(spellAbility instanceof AbilitySub)) {
+ sb.append(spellAbility.getSourceCard().getName()).append(" - ");
+ } else {
+ sb.append(" ");
+ }
+
+ ArrayList sas;
+
+ final Target tgt = abilityFactory.getAbTgt();
+ if (tgt != null) {
+ sas = tgt.getTargetSAs();
+ } else {
+ sas = AbilityFactory.getDefinedSpellAbilities(spellAbility.getSourceCard(), this.params.get("Defined"), spellAbility);
+ }
+
+ sb.append("splicing");
+
+ boolean isAbility = false;
+ for (final SpellAbility tgtSA : sas) {
+ sb.append(" ");
+ sb.append(tgtSA.getSourceCard());
+ isAbility = tgtSA.isAbility();
+ if (isAbility) {
+ sb.append("'s ability");
+ }
+ }
+
+ if (isAbility && this.params.containsKey("DestroyPermanent")) {
+ sb.append(" and destroy it");
+ }
+
+ sb.append(".");
+
+ final AbilitySub abSub = spellAbility.getSubAbility();
+ if (abSub != null) {
+ sb.append(abSub.getStackDescription());
+ }
+
+ return sb.toString();
+ } // end spliceStackDescription
+
+ /**
+ *
+ * removeFromStack.
+ *
+ *
+ * @param targetSpellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ * @param sourceSpellAbility
+ * a {@link forge.card.spellability.SpellAbility} object.
+ * @param spellAbilityStackInstance
+ * a {@link forge.card.spellability.SpellAbilityStackInstance}
+ * object.
+ */
+ private void removeFromStack(final SpellAbility targetSpellAbility, final SpellAbility sourceSpellAbility, final SpellAbilityStackInstance spellAbilityStackInstance) {
+ AllZone.getStack().remove(spellAbilityStackInstance);
+ }
+
+} // end class AbilityFactorySplice
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
index 2d0c32a0331..31b4291830a 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
@@ -293,8 +293,14 @@ public class AbilityFactoryTurns {
// ************************* END TURN **************************************
// *************************************************************************
+ /**
+ * Creates the ability end turn.
+ *
+ * @param af the af
+ * @return the spell ability
+ */
public static SpellAbility createAbilityEndTurn(final AbilityFactory af) {
- SpellAbility ret = new AbilityActivated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
+ final SpellAbility ret = new AbilityActivated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
private static final long serialVersionUID = 72570867940224012L;
@@ -309,7 +315,7 @@ public class AbilityFactoryTurns {
}
@Override
- public boolean doTrigger(boolean mandatory) {
+ public boolean doTrigger(final boolean mandatory) {
if (mandatory) {
return true;
}
@@ -319,7 +325,7 @@ public class AbilityFactoryTurns {
@Override
public void resolve() {
- endTurnResolve(af, this);
+ AbilityFactoryTurns.endTurnResolve(af, this);
}
};
@@ -327,8 +333,14 @@ public class AbilityFactoryTurns {
return ret;
}
+ /**
+ * Creates the spell end turn.
+ *
+ * @param af the af
+ * @return the spell ability
+ */
public static SpellAbility createSpellEndTurn(final AbilityFactory af) {
- SpellAbility ret = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
+ final SpellAbility ret = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
private static final long serialVersionUID = -2553413143747617709L;
@@ -344,7 +356,7 @@ public class AbilityFactoryTurns {
@Override
public void resolve() {
- endTurnResolve(af, this);
+ AbilityFactoryTurns.endTurnResolve(af, this);
}
};
@@ -352,6 +364,12 @@ public class AbilityFactoryTurns {
return ret;
}
+ /**
+ * Creates the drawback end turn.
+ *
+ * @param af the af
+ * @return the spell ability
+ */
public static SpellAbility createDrawbackEndTurn(final AbilityFactory af) {
final SpellAbility dbEndTurn = new AbilitySub(af.getHostCard(), af.getAbTgt()) {
private static final long serialVersionUID = -562517287448810951L;
@@ -386,24 +404,28 @@ public class AbilityFactoryTurns {
private static void endTurnResolve(final AbilityFactory af, final SpellAbility sa) {
- //Steps taken from gatherer's rulings on Time Stop.
- //1) All spells and abilities on the stack are exiled. This includes Time Stop, though it will continue to resolve. It also includes spells and abilities that can't be countered.
- for (Card c : AllZone.getStackZone().getCards()) {
+ // Steps taken from gatherer's rulings on Time Stop.
+ // 1) All spells and abilities on the stack are exiled. This includes
+ // Time Stop, though it will continue to resolve. It also includes
+ // spells and abilities that can't be countered.
+ for (final Card c : AllZone.getStackZone().getCards()) {
AllZone.getGameAction().exile(c);
}
AllZone.getStack().getStack().clear();
- //2) All attacking and blocking creatures are removed from combat.
+ // 2) All attacking and blocking creatures are removed from combat.
AllZone.getCombat().resetAttackers();
AllZone.getCombat().resetBlockers();
- //3) State-based actions are checked. No player gets priority, and no triggered abilities are put onto the stack.
+ // 3) State-based actions are checked. No player gets priority, and no
+ // triggered abilities are put onto the stack.
AllZone.getGameAction().checkStateEffects();
- //4) The current phase and/or step ends. The game skips straight to the cleanup step. The cleanup step happens in its entirety.
+ // 4) The current phase and/or step ends. The game skips straight to the
+ // cleanup step. The cleanup step happens in its entirety.
AllZone.getPhaseHandler().setPhaseState(Constant.Phase.CLEANUP);
- //Update observers
+ // Update observers
AllZone.getStack().updateObservers();
AllZone.getComputerPlayer().updateObservers();
AllZone.getHumanPlayer().updateObservers();
diff --git a/src/main/java/forge/card/replacement/ReplacementEffect.java b/src/main/java/forge/card/replacement/ReplacementEffect.java
index 40db45b59fc..ffc5e11fc5d 100644
--- a/src/main/java/forge/card/replacement/ReplacementEffect.java
+++ b/src/main/java/forge/card/replacement/ReplacementEffect.java
@@ -29,9 +29,9 @@ import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility;
-/**
+/**
* TODO: Write javadoc for this type.
- *
+ *
*/
public abstract class ReplacementEffect extends TriggerReplacementBase {
@@ -40,45 +40,55 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
/**
* Checks for run.
- *
+ *
* @return the hasRun
*/
public final boolean hasRun() {
- return hasRun;
+ return this.hasRun;
}
-
+
+ /**
+ * Checks if is secondary.
+ *
+ * @return true, if is secondary
+ */
public final boolean isSecondary() {
- return mapParams.containsKey("Secondary");
+ return this.mapParams.containsKey("Secondary");
}
-
+
+ /**
+ * Ai should run.
+ *
+ * @param sa the sa
+ * @return true, if successful
+ */
public final boolean aiShouldRun(final SpellAbility sa) {
- if (mapParams.containsKey("AICheckSVar")) {
- String svarToCheck = mapParams.get("AICheckSVar");
+ if (this.mapParams.containsKey("AICheckSVar")) {
+ final String svarToCheck = this.mapParams.get("AICheckSVar");
String comparator = "GE";
int compareTo = 1;
- if (mapParams.containsKey("AISVarCompare")) {
- String fullCmp = mapParams.get("AISVarCompare");
+ if (this.mapParams.containsKey("AISVarCompare")) {
+ final String fullCmp = this.mapParams.get("AISVarCompare");
comparator = fullCmp.substring(0, 2);
- String strCmpTo = fullCmp.substring(2);
+ final String strCmpTo = fullCmp.substring(2);
try {
compareTo = Integer.parseInt(strCmpTo);
- }
- catch (Exception ignored) {
+ } catch (final Exception ignored) {
if (sa == null) {
- compareTo = CardFactoryUtil.xCount(hostCard, hostCard.getSVar(strCmpTo));
+ compareTo = CardFactoryUtil.xCount(this.hostCard, this.hostCard.getSVar(strCmpTo));
} else {
- compareTo = AbilityFactory.calculateAmount(hostCard, hostCard.getSVar(strCmpTo), sa);
+ compareTo = AbilityFactory.calculateAmount(this.hostCard, this.hostCard.getSVar(strCmpTo), sa);
}
}
}
int left = 0;
- if (sa == null) {
- left = CardFactoryUtil.xCount(hostCard, hostCard.getSVar(svarToCheck));
+ if (sa == null) {
+ left = CardFactoryUtil.xCount(this.hostCard, this.hostCard.getSVar(svarToCheck));
} else {
- left = AbilityFactory.calculateAmount(hostCard, hostCard.getSVar(svarToCheck), sa);
+ left = AbilityFactory.calculateAmount(this.hostCard, this.hostCard.getSVar(svarToCheck), sa);
}
if (AllZoneUtil.compare(left, comparator, compareTo)) {
@@ -92,10 +102,11 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
/**
* Sets the checks for run.
- *
- * @param hasRun the hasRun to set
+ *
+ * @param hasRun
+ * the hasRun to set
*/
- public final void setHasRun(boolean hasRun) {
+ public final void setHasRun(final boolean hasRun) {
this.hasRun = hasRun;
}
@@ -151,20 +162,23 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
/**
* Can replace.
- *
- * @param runParams the run params
+ *
+ * @param runParams
+ * the run params
* @return true, if successful
*/
public abstract boolean canReplace(final HashMap runParams);
/**
+ * To string.
+ *
* @return a String
*/
+ @Override
public String toString() {
- if (getMapParams().containsKey("Description") && !this.isSuppressed()) {
- return getMapParams().get("Description");
- }
- else {
+ if (this.getMapParams().containsKey("Description") && !this.isSuppressed()) {
+ return this.getMapParams().get("Description");
+ } else {
return "";
}
}
@@ -371,26 +385,30 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
/**
* Gets the copy.
- *
+ *
* @return the copy
*/
public abstract ReplacementEffect getCopy();
/**
* Sets the replacing objects.
- *
- * @param runParams the run params
- * @param spellAbility the SpellAbility
+ *
+ * @param runParams
+ * the run params
+ * @param spellAbility
+ * the SpellAbility
*/
- public void setReplacingObjects(HashMap runParams, SpellAbility spellAbility) {
- //Should be overridden by replacers that need it.
+ public void setReplacingObjects(final HashMap runParams, final SpellAbility spellAbility) {
+ // Should be overridden by replacers that need it.
}
/**
* Instantiates a new replacement effect.
- *
- * @param map the map
- * @param host the host
+ *
+ * @param map
+ * the map
+ * @param host
+ * the host
*/
public ReplacementEffect(final HashMap map, final Card host) {
this.setMapParams(map);
diff --git a/src/main/java/forge/card/replacement/ReplacementHandler.java b/src/main/java/forge/card/replacement/ReplacementHandler.java
index 567bf660533..392393f92fc 100644
--- a/src/main/java/forge/card/replacement/ReplacementHandler.java
+++ b/src/main/java/forge/card/replacement/ReplacementHandler.java
@@ -24,51 +24,54 @@ import java.util.List;
import forge.AllZone;
import forge.Card;
import forge.ComputerUtil;
+import forge.Constant.Zone;
import forge.GameActionUtil;
import forge.Player;
-import forge.Constant.Zone;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.gui.GuiUtils;
-/**
+/**
* TODO: Write javadoc for this type.
- *
+ *
*/
public class ReplacementHandler {
- private List tmpEffects = new ArrayList();
+ private final List tmpEffects = new ArrayList();
/**
*
* Runs any applicable replacement effects.
- * @param runParams the run params,same as for triggers.
+ *
+ * @param runParams
+ * the run params,same as for triggers.
* @return true if the event was replaced.
*/
public boolean run(final HashMap runParams) {
- Object affected = runParams.get("Affected");
- List possibleReplacers = new ArrayList();
+ final Object affected = runParams.get("Affected");
+ final List possibleReplacers = new ArrayList();
Player decider = null;
- //Figure out who decides which of multiple replacements to apply
- //as well as whether or not to apply optional replacements.
+ // Figure out who decides which of multiple replacements to apply
+ // as well as whether or not to apply optional replacements.
if (affected instanceof Player) {
decider = (Player) affected;
} else {
decider = ((Card) affected).getController();
}
- //Round up Non-static replacement effects ("Until EOT," or "The next time you would..." etc)
- for (ReplacementEffect replacementEffect : tmpEffects) {
+ // Round up Non-static replacement effects ("Until EOT," or
+ // "The next time you would..." etc)
+ for (final ReplacementEffect replacementEffect : this.tmpEffects) {
if (!replacementEffect.hasRun() && replacementEffect.canReplace(runParams)) {
possibleReplacers.add(replacementEffect);
}
}
- //Round up Static replacement effects
- for (Player p : AllZone.getPlayersInGame()) {
- for (Card crd : p.getCardsIn(Zone.Battlefield)) {
- for (ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
+ // Round up Static replacement effects
+ for (final Player p : AllZone.getPlayersInGame()) {
+ for (final Card crd : p.getCardsIn(Zone.Battlefield)) {
+ for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
if (replacementEffect.requirementsCheck()) {
if (!replacementEffect.hasRun() && replacementEffect.canReplace(runParams)) {
possibleReplacers.add(replacementEffect);
@@ -90,20 +93,20 @@ public class ReplacementHandler {
if (possibleReplacers.size() > 1) {
if (decider.isHuman()) {
- chosenRE = (ReplacementEffect) GuiUtils.getChoice(
- "Choose which replacement effect to apply.", possibleReplacers.toArray());
+ chosenRE = (ReplacementEffect) GuiUtils.getChoice("Choose which replacement effect to apply.",
+ possibleReplacers.toArray());
} else {
- //AI logic for choosing which replacement effect to apply happens here.
+ // AI logic for choosing which replacement effect to apply
+ // happens here.
chosenRE = possibleReplacers.get(0);
}
}
- if (chosenRE != null) {
- if (executeReplacement(runParams, chosenRE, decider)) {
+ if (chosenRE != null) {
+ if (this.executeReplacement(runParams, chosenRE, decider)) {
AllZone.getGameLog().add("ReplacementEffect", chosenRE.toString(), 2);
return true;
- }
- else {
+ } else {
return false;
}
} else {
@@ -115,35 +118,39 @@ public class ReplacementHandler {
/**
*
* Runs a single replacement effect.
- * @param replacementEffect the replacement effect to run
+ *
+ * @param replacementEffect
+ * the replacement effect to run
*/
- private boolean executeReplacement(HashMap runParams, ReplacementEffect replacementEffect, Player decider) {
+ private boolean executeReplacement(final HashMap runParams,
+ final ReplacementEffect replacementEffect, final Player decider) {
- HashMap mapParams = replacementEffect.getMapParams();
+ final HashMap mapParams = replacementEffect.getMapParams();
replacementEffect.setHasRun(true);
- SpellAbility effectSA = null;
+ SpellAbility effectSA = null;
if (mapParams.containsKey("ReplaceWith")) {
- String effectSVar = mapParams.get("ReplaceWith");
- String effectAbString = replacementEffect.getHostCard().getSVar(effectSVar);
+ final String effectSVar = mapParams.get("ReplaceWith");
+ final String effectAbString = replacementEffect.getHostCard().getSVar(effectSVar);
- AbilityFactory abilityFactory = new AbilityFactory();
+ final AbilityFactory abilityFactory = new AbilityFactory();
effectSA = abilityFactory.getAbility(effectAbString, replacementEffect.getHostCard());
replacementEffect.setReplacingObjects(runParams, effectSA);
}
-
- //Decider gets to choose wether or not to apply the replacement.
+
+ // Decider gets to choose wether or not to apply the replacement.
if (replacementEffect.getMapParams().containsKey("Optional")) {
Player optDecider = decider;
- if (mapParams.containsKey("OptionalDecider") && effectSA != null) {
- optDecider = AbilityFactory.getDefinedPlayers(replacementEffect.getHostCard(), mapParams.get("OptionalDecider"), effectSA).get(0);
+ if (mapParams.containsKey("OptionalDecider") && (effectSA != null)) {
+ optDecider = AbilityFactory.getDefinedPlayers(replacementEffect.getHostCard(),
+ mapParams.get("OptionalDecider"), effectSA).get(0);
}
if (optDecider.isHuman()) {
- StringBuilder buildQuestion = new StringBuilder("Apply replacement effect of ");
+ final StringBuilder buildQuestion = new StringBuilder("Apply replacement effect of ");
buildQuestion.append(replacementEffect.getHostCard());
buildQuestion.append("?\r\n(");
buildQuestion.append(replacementEffect.toString());
@@ -151,8 +158,8 @@ public class ReplacementHandler {
if (!GameActionUtil.showYesNoDialog(replacementEffect.getHostCard(), buildQuestion.toString())) {
return false;
}
- } else {
- //AI-logic
+ } else {
+ // AI-logic
if (!replacementEffect.aiShouldRun(effectSA)) {
return false;
}
@@ -162,14 +169,13 @@ public class ReplacementHandler {
if (mapParams.containsKey("Prevent")) {
if (mapParams.get("Prevent").equals("True")) {
replacementEffect.setHasRun(false);
- return true; //Nothing should replace the event.
+ return true; // Nothing should replace the event.
}
}
if (replacementEffect.getHostCard().getController().isHuman()) {
AllZone.getGameAction().playSpellAbilityNoStack(effectSA, false);
- }
- else {
+ } else {
ComputerUtil.playNoStack(effectSA);
}
@@ -180,9 +186,13 @@ public class ReplacementHandler {
/**
*
- * Creates an instance of the proper replacement effect object based on raw script.
- * @param repParse A raw line of script
- * @param host The cards that hosts the replacement effect.
+ * Creates an instance of the proper replacement effect object based on raw
+ * script.
+ *
+ * @param repParse
+ * A raw line of script
+ * @param host
+ * The cards that hosts the replacement effect.
* @return A finished instance
*/
public static ReplacementEffect parseReplacement(final String repParse, final Card host) {
@@ -192,9 +202,13 @@ public class ReplacementHandler {
/**
*
- * Creates an instance of the proper replacement effect object based on a parsed script.
- * @param mapParams The parsed script
- * @param host The card that hosts the replacement effect
+ * Creates an instance of the proper replacement effect object based on a
+ * parsed script.
+ *
+ * @param mapParams
+ * The parsed script
+ * @param host
+ * The card that hosts the replacement effect
* @return The finished instance
*/
public static ReplacementEffect parseReplacement(final HashMap mapParams, final Card host) {
diff --git a/src/main/java/forge/model/FModel.java b/src/main/java/forge/model/FModel.java
index 85f8e4a5f13..6538f23792c 100644
--- a/src/main/java/forge/model/FModel.java
+++ b/src/main/java/forge/model/FModel.java
@@ -102,14 +102,16 @@ public class FModel {
// TODO this single setting from preferences should not be here, or,
// it should be here with all the other settings at the same time.
- // Unfortunately, they're tied up in legacy code in the Display interface,
- // currently in GuiTopLevel. When that code is updated, this TODO should be resolved.
+ // Unfortunately, they're tied up in legacy code in the Display
+ // interface,
+ // currently in GuiTopLevel. When that code is updated, this TODO should
+ // be resolved.
// Doublestrike 24-01-12
// ==
// It's looking like all the settings at the same time, here only.
// Doublestrike 06-02-12
- Constant.Runtime.DEV_MODE[0] = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED);
- Constant.Runtime.setSkinName(preferences.getPref(FPref.UI_SKIN));
+ Constant.Runtime.DEV_MODE[0] = this.preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED);
+ Constant.Runtime.setSkinName(this.preferences.getPref(FPref.UI_SKIN));
// Load splash image and preloader swatches for skin
FSkin.loadLight(Constant.Runtime.getSkinName());
@@ -270,32 +272,56 @@ public class FModel {
}
}
- /** @return {@link forge.model.BuildInfo} */
+ /**
+ * Gets the builds the info.
+ *
+ * @return {@link forge.model.BuildInfo}
+ */
public final BuildInfo getBuildInfo() {
return this.buildInfo;
}
- /** @param bi0 {@link forge.model.BuildInfo} */
+ /**
+ * Sets the builds the info.
+ *
+ * @param bi0 {@link forge.model.BuildInfo}
+ */
protected final void setBuildInfo(final BuildInfo bi0) {
this.buildInfo = bi0;
}
- /** @return {@link forge.properties.ForgePreferences} */
+ /**
+ * Gets the preferences.
+ *
+ * @return {@link forge.properties.ForgePreferences}
+ */
public final ForgePreferences getPreferences() {
return this.preferences;
}
- /** @return {@link forge.quest.data.QuestPreferences} */
+ /**
+ * Gets the quest preferences.
+ *
+ * @return {@link forge.quest.data.QuestPreferences}
+ */
public final QuestPreferences getQuestPreferences() {
return this.questPreferences;
}
- /** @return {@link forge.model.FGameState} */
+ /**
+ * Gets the game state.
+ *
+ * @return {@link forge.model.FGameState}
+ */
public final FGameState getGameState() {
return this.gameState;
}
- /** @return {@link forge.game.GameSummary} */
+ /**
+ * Gets the game summary.
+ *
+ * @return {@link forge.game.GameSummary}
+ */
public final GameSummary getGameSummary() {
return this.gameState.getGameSummary();
}
@@ -311,12 +337,19 @@ public class FModel {
}
/**
+<<<<<<< HEAD
* TODO: Needs to be reworked for efficiency with rest of prefs saves in codebase.
*
* @return a boolean.
+=======
+ * TODO: Needs to be reworked for efficiency with rest of prefs saves in
+ * codebase.
+ *
+ * @return true, if successful
+>>>>>>> Update Maven plugins. Checkstyle
*/
public final boolean savePrefs() {
- final ForgePreferences fp = preferences;
+ final ForgePreferences fp = this.preferences;
final List fieldViews = Singletons.getView().getMatchView().getFieldViews();
// AI field is at index [0]
@@ -324,8 +357,10 @@ public class FModel {
fp.setPref(FPref.PHASE_AI_DRAW, String.valueOf(fieldViews.get(0).getLblDraw().getEnabled()));
fp.setPref(FPref.PHASE_AI_MAIN1, String.valueOf(fieldViews.get(0).getLblMain1().getEnabled()));
fp.setPref(FPref.PHASE_AI_BEGINCOMBAT, String.valueOf(fieldViews.get(0).getLblBeginCombat().getEnabled()));
- fp.setPref(FPref.PHASE_AI_DECLAREATTACKERS, String.valueOf(fieldViews.get(0).getLblDeclareAttackers().getEnabled()));
- fp.setPref(FPref.PHASE_AI_DECLAREBLOCKERS, String.valueOf(fieldViews.get(0).getLblDeclareBlockers().getEnabled()));
+ fp.setPref(FPref.PHASE_AI_DECLAREATTACKERS,
+ String.valueOf(fieldViews.get(0).getLblDeclareAttackers().getEnabled()));
+ fp.setPref(FPref.PHASE_AI_DECLAREBLOCKERS,
+ String.valueOf(fieldViews.get(0).getLblDeclareBlockers().getEnabled()));
fp.setPref(FPref.PHASE_AI_FIRSTSTRIKE, String.valueOf(fieldViews.get(0).getLblFirstStrike().getEnabled()));
fp.setPref(FPref.PHASE_AI_COMBATDAMAGE, String.valueOf(fieldViews.get(0).getLblCombatDamage().getEnabled()));
fp.setPref(FPref.PHASE_AI_ENDCOMBAT, String.valueOf(fieldViews.get(0).getLblEndCombat().getEnabled()));
@@ -338,8 +373,10 @@ public class FModel {
fp.setPref(FPref.PHASE_HUMAN_DRAW, String.valueOf(fieldViews.get(1).getLblDraw().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_MAIN1, String.valueOf(fieldViews.get(1).getLblMain1().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_BEGINCOMBAT, String.valueOf(fieldViews.get(1).getLblBeginCombat().getEnabled()));
- fp.setPref(FPref.PHASE_HUMAN_DECLAREATTACKERS, String.valueOf(fieldViews.get(1).getLblDeclareAttackers().getEnabled()));
- fp.setPref(FPref.PHASE_HUMAN_DECLAREBLOCKERS, String.valueOf(fieldViews.get(1).getLblDeclareBlockers().getEnabled()));
+ fp.setPref(FPref.PHASE_HUMAN_DECLAREATTACKERS,
+ String.valueOf(fieldViews.get(1).getLblDeclareAttackers().getEnabled()));
+ fp.setPref(FPref.PHASE_HUMAN_DECLAREBLOCKERS,
+ String.valueOf(fieldViews.get(1).getLblDeclareBlockers().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_FIRSTSTRIKE, String.valueOf(fieldViews.get(1).getLblFirstStrike().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_COMBATDAMAGE, String.valueOf(fieldViews.get(1).getLblCombatDamage().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_ENDCOMBAT, String.valueOf(fieldViews.get(1).getLblEndCombat().getEnabled()));
@@ -347,7 +384,7 @@ public class FModel {
fp.setPref(FPref.PHASE_HUMAN_EOT, String.valueOf(fieldViews.get(1).getLblEndTurn().getEnabled()));
fp.setPref(FPref.PHASE_HUMAN_CLEANUP, String.valueOf(fieldViews.get(1).getLblCleanup().getEnabled()));
- ViewTabber v = Singletons.getView().getMatchView().getViewTabber();
+ final ViewTabber v = Singletons.getView().getMatchView().getViewTabber();
Constant.Runtime.MILL[0] = v.getLblMilling().getEnabled();
fp.setPref(FPref.DEV_MILLING_LOSS, String.valueOf(Constant.Runtime.MILL[0]));
@@ -359,9 +396,16 @@ public class FModel {
}
/**
+<<<<<<< HEAD
* TODO: Needs to be reworked for efficiency with rest of prefs loads in codebase.
*
* @return a boolean.
+=======
+ * TODO: Needs to be reworked for efficiency with rest of prefs loads in
+ * codebase.
+ *
+ * @return true, if successful
+>>>>>>> Update Maven plugins. Checkstyle
*/
public final boolean loadPrefs() {
final ForgePreferences fp = Singletons.getModel().getPreferences();
@@ -371,8 +415,8 @@ public class FModel {
Constant.Runtime.DEV_MODE[0] = fp.getPrefBoolean(FPref.DEV_MODE_ENABLED);
Constant.Runtime.UPLOAD_DRAFT[0] = fp.getPrefBoolean(FPref.UI_UPLOAD_DRAFT);
Constant.Runtime.RANDOM_FOIL[0] = fp.getPrefBoolean(FPref.UI_RANDOM_FOIL);
- Constant.Runtime.UPLOAD_DRAFT[0] =
- (Constant.Runtime.NET_CONN[0] ? fp.getPrefBoolean(FPref.UI_UPLOAD_DRAFT) : false);
+ Constant.Runtime.UPLOAD_DRAFT[0] = (Constant.Runtime.NET_CONN[0] ? fp.getPrefBoolean(FPref.UI_UPLOAD_DRAFT)
+ : false);
// AI field is at index [0]
fieldViews.get(0).getLblUpkeep().setEnabled(fp.getPrefBoolean(FPref.PHASE_AI_UPKEEP));
diff --git a/src/main/java/forge/util/SectionUtil.java b/src/main/java/forge/util/SectionUtil.java
index d6541e12963..3861543e038 100644
--- a/src/main/java/forge/util/SectionUtil.java
+++ b/src/main/java/forge/util/SectionUtil.java
@@ -31,8 +31,9 @@ public class SectionUtil {
/**
* Parses the sections.
- *
- * @param source the source
+ *
+ * @param source
+ * the source
* @return the map
*/
@SuppressWarnings("unchecked")
@@ -77,9 +78,15 @@ public class SectionUtil {
return result;
}
-
- public static Map parseKvPairs(List lines) {
- Map result = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+
+ /**
+ * Parses the kv pairs.
+ *
+ * @param lines the lines
+ * @return the map
+ */
+ public static Map parseKvPairs(final List lines) {
+ final Map result = new TreeMap(String.CASE_INSENSITIVE_ORDER);
for (final String dd : lines) {
final String[] v = dd.split(":", 2);
diff --git a/src/main/java/net/slightlymagic/braids/util/lambda/Lambda0.java b/src/main/java/net/slightlymagic/braids/util/lambda/Lambda0.java
index 212b66d70e5..00582a7d751 100644
--- a/src/main/java/net/slightlymagic/braids/util/lambda/Lambda0.java
+++ b/src/main/java/net/slightlymagic/braids/util/lambda/Lambda0.java
@@ -22,19 +22,14 @@ package net.slightlymagic.braids.util.lambda;
/**
* The Class Lambda1.
- *
- * @param
- * the generic type
- * @param
- * the generic type
+ *
+ * @param the generic type
*/
public abstract class Lambda0 implements Lambda {
/**
* Apply.
- *
- * @param arg1
- * the arg1
+ *
* @return the r
*/
public abstract R apply();
@@ -49,12 +44,14 @@ public abstract class Lambda0 implements Lambda {
// TODO @Override
/**
* Apply.
- *
- * @param args Object[]
+ *
+ * @param args
+ * Object[]
* @return R
*/
+ @Override
public final R apply(final Object[] args) {
- return apply();
+ return this.apply();
}
}