[minor] formatting

This commit is contained in:
LevelX2 2013-04-02 13:46:43 +02:00
parent 7beb02a5c1
commit de20fcb5cc
5 changed files with 96 additions and 70 deletions

View file

@ -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);
}

View file

@ -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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
required = false;
} else {
int count = cards.count(target.getFilter(), game);
if (count == 0) required = false;
if (count == 0) {
required = false;
}
}
Map<String, Serializable> options = getOptions(target);
if (target.getTargets().size() > 0) {
@ -343,7 +349,9 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
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<HumanPlayer> {
game.fireGetChoiceEvent(playerId, name, new ArrayList<SpecialAction>(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<HumanPlayer> {
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(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<HumanPlayer> {
Map<UUID, String> modeMap = new LinkedHashMap<UUID, String>();
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<HumanPlayer> {
updateGameStatePriority("choosePile", game);
game.fireChoosePileEvent(playerId, message, pile1, pile2);
waitForBooleanResponse();
if (!abort)
if (!abort) {
return response.getBoolean();
}
return false;
}

View file

@ -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<T extends ManaCostImpl<T>> extends CostImpl<T> implements ManaCost {
@ -61,8 +61,9 @@ public abstract class ManaCostImpl<T extends ManaCostImpl<T>> extends CostImpl<T
this.payment = manaCost.payment.copy();
this.cost = manaCost.cost.copy();
this.options = manaCost.options.copy();
if (manaCost.sourceFilter != null)
if (manaCost.sourceFilter != null) {
this.sourceFilter = manaCost.sourceFilter.copy();
}
}
@Override
@ -168,27 +169,33 @@ public abstract class ManaCostImpl<T extends ManaCostImpl<T>> extends CostImpl<T
protected boolean isColoredPaid(ColoredManaSymbol mana) {
switch (mana) {
case B:
if (this.payment.getBlack() > 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<T extends ManaCostImpl<T>> extends CostImpl<T
Player player = game.getPlayer(controllerId);
assignPayment(game, ability, player.getManaPool());
while (!isPaid()) {
if (player.playMana(this, game))
if (player.playMana(this, game)) {
assignPayment(game, ability, player.getManaPool());
else
}
else {
return false;
}
}
return true;
}

View file

@ -28,6 +28,7 @@
package mage.abilities.costs.mana;
import java.util.*;
import mage.Constants.ColoredManaSymbol;
import mage.Mana;
import mage.abilities.Ability;
@ -39,7 +40,7 @@ import mage.players.ManaPool;
import mage.players.Player;
import mage.target.Targets;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
@ -115,21 +116,13 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> 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<ManaCost>) this, game))
// vCost.assignPayment(game, ability, player.getManaPool());
// else
// return false;
// }
// }
return true;
}
@ -156,8 +149,9 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
public ManaCosts<T> getUnpaid() {
ManaCosts<T> unpaid = new ManaCostsImpl<T>();
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<T extends ManaCost> extends ArrayList<T> implements M
public ManaCosts<T> getUnpaidVariableCosts() {
ManaCosts<T> unpaid = new ManaCostsImpl<T>();
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<T extends ManaCost> extends ArrayList<T> implements M
public List<VariableCost> getVariableCosts() {
List<VariableCost> variableCosts = new ArrayList<VariableCost>();
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<T extends ManaCost> extends ArrayList<T> implements M
public int getX() {
int amount = 0;
List<VariableCost> variableCosts = getVariableCosts();
if (!variableCosts.isEmpty())
if (!variableCosts.isEmpty()) {
amount = variableCosts.get(0).getAmount();
}
return amount;
}
@Override
public void setX(int x) {
List<VariableCost> variableCosts = getVariableCosts();
if (!variableCosts.isEmpty())
if (!variableCosts.isEmpty()) {
variableCosts.get(0).setAmount(x);
}
}
@Override
@ -251,8 +245,9 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> 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<T extends ManaCost> extends ArrayList<T> 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<T extends ManaCost> extends ArrayList<T> 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<T extends ManaCost> extends ArrayList<T> 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<T extends ManaCost> extends ArrayList<T> 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<T extends ManaCost> extends ArrayList<T> 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;
}

View file

@ -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);
}
}