- CheckStyle.

This commit is contained in:
Chris
2012-11-23 20:22:21 +00:00
parent df47bab393
commit cf4d65bf73
19 changed files with 156 additions and 133 deletions

View File

@@ -282,8 +282,9 @@ public enum FControl {
*/ */
private Lobby lobby = null; private Lobby lobby = null;
public Lobby getLobby() { public Lobby getLobby() {
if( lobby == null ) if (lobby == null) {
lobby = new Lobby(); lobby = new Lobby();
}
return lobby; return lobby;
} }

View File

@@ -62,7 +62,6 @@ public class Lobby {
*/ */
public LobbyPlayer findLocalPlayer(PlayerType type, String name) { public LobbyPlayer findLocalPlayer(PlayerType type, String name) {
return new LobbyPlayer(type, name); return new LobbyPlayer(type, name);
} }
@@ -72,8 +71,9 @@ public class Lobby {
* @return * @return
*/ */
public LobbyPlayer findLocalPlayer(PlayerType type) { public LobbyPlayer findLocalPlayer(PlayerType type) {
if ( type == PlayerType.HUMAN ) if (type == PlayerType.HUMAN) {
return new LobbyPlayer(type, "Human"); // need to get name! return new LobbyPlayer(type, "Human"); // need to get name!
}
LobbyPlayer player = findLocalPlayer(type, getRandomName()); LobbyPlayer player = findLocalPlayer(type, getRandomName());
player.setAvatarIndex(MyRandom.getRandom().nextInt(FSkin.getAvatars().size())); player.setAvatarIndex(MyRandom.getRandom().nextInt(FSkin.getAvatars().size()));
@@ -100,5 +100,4 @@ public class Lobby {
} }
} }

View File

@@ -122,6 +122,7 @@ public abstract class Input implements java.io.Serializable {
* This method is used to mark old descendants of Input * This method is used to mark old descendants of Input
* TODO: Write javadoc for this method. * TODO: Write javadoc for this method.
*/ */
public /*abstract */void isClassUpdated() {}//; public /*abstract */void isClassUpdated() {
} //;
} }

View File

@@ -46,7 +46,7 @@ public class InputBlock extends Input {
private static final long serialVersionUID = 6120743598368928128L; private static final long serialVersionUID = 6120743598368928128L;
private Card currentAttacker = null; private Card currentAttacker = null;
private final HashMap<Card,List<Card>> allBlocking = new HashMap<Card, List<Card>>(); private final HashMap<Card, List<Card>> allBlocking = new HashMap<Card, List<Card>>();
private final Player defender; private final Player defender;
/** /**
@@ -125,8 +125,8 @@ public class InputBlock extends Input {
} }
List<Card> attackersBlocked = this.allBlocking.get(card); List<Card> attackersBlocked = this.allBlocking.get(card);
if (!attackersBlocked.contains(this.currentAttacker) && if (!attackersBlocked.contains(this.currentAttacker)
CombatUtil.canBlock(this.currentAttacker, card, Singletons.getModel().getGame().getCombat())) { && CombatUtil.canBlock(this.currentAttacker, card, Singletons.getModel().getGame().getCombat())) {
attackersBlocked.add(this.currentAttacker); attackersBlocked.add(this.currentAttacker);
Singletons.getModel().getGame().getCombat().addBlocker(this.currentAttacker, card); Singletons.getModel().getGame().getCombat().addBlocker(this.currentAttacker, card);
reminder = false; reminder = false;

View File

@@ -211,8 +211,9 @@ public class InputControl extends MyObservable implements java.io.Serializable {
return null; return null;
} }
if ( priority.isHuman() ) if (priority.isHuman()) {
return new InputBlock(priority); return new InputBlock(priority);
}
// ai is under attack // ai is under attack
priority.getController().getAiInput().getComputer().declareBlockers(); priority.getController().getAiInput().getComputer().declareBlockers();
@@ -238,7 +239,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} else if (priority.isHuman()) { } else if (priority.isHuman()) {
boolean prioritySkip = priority.getController().mayAutoPass(phase) boolean prioritySkip = priority.getController().mayAutoPass(phase)
|| priority.getController().isUiSetToSkipPhase(playerTurn, phase); || priority.getController().isUiSetToSkipPhase(playerTurn, phase);
if (this.game.getStack().isEmpty() && prioritySkip ) { if (this.game.getStack().isEmpty() && prioritySkip) {
handler.passPriority(); handler.passPriority();
return null; return null;
} else { } else {

View File

@@ -94,7 +94,9 @@ public class InputMulligan extends Input {
// Computer mulligan // Computer mulligan
for (Player ai : game.getPlayers()) { for (Player ai : game.getPlayers()) {
if ( ai.isHuman() ) continue; if (ai.isHuman()) {
continue;
}
boolean aiTakesMulligan = true; boolean aiTakesMulligan = true;
@@ -121,7 +123,7 @@ public class InputMulligan extends Input {
final List<Card> openingHand = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand)); final List<Card> openingHand = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand));
for (final Card c : openingHand) { for (final Card c : openingHand) {
if ( p.isHuman() ) { if (p.isHuman()) {
final ArrayList<String> kws = c.getKeyword(); final ArrayList<String> kws = c.getKeyword();
for (int i = 0; i < kws.size(); i++) { for (int i = 0; i < kws.size(); i++) {
final String kw = kws.get(i); final String kw = kws.get(i);
@@ -161,8 +163,9 @@ public class InputMulligan extends Input {
} }
} }
} }
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity") && if (c.getName().startsWith("Leyline")
(Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Leyline of Singularity"))))) { && !(c.getName().startsWith("Leyline of Singularity")
&& (Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Leyline of Singularity"))))) {
ga.moveToPlay(c); ga.moveToPlay(c);
//ga.checkStateEffects(); //ga.checkStateEffects();
} }

View File

@@ -86,5 +86,6 @@ public class InputPassPriority extends Input {
} }
} // selectCard() } // selectCard()
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -186,5 +186,6 @@ public class InputPayDiscardCost extends Input {
this.unpaid.execute(); this.unpaid.execute();
} }
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -117,7 +117,7 @@ public class InputPayManaCost extends InputPayMana {
this.spell = sa; this.spell = sa;
if (Singletons.getModel().getGame() != null ) { if (Singletons.getModel().getGame() != null) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (this.spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {
this.stopSetNext(this.spell.getAfterPayMana()); this.stopSetNext(this.spell.getAfterPayMana());
@@ -291,5 +291,6 @@ public class InputPayManaCost extends InputPayMana {
} }
} }
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -156,5 +156,6 @@ public class InputPayManaCost2 extends InputPayMana {
} }
} }
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -248,6 +248,7 @@ public class InputPayManaCostAbility extends InputPayMana {
} }
} }
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -62,7 +62,6 @@ public class InputPayManaCostUtil {
return manaCost; return manaCost;
} }
final StringBuilder cneeded = new StringBuilder(); final StringBuilder cneeded = new StringBuilder();
final StringBuilder colorRequired = new StringBuilder(); final StringBuilder colorRequired = new StringBuilder();
boolean choice = true; boolean choice = true;
@@ -81,7 +80,7 @@ public class InputPayManaCostUtil {
List<SpellAbility> abilities = new ArrayList<SpellAbility>(); List<SpellAbility> abilities = new ArrayList<SpellAbility>();
// you can't remove unneeded abilities inside a for(am:abilities) loop :( // you can't remove unneeded abilities inside a for(am:abilities) loop :(
for(SpellAbility ma : card.getManaAbility()) { for (SpellAbility ma : card.getManaAbility()) {
ma.setActivatingPlayer(Singletons.getControl().getPlayer()); ma.setActivatingPlayer(Singletons.getControl().getPlayer());
AbilityManaPart m = ma.getManaPart(); AbilityManaPart m = ma.getManaPart();
if (!ma.canPlay()) { if (!ma.canPlay()) {

View File

@@ -110,5 +110,6 @@ public class InputPayManaX extends InputPayMana {
* @see forge.control.input.Input#isClassUpdated() * @see forge.control.input.Input#isClassUpdated()
*/ */
@Override @Override
public void isClassUpdated() {} public void isClassUpdated() {
}
} }

View File

@@ -186,8 +186,7 @@ public class InputPayReturnCost extends Input {
this.unpaid.execute(); this.unpaid.execute();
} }
@Override public void isClassUpdated() {
@Override public void isClassUpdated() {} }
} }

View File

@@ -187,5 +187,6 @@ public class InputPaySacCost extends Input {
this.unpaid.execute(); this.unpaid.execute();
} }
@Override public void isClassUpdated() {} @Override public void isClassUpdated() {
}
} }

View File

@@ -21,9 +21,11 @@ public abstract class InputSelectMany<T extends GameEntity> extends Input {
private String message = "Source-Card-Name - Select %d more card(s)"; private String message = "Source-Card-Name - Select %d more card(s)";
protected InputSelectMany(int min, int max) protected InputSelectMany(int min, int max) {
{
if( min > max ) throw new IllegalArgumentException("Min must not be greater than Max"); if (min > max) {
throw new IllegalArgumentException("Min must not be greater than Max");
}
this.min = min; this.min = min;
this.max = max; this.max = max;
} }
@@ -36,10 +38,18 @@ public abstract class InputSelectMany<T extends GameEntity> extends Input {
boolean canCancel = (min == 0 && selected.isEmpty()) || canCancelWithSomethingSelected(); boolean canCancel = (min == 0 && selected.isEmpty()) || canCancelWithSomethingSelected();
boolean canOk = hasEnoughTargets(); boolean canOk = hasEnoughTargets();
if (canOk && canCancel) ButtonUtil.enableAll(); if (canOk && canCancel) {
if (!canOk && canCancel) ButtonUtil.enableOnlyCancel(); ButtonUtil.enableAll();
if (canOk && !canCancel) ButtonUtil.enableOnlyOK(); }
if (!canOk && !canCancel) ButtonUtil.disableAll(); if (!canOk && canCancel) {
ButtonUtil.enableOnlyCancel();
}
if (canOk && !canCancel) {
ButtonUtil.enableOnlyOK();
}
if (!canOk && !canCancel) {
ButtonUtil.disableAll();
}
} }
@@ -61,10 +71,11 @@ public abstract class InputSelectMany<T extends GameEntity> extends Input {
// Singletons.getModel().getMatch().getInput().setInput(next); // Singletons.getModel().getMatch().getInput().setInput(next);
// } // }
if ( null == next ) if (null == next) {
this.stop(); this.stop();
else } else {
this.stopSetNext(next); this.stopSetNext(next);
}
// for a next use // for a next use
selected.clear(); selected.clear();
@@ -82,23 +93,24 @@ public abstract class InputSelectMany<T extends GameEntity> extends Input {
// Singletons.getModel().getMatch().getInput().setInput(next); // Singletons.getModel().getMatch().getInput().setInput(next);
// } // }
if ( null == next ) if (null == next) {
this.stop(); this.stop();
else } else {
this.stopSetNext(next); this.stopSetNext(next);
}
// for a next use // for a next use
selected.clear(); selected.clear();
} }
@Override @Override
public void isClassUpdated() {} public void isClassUpdated() {
}
public void setMessage(String message0) { public void setMessage(String message0) {
this.message = message0; // TODO: Add 0 to parameter's name. this.message = message0; // TODO: Add 0 to parameter's name.
} }
// must define these // must define these
protected abstract Input onDone(); protected abstract Input onDone();
protected abstract boolean isValidChoice(T choice); protected abstract boolean isValidChoice(T choice);
@@ -109,19 +121,18 @@ public abstract class InputSelectMany<T extends GameEntity> extends Input {
protected boolean hasEnoughTargets() { return selected.size() >= min; } protected boolean hasEnoughTargets() { return selected.size() >= min; }
protected boolean hasAllTargets() { return selected.size() >= max; } protected boolean hasAllTargets() { return selected.size() >= max; }
protected void selectEntity(T c) {
protected void selectEntity(T c) if (selected.contains(c) || !isValidChoice(c)) {
{ return;
if ( selected.contains(c) || !isValidChoice(c) ) return; }
this.selected.add(c); this.selected.add(c);
this.showMessage(); this.showMessage();
if ( hasAllTargets() ) if (hasAllTargets()) {
selectButtonOK(); selectButtonOK();
}
} }
} }

View File

@@ -5,8 +5,8 @@ import forge.Card;
public abstract class InputSelectManyCards extends InputSelectMany<Card> { public abstract class InputSelectManyCards extends InputSelectMany<Card> {
private static final long serialVersionUID = -6609493252672573139L; private static final long serialVersionUID = -6609493252672573139L;
protected InputSelectManyCards(int min, int max) protected InputSelectManyCards(int min, int max) {
{
super(min, max); super(min, max);
} }

View File

@@ -13,8 +13,8 @@ public class InputSelectManyPlayers extends InputSelectMany<Player> {
protected final Function<List<Player>, Input> onComplete; protected final Function<List<Player>, Input> onComplete;
private final Predicate<Player> allowedFilter; private final Predicate<Player> allowedFilter;
public InputSelectManyPlayers(final Predicate<Player> allowedRule, int min, int max, final Function<List<Player>, Input> onDone) public InputSelectManyPlayers(final Predicate<Player> allowedRule, int min, int max, final Function<List<Player>, Input> onDone) {
{
super(min, max); super(min, max);
allowedFilter = allowedRule; allowedFilter = allowedRule;
onComplete = onDone; onComplete = onDone;
@@ -27,7 +27,9 @@ public class InputSelectManyPlayers extends InputSelectMany<Player> {
} }
protected boolean isValidChoice(Player choice) { protected boolean isValidChoice(Player choice) {
if ( allowedFilter != null && !allowedFilter.apply(choice)) return false; if (allowedFilter != null && !allowedFilter.apply(choice)) {
return false;
}
return true; return true;
} }