From de20fcb5cc87196f60ace31855549cd6aae1be6e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 2 Apr 2013 13:46:43 +0200 Subject: [PATCH] [minor] formatting --- .../java/mage/client/game/FeedbackPanel.java | 20 +++---- .../src/mage/player/human/HumanPlayer.java | 52 +++++++++++------ .../abilities/costs/mana/ManaCostImpl.java | 29 ++++++---- .../abilities/costs/mana/ManaCostsImpl.java | 56 +++++++++---------- .../costs/mana/PhyrexianManaCost.java | 9 ++- 5 files changed, 96 insertions(+), 70 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java index ea00608dda..ffd63c00c9 100644 --- a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java @@ -34,15 +34,6 @@ package mage.client.game; -import mage.client.MageFrame; -import mage.client.chat.ChatPanel; -import mage.client.components.MageTextArea; -import mage.client.dialog.MageDialog; -import mage.client.util.AudioManager; -import mage.client.util.gui.ArrowBuilder; -import mage.remote.Session; -import org.apache.log4j.Logger; - import java.awt.*; import java.awt.event.ActionEvent; import java.io.Serializable; @@ -51,6 +42,14 @@ import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import mage.client.MageFrame; +import mage.client.chat.ChatPanel; +import mage.client.components.MageTextArea; +import mage.client.dialog.MageDialog; +import mage.client.util.AudioManager; +import mage.client.util.gui.ArrowBuilder; +import mage.remote.Session; +import org.apache.log4j.Logger; /** @@ -136,6 +135,7 @@ public class FeedbackPanel extends javax.swing.JPanel { this.btnSpecial.setVisible(special); this.btnSpecial.setText("Special"); this.helper.setSpecial("Special", special); + // Handling Phyrexian mana if (message.contains("P}")) { this.btnSpecial.setVisible(true); this.btnSpecial.setText("Pay 2 life"); @@ -289,7 +289,7 @@ public class FeedbackPanel extends javax.swing.JPanel { session.sendPlayerString(gameId, "special"); }//GEN-LAST:event_btnSpecialActionPerformed - private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed + private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) { session.undo(gameId); } diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 785efbe361..f0d8098dcf 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -28,6 +28,8 @@ package mage.player.human; +import java.io.Serializable; +import java.util.*; import mage.Constants.Outcome; import mage.Constants.RangeOfInfluence; import mage.Constants.Zone; @@ -65,8 +67,6 @@ import mage.target.common.TargetDefender; import mage.util.ManaUtil; import org.apache.log4j.Logger; -import java.io.Serializable; -import java.util.*; /** * @@ -140,8 +140,9 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("chooseMulligan", game); game.fireAskPlayerEvent(playerId, "Do you want to take a mulligan?"); waitForBooleanResponse(); - if (!abort) + if (!abort) { return response.getBoolean(); + } return false; } @@ -150,8 +151,9 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("chooseUse", game); game.fireAskPlayerEvent(playerId, message); waitForBooleanResponse(); - if (!abort) + if (!abort) { return response.getBoolean(); + } return false; } @@ -164,8 +166,9 @@ public class HumanPlayer extends PlayerImpl { replacementEffectChoice.getChoices().add(count + ". " + effectText); count++; } - if (replacementEffectChoice.getChoices().size() == 1) + if (replacementEffectChoice.getChoices().size() == 1) { return 0; + } while (!abort) { game.fireChooseEvent(playerId, replacementEffectChoice); waitForResponse(); @@ -174,8 +177,9 @@ public class HumanPlayer extends PlayerImpl { replacementEffectChoice.setChoice(response.getString()); count = 1; for (int i = 0; i < rEffects.size(); i++) { - if (replacementEffectChoice.getChoice().equals(count + ". " + rEffects.get(i))) + if (replacementEffectChoice.getChoice().equals(count + ". " + rEffects.get(i))) { return i; + } count++; } } @@ -302,7 +306,9 @@ public class HumanPlayer extends PlayerImpl { required = false; } else { int count = cards.count(target.getFilter(), game); - if (count == 0) required = false; + if (count == 0) { + required = false; + } } Map options = getOptions(target); if (target.getTargets().size() > 0) { @@ -343,7 +349,9 @@ public class HumanPlayer extends PlayerImpl { required = false; } else { int count = cards.count(target.getFilter(), game); - if (count == 0) required = false; + if (count == 0) { + required = false; + } } game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(), null); waitForResponse(); @@ -438,8 +446,9 @@ public class HumanPlayer extends PlayerImpl { waitForResponse(); if (response.getUUID() != null) { for (TriggeredAbility ability: abilities) { - if (ability.getId().equals(response.getUUID())) + if (ability.getId().equals(response.getUUID())) { return ability; + } } } } @@ -608,8 +617,9 @@ public class HumanPlayer extends PlayerImpl { waitForResponse(); if (response.getUUID() != null) { for (Permanent perm: attackers) { - if (perm.getId().equals(response.getUUID())) + if (perm.getId().equals(response.getUUID())) { return perm.getId(); + } } } } @@ -625,8 +635,9 @@ public class HumanPlayer extends PlayerImpl { waitForResponse(); if (response.getUUID() != null) { for (Permanent perm: blockers) { - if (perm.getId().equals(response.getUUID())) + if (perm.getId().equals(response.getUUID())) { return perm.getId(); + } } } } @@ -651,7 +662,9 @@ public class HumanPlayer extends PlayerImpl { int remainingDamage = damage; while (remainingDamage > 0) { Target target = new TargetCreatureOrPlayer(); - if (singleTargetName != null) target.setTargetName(singleTargetName); + if (singleTargetName != null) { + target.setTargetName(singleTargetName); + } choose(Outcome.Damage, target, sourceId, game); if (targets.isEmpty() || targets.contains(target.getFirstTarget())) { int damageAmount = getAmount(0, remainingDamage, "Select amount", game); @@ -700,8 +713,9 @@ public class HumanPlayer extends PlayerImpl { game.fireGetChoiceEvent(playerId, name, new ArrayList(specialActions.values())); waitForResponse(); if (response.getUUID() != null) { - if (specialActions.containsKey(response.getUUID())) + if (specialActions.containsKey(response.getUUID())) { activateAbility(specialActions.get(response.getUUID()), game); + } } } @@ -717,8 +731,9 @@ public class HumanPlayer extends PlayerImpl { game.fireGetChoiceEvent(playerId, name, new ArrayList(abilities.values())); waitForResponse(); if (response.getUUID() != null) { - if (abilities.containsKey(response.getUUID())) + if (abilities.containsKey(response.getUUID())) { activateAbility(abilities.get(response.getUUID()), game); + } } } @@ -730,16 +745,18 @@ public class HumanPlayer extends PlayerImpl { Map modeMap = new LinkedHashMap(); for (Mode mode: modes.values()) { String modeText = mode.getEffects().getText(mode); - if (obj != null) + if (obj != null) { modeText = modeText.replace("{source}", obj.getName()); + } modeMap.put(mode.getId(), modeText); } game.fireGetModeEvent(playerId, "Choose Mode", modeMap); waitForResponse(); if (response.getUUID() != null) { for (Mode mode: modes.values()) { - if (mode.getId().equals(response.getUUID())) + if (mode.getId().equals(response.getUUID())) { return mode; + } } } return null; @@ -752,8 +769,9 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("choosePile", game); game.fireChoosePileEvent(playerId, message, pile1, pile2); waitForBooleanResponse(); - if (!abort) + if (!abort) { return response.getBoolean(); + } return false; } diff --git a/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java b/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java index 816f744995..38bed215e7 100644 --- a/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java +++ b/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java @@ -28,6 +28,7 @@ package mage.abilities.costs.mana; +import java.util.UUID; import mage.Constants.ColoredManaSymbol; import mage.Constants.ManaType; import mage.Mana; @@ -39,7 +40,6 @@ import mage.game.Game; import mage.players.ManaPool; import mage.players.Player; -import java.util.UUID; public abstract class ManaCostImpl> extends CostImpl implements ManaCost { @@ -61,8 +61,9 @@ public abstract class ManaCostImpl> extends CostImpl> extends CostImpl 0) + if (this.payment.getBlack() > 0) { return true; + } case U: - if (this.payment.getBlue() > 0) + if (this.payment.getBlue() > 0) { return true; + } case W: - if (this.payment.getWhite() > 0) + if (this.payment.getWhite() > 0) { return true; + } case G: - if (this.payment.getGreen() > 0) + if (this.payment.getGreen() > 0) { return true; + } case R: - if (this.payment.getRed() > 0) + if (this.payment.getRed() > 0) { return true; + } } return false; } protected boolean isColorlessPaid(int mana) { - if (this.payment.count() >= mana) + if (this.payment.count() >= mana) { return true; + } return false; } @@ -206,10 +213,12 @@ public abstract class ManaCostImpl> extends CostImpl extends ArrayList implements M Player player = game.getPlayer(controllerId); assignPayment(game, ability, player.getManaPool()); while (!isPaid()) { - if (player.playMana(this.getUnpaid(), game)) + if (player.playMana(this.getUnpaid(), game)) { assignPayment(game, ability, player.getManaPool()); - else + } + else { return false; + } } - // no more needed because X costs are added to the cost during announcing of the X costs -// for (ManaCost cost : this.getUnpaidVariableCosts()) { -// VariableManaCost vCost = (VariableManaCost) cost; -// while (!vCost.isPaid()) { -// if (player.playXMana(vCost, (ManaCosts) this, game)) -// vCost.assignPayment(game, ability, player.getManaPool()); -// else -// return false; -// } -// } return true; } @@ -156,8 +149,9 @@ public class ManaCostsImpl extends ArrayList implements M public ManaCosts getUnpaid() { ManaCosts unpaid = new ManaCostsImpl(); for (T cost : this) { - if (!(cost instanceof VariableManaCost) && !cost.isPaid()) + if (!(cost instanceof VariableManaCost) && !cost.isPaid()) { unpaid.add((T) cost.getUnpaid()); + } } return unpaid; } @@ -166,8 +160,9 @@ public class ManaCostsImpl extends ArrayList implements M public ManaCosts getUnpaidVariableCosts() { ManaCosts unpaid = new ManaCostsImpl(); for (ManaCost cost : this) { - if (cost instanceof VariableManaCost && !cost.isPaid()) + if (cost instanceof VariableManaCost && !cost.isPaid()) { unpaid.add((T) cost.getUnpaid()); + } } return unpaid; } @@ -177,13 +172,10 @@ public class ManaCostsImpl extends ArrayList implements M public List getVariableCosts() { List variableCosts = new ArrayList(); for (ManaCost cost : this) { - if (cost instanceof VariableCost) + if (cost instanceof VariableCost) { variableCosts.add((VariableCost) cost); + } } -// if (variableCosts.size() == 0) { -// // add empty cost (#Issue 210) -// variableCosts.add(new VariableManaCost()); -// } return variableCosts; } @@ -191,16 +183,18 @@ public class ManaCostsImpl extends ArrayList implements M public int getX() { int amount = 0; List variableCosts = getVariableCosts(); - if (!variableCosts.isEmpty()) + if (!variableCosts.isEmpty()) { amount = variableCosts.get(0).getAmount(); + } return amount; } @Override public void setX(int x) { List variableCosts = getVariableCosts(); - if (!variableCosts.isEmpty()) + if (!variableCosts.isEmpty()) { variableCosts.get(0).setAmount(x); + } } @Override @@ -251,8 +245,9 @@ public class ManaCostsImpl extends ArrayList implements M this.add((T) cost.copy()); } } else { - if (mana == null || mana.length() == 0) + if (mana == null || mana.length() == 0) { return; + } String[] symbols = mana.split("^\\{|\\}\\{|\\}$"); int modifierForX = 0; for (String symbol : symbols) { @@ -261,8 +256,9 @@ public class ManaCostsImpl extends ArrayList implements M if (Character.isDigit(symbol.charAt(0))) { this.add((T) new GenericManaCost(Integer.valueOf(symbol))); } else { - if (!symbol.equals("X")) + if (!symbol.equals("X")) { this.add((T) new ColoredManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); + } else { // check X wasn't added before if (modifierForX == 0) { @@ -317,8 +313,9 @@ public class ManaCostsImpl extends ArrayList implements M @Override public String getText() { - if (this.size() == 0) + if (this.size() == 0) { return ""; + } StringBuilder sbText = new StringBuilder(); for (ManaCost cost : this) { @@ -346,8 +343,9 @@ public class ManaCostsImpl extends ArrayList implements M @Override public boolean testPay(Mana testMana) { for (ManaCost cost : this) { - if (cost.testPay(testMana)) + if (cost.testPay(testMana)) { return true; + } } return false; } @@ -355,8 +353,9 @@ public class ManaCostsImpl extends ArrayList implements M @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { for (T cost : this) { - if (!cost.canPay(sourceId, controllerId, game)) + if (!cost.canPay(sourceId, controllerId, game)) { return false; + } } return true; } @@ -364,8 +363,9 @@ public class ManaCostsImpl extends ArrayList implements M @Override public boolean isPaid() { for (T cost : this) { - if (!((T) cost instanceof VariableManaCost) && !cost.isPaid()) + if (!((T) cost instanceof VariableManaCost) && !cost.isPaid()) { return false; + } } return true; } diff --git a/Mage/src/mage/abilities/costs/mana/PhyrexianManaCost.java b/Mage/src/mage/abilities/costs/mana/PhyrexianManaCost.java index ff0a15ac0a..e4248e5962 100644 --- a/Mage/src/mage/abilities/costs/mana/PhyrexianManaCost.java +++ b/Mage/src/mage/abilities/costs/mana/PhyrexianManaCost.java @@ -28,13 +28,14 @@ package mage.abilities.costs.mana; +import java.util.UUID; import mage.Constants.ColoredManaSymbol; import mage.Mana; import mage.abilities.Ability; import mage.game.Game; import mage.players.ManaPool; -import java.util.UUID; + /** * @@ -53,13 +54,12 @@ public class PhyrexianManaCost extends ColoredManaCost { @Override public void assignPayment(Game game, Ability ability, ManaPool pool) { - if (assignColored(ability, game, pool, this.mana)) - return; + assignColored(ability, game, pool, this.mana); } @Override public String getText() { - return "{" + mana.toString() + "P}"; + return new StringBuilder("{").append(mana.toString()).append("P}").toString(); } @Override @@ -86,4 +86,3 @@ public class PhyrexianManaCost extends ColoredManaCost { return new PhyrexianManaCost(this); } } -