- CheckStyle.

This commit is contained in:
Chris
2012-12-01 16:08:54 +00:00
parent 042dc9ab20
commit 88af2acb11
8 changed files with 105 additions and 87 deletions

View File

@@ -60,16 +60,17 @@ public enum CMatchUI implements CardContainer {
String strAvatarIcon = p.getLobbyPlayer().getPicture();
if (strAvatarIcon != null) {
final File f = new File(ForgeProps.getFile(NewConstants.IMAGE_ICON), strAvatarIcon);
if (f.exists())
if (f.exists()) {
return new ImageIcon(f.getPath()).getImage();
}
}
int iAvatar = p.getLobbyPlayer().getAvatarIndex();
return FSkin.getAvatars().get(iAvatar >= 0 ? iAvatar : defaultIndex);
}
private void setAvatar(final VField view, final Image img)
{
private void setAvatar(final VField view, final Image img) {
view.getLblAvatar().setIcon(new ImageIcon(img));
view.getLblAvatar().getResizeTimer().start();
}
@@ -100,11 +101,13 @@ public enum CMatchUI implements CardContainer {
int i = 1;
for (Player p : players) {
if (p.equals(localPlayer)) continue;
if (p.equals(localPlayer)) {
continue;
}
// A field must be initialized after it's instantiated, to update player info.
// No player, no init.
VField f = new VField(EDocID.valueOf("FIELD_" + i), p);
setAvatar(f, getPlayerAvatar(p, Integer.parseInt(indices[i%2])));
setAvatar(f, getPlayerAvatar(p, Integer.parseInt(indices[i % 2])));
f.getLayoutControl().initialize();
fields.add(f);
VCommand c = new VCommand(EDocID.valueOf("COMMAND_" + i), p);
@@ -167,8 +170,9 @@ public enum CMatchUI implements CardContainer {
public VField getFieldViewFor(Player p) {
for (final VField f : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
if ( f.getLayoutControl().getPlayer().equals(p))
if (f.getLayoutControl().getPlayer().equals(p)) {
return f;
}
}
return null;
}

View File

@@ -114,10 +114,15 @@ public class ControlWinLose {
GameOutcome lastGame = match.getLastGameOutcome();
if ( games.isEmpty() ) return;
if (games.isEmpty()) {
return;
}
for (Player p: Singletons.getModel().getGame().getRegisteredPlayers()) {
if (!p.getName().equals(lastGame.getWinner().getName())) continue; // not a loser
for (Player p : Singletons.getModel().getGame().getRegisteredPlayers()) {
if (!p.getName().equals(lastGame.getWinner().getName())) {
continue; // not a loser
}
// remove all the lost cards from owners' decks
List<CardPrinted> losses = new ArrayList<CardPrinted>();

View File

@@ -82,7 +82,8 @@ public class GauntletWinLose extends ControlWinLose {
LobbyPlayer questPlayer = Singletons.getControl().getLobby().getQuestPlayer();
if (match.isMatchOver()) {
// In all cases, update stats.
lstEventRecords.set(gd.getCompleted(), match.getGamesWonBy(questPlayer) + " - " + ( match.getPlayedGames().size() - match.getGamesWonBy(questPlayer) ) );
lstEventRecords.set(gd.getCompleted(), match.getGamesWonBy(questPlayer) + " - "
+ (match.getPlayedGames().size() - match.getGamesWonBy(questPlayer)));
gd.setCompleted(gd.getCompleted() + 1);
// Win match case

View File

@@ -127,18 +127,22 @@ public class QuestWinLose extends ControlWinLose {
if (!outcome.isDraw()) {
boolean isHumanWinner = outcome.getWinner().equals(questPlayer);
final List<CardPrinted> anteCards = new ArrayList<CardPrinted>();
for( Player p : Singletons.getModel().getGame().getRegisteredPlayers() ) {
if (p.getLobbyPlayer().equals(questPlayer) == isHumanWinner) continue;
for(Card c : p.getCardsIn(ZoneType.Ante))
for (Player p : Singletons.getModel().getGame().getRegisteredPlayers()) {
if (p.getLobbyPlayer().equals(questPlayer) == isHumanWinner) {
continue;
}
for (Card c : p.getCardsIn(ZoneType.Ante)) {
anteCards.add(CardDb.instance().getCard(c));
}
}
if (isHumanWinner) {
qc.getCards().addAllCards(anteCards);
this.anteWon(anteCards);
} else {
for(CardPrinted c : anteCards)
for (CardPrinted c : anteCards) {
qc.getCards().loseCard(c);
}
this.anteLost(anteCards);
}
}
@@ -344,10 +348,10 @@ public class QuestWinLose extends ControlWinLose {
}
// Alternate win
// final PlayerStatistics aiRating = game.getStatistics(computer.getName());
// final PlayerStatistics aiRating = game.getStatistics(computer.getName());
PlayerStatistics humanRating = null;
for(Entry<LobbyPlayer, PlayerStatistics> kvRating : game ) {
if( kvRating.getKey().equals(localHuman)) {
for (Entry<LobbyPlayer, PlayerStatistics> kvRating : game) {
if (kvRating.getKey().equals(localHuman)) {
humanRating = kvRating.getValue();
continue;
}
@@ -709,8 +713,10 @@ public class QuestWinLose extends ControlWinLose {
*/
private int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
QuestPreferences qp = Singletons.getModel().getQuestPreferences();
if ( null == whyAiLost) // Felidar, Helix Pinnacle, etc.
if (null == whyAiLost) {
// Felidar, Helix Pinnacle, etc.
return qp.getPreferenceInt(QPref.REWARDS_UNDEFEATED);
}
switch (whyAiLost) {
case LifeReachedZero:
return 0; // nothing special here, ordinary kill

View File

@@ -207,7 +207,7 @@ public enum TargetingOverlay {
*/
// Arrow drawing code by the MAGE team, used with permission.
private Area getArrow (float length, float bendPercent) {
private Area getArrow(float length, float bendPercent) {
float p1x = 0, p1y = 0;
float p2x = length, p2y = 0;
float cx = length / 2, cy = length / 8f * bendPercent;
@@ -216,10 +216,10 @@ public enum TargetingOverlay {
float headSize = 17;
float adjSize, ex, ey, abs_e;
adjSize = (float)(bodyWidth / 2 / Math.sqrt(2));
adjSize = (float) (bodyWidth / 2 / Math.sqrt(2));
ex = p2x - cx;
ey = p2y - cy;
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
ex /= abs_e;
ey /= abs_e;
GeneralPath bodyPath = new GeneralPath();
@@ -229,10 +229,10 @@ public enum TargetingOverlay {
bodyPath.quadTo(cx, cy, p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
bodyPath.closePath();
adjSize = (float)(headSize / Math.sqrt(2));
adjSize = (float) (headSize / Math.sqrt(2));
ex = p2x - cx;
ey = p2y - cy;
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
ex /= abs_e;
ey /= abs_e;
GeneralPath headPath = new GeneralPath();
@@ -251,10 +251,12 @@ public enum TargetingOverlay {
float ey = endY - startY;
if (ex == 0 && ey == 0) { return; }
float length = (float)Math.sqrt(ex * ex + ey * ey);
float bendPercent = (float)Math.asin(ey / length);
float length = (float) Math.sqrt(ex * ex + ey * ey);
float bendPercent = (float) Math.asin(ey / length);
if (endX > startX) bendPercent = -bendPercent;
if (endX > startX) {
bendPercent = -bendPercent;
}
Area arrow = getArrow(length, bendPercent);
AffineTransform af = g2d.getTransform();
@@ -295,10 +297,10 @@ public enum TargetingOverlay {
continue;
}
int endX = (int)p[0].getX();
int endY = (int)p[0].getY();
int startX = (int)p[1].getX();
int startY = (int)p[1].getY();
int endX = (int) p[0].getX();
int endY = (int) p[0].getY();
int startX = (int) p[1].getX();
int startY = (int) p[1].getY();
Color color = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
drawArrow(g2d, startX, startY, endX, endY, color);

View File

@@ -89,7 +89,7 @@ public class VAssignDamage {
return true;
}
if (active != this.lstDamage.size() -1) {
if (active != this.lstDamage.size() - 1) {
return false;
}