mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- CheckStyle.
This commit is contained in:
@@ -60,16 +60,17 @@ public enum CMatchUI implements CardContainer {
|
|||||||
String strAvatarIcon = p.getLobbyPlayer().getPicture();
|
String strAvatarIcon = p.getLobbyPlayer().getPicture();
|
||||||
if (strAvatarIcon != null) {
|
if (strAvatarIcon != null) {
|
||||||
final File f = new File(ForgeProps.getFile(NewConstants.IMAGE_ICON), strAvatarIcon);
|
final File f = new File(ForgeProps.getFile(NewConstants.IMAGE_ICON), strAvatarIcon);
|
||||||
if (f.exists())
|
if (f.exists()) {
|
||||||
return new ImageIcon(f.getPath()).getImage();
|
return new ImageIcon(f.getPath()).getImage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int iAvatar = p.getLobbyPlayer().getAvatarIndex();
|
int iAvatar = p.getLobbyPlayer().getAvatarIndex();
|
||||||
return FSkin.getAvatars().get(iAvatar >= 0 ? iAvatar : defaultIndex);
|
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().setIcon(new ImageIcon(img));
|
||||||
view.getLblAvatar().getResizeTimer().start();
|
view.getLblAvatar().getResizeTimer().start();
|
||||||
}
|
}
|
||||||
@@ -100,11 +101,13 @@ public enum CMatchUI implements CardContainer {
|
|||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Player p : players) {
|
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.
|
// A field must be initialized after it's instantiated, to update player info.
|
||||||
// No player, no init.
|
// No player, no init.
|
||||||
VField f = new VField(EDocID.valueOf("FIELD_" + i), p);
|
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();
|
f.getLayoutControl().initialize();
|
||||||
fields.add(f);
|
fields.add(f);
|
||||||
VCommand c = new VCommand(EDocID.valueOf("COMMAND_" + i), p);
|
VCommand c = new VCommand(EDocID.valueOf("COMMAND_" + i), p);
|
||||||
@@ -167,8 +170,9 @@ public enum CMatchUI implements CardContainer {
|
|||||||
|
|
||||||
public VField getFieldViewFor(Player p) {
|
public VField getFieldViewFor(Player p) {
|
||||||
for (final VField f : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
for (final VField f : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||||
if ( f.getLayoutControl().getPlayer().equals(p))
|
if (f.getLayoutControl().getPlayer().equals(p)) {
|
||||||
return f;
|
return f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,10 +114,15 @@ public class ControlWinLose {
|
|||||||
|
|
||||||
|
|
||||||
GameOutcome lastGame = match.getLastGameOutcome();
|
GameOutcome lastGame = match.getLastGameOutcome();
|
||||||
if ( games.isEmpty() ) return;
|
if (games.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p: Singletons.getModel().getGame().getRegisteredPlayers()) {
|
for (Player p : Singletons.getModel().getGame().getRegisteredPlayers()) {
|
||||||
if (!p.getName().equals(lastGame.getWinner().getName())) continue; // not a loser
|
if (!p.getName().equals(lastGame.getWinner().getName())) {
|
||||||
|
|
||||||
|
continue; // not a loser
|
||||||
|
}
|
||||||
|
|
||||||
// remove all the lost cards from owners' decks
|
// remove all the lost cards from owners' decks
|
||||||
List<CardPrinted> losses = new ArrayList<CardPrinted>();
|
List<CardPrinted> losses = new ArrayList<CardPrinted>();
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ public class GauntletWinLose extends ControlWinLose {
|
|||||||
LobbyPlayer questPlayer = Singletons.getControl().getLobby().getQuestPlayer();
|
LobbyPlayer questPlayer = Singletons.getControl().getLobby().getQuestPlayer();
|
||||||
if (match.isMatchOver()) {
|
if (match.isMatchOver()) {
|
||||||
// In all cases, update stats.
|
// 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);
|
gd.setCompleted(gd.getCompleted() + 1);
|
||||||
|
|
||||||
// Win match case
|
// Win match case
|
||||||
|
|||||||
@@ -127,18 +127,22 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
if (!outcome.isDraw()) {
|
if (!outcome.isDraw()) {
|
||||||
boolean isHumanWinner = outcome.getWinner().equals(questPlayer);
|
boolean isHumanWinner = outcome.getWinner().equals(questPlayer);
|
||||||
final List<CardPrinted> anteCards = new ArrayList<CardPrinted>();
|
final List<CardPrinted> anteCards = new ArrayList<CardPrinted>();
|
||||||
for( Player p : Singletons.getModel().getGame().getRegisteredPlayers() ) {
|
for (Player p : Singletons.getModel().getGame().getRegisteredPlayers()) {
|
||||||
if (p.getLobbyPlayer().equals(questPlayer) == isHumanWinner) continue;
|
if (p.getLobbyPlayer().equals(questPlayer) == isHumanWinner) {
|
||||||
for(Card c : p.getCardsIn(ZoneType.Ante))
|
continue;
|
||||||
|
}
|
||||||
|
for (Card c : p.getCardsIn(ZoneType.Ante)) {
|
||||||
anteCards.add(CardDb.instance().getCard(c));
|
anteCards.add(CardDb.instance().getCard(c));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHumanWinner) {
|
if (isHumanWinner) {
|
||||||
qc.getCards().addAllCards(anteCards);
|
qc.getCards().addAllCards(anteCards);
|
||||||
this.anteWon(anteCards);
|
this.anteWon(anteCards);
|
||||||
} else {
|
} else {
|
||||||
for(CardPrinted c : anteCards)
|
for (CardPrinted c : anteCards) {
|
||||||
qc.getCards().loseCard(c);
|
qc.getCards().loseCard(c);
|
||||||
|
}
|
||||||
this.anteLost(anteCards);
|
this.anteLost(anteCards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -344,10 +348,10 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
}
|
}
|
||||||
// Alternate win
|
// Alternate win
|
||||||
|
|
||||||
// final PlayerStatistics aiRating = game.getStatistics(computer.getName());
|
// final PlayerStatistics aiRating = game.getStatistics(computer.getName());
|
||||||
PlayerStatistics humanRating = null;
|
PlayerStatistics humanRating = null;
|
||||||
for(Entry<LobbyPlayer, PlayerStatistics> kvRating : game ) {
|
for (Entry<LobbyPlayer, PlayerStatistics> kvRating : game) {
|
||||||
if( kvRating.getKey().equals(localHuman)) {
|
if (kvRating.getKey().equals(localHuman)) {
|
||||||
humanRating = kvRating.getValue();
|
humanRating = kvRating.getValue();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -709,8 +713,10 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
*/
|
*/
|
||||||
private int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
|
private int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
|
||||||
QuestPreferences qp = Singletons.getModel().getQuestPreferences();
|
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);
|
return qp.getPreferenceInt(QPref.REWARDS_UNDEFEATED);
|
||||||
|
}
|
||||||
switch (whyAiLost) {
|
switch (whyAiLost) {
|
||||||
case LifeReachedZero:
|
case LifeReachedZero:
|
||||||
return 0; // nothing special here, ordinary kill
|
return 0; // nothing special here, ordinary kill
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ public enum TargetingOverlay {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Arrow drawing code by the MAGE team, used with permission.
|
// 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 p1x = 0, p1y = 0;
|
||||||
float p2x = length, p2y = 0;
|
float p2x = length, p2y = 0;
|
||||||
float cx = length / 2, cy = length / 8f * bendPercent;
|
float cx = length / 2, cy = length / 8f * bendPercent;
|
||||||
@@ -216,10 +216,10 @@ public enum TargetingOverlay {
|
|||||||
float headSize = 17;
|
float headSize = 17;
|
||||||
|
|
||||||
float adjSize, ex, ey, abs_e;
|
float adjSize, ex, ey, abs_e;
|
||||||
adjSize = (float)(bodyWidth / 2 / Math.sqrt(2));
|
adjSize = (float) (bodyWidth / 2 / Math.sqrt(2));
|
||||||
ex = p2x - cx;
|
ex = p2x - cx;
|
||||||
ey = p2y - cy;
|
ey = p2y - cy;
|
||||||
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
|
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
|
||||||
ex /= abs_e;
|
ex /= abs_e;
|
||||||
ey /= abs_e;
|
ey /= abs_e;
|
||||||
GeneralPath bodyPath = new GeneralPath();
|
GeneralPath bodyPath = new GeneralPath();
|
||||||
@@ -229,10 +229,10 @@ public enum TargetingOverlay {
|
|||||||
bodyPath.quadTo(cx, cy, p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
|
bodyPath.quadTo(cx, cy, p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
|
||||||
bodyPath.closePath();
|
bodyPath.closePath();
|
||||||
|
|
||||||
adjSize = (float)(headSize / Math.sqrt(2));
|
adjSize = (float) (headSize / Math.sqrt(2));
|
||||||
ex = p2x - cx;
|
ex = p2x - cx;
|
||||||
ey = p2y - cy;
|
ey = p2y - cy;
|
||||||
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
|
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
|
||||||
ex /= abs_e;
|
ex /= abs_e;
|
||||||
ey /= abs_e;
|
ey /= abs_e;
|
||||||
GeneralPath headPath = new GeneralPath();
|
GeneralPath headPath = new GeneralPath();
|
||||||
@@ -251,10 +251,12 @@ public enum TargetingOverlay {
|
|||||||
float ey = endY - startY;
|
float ey = endY - startY;
|
||||||
if (ex == 0 && ey == 0) { return; }
|
if (ex == 0 && ey == 0) { return; }
|
||||||
|
|
||||||
float length = (float)Math.sqrt(ex * ex + ey * ey);
|
float length = (float) Math.sqrt(ex * ex + ey * ey);
|
||||||
float bendPercent = (float)Math.asin(ey / length);
|
float bendPercent = (float) Math.asin(ey / length);
|
||||||
|
|
||||||
if (endX > startX) bendPercent = -bendPercent;
|
if (endX > startX) {
|
||||||
|
bendPercent = -bendPercent;
|
||||||
|
}
|
||||||
|
|
||||||
Area arrow = getArrow(length, bendPercent);
|
Area arrow = getArrow(length, bendPercent);
|
||||||
AffineTransform af = g2d.getTransform();
|
AffineTransform af = g2d.getTransform();
|
||||||
@@ -295,10 +297,10 @@ public enum TargetingOverlay {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int endX = (int)p[0].getX();
|
int endX = (int) p[0].getX();
|
||||||
int endY = (int)p[0].getY();
|
int endY = (int) p[0].getY();
|
||||||
int startX = (int)p[1].getX();
|
int startX = (int) p[1].getX();
|
||||||
int startY = (int)p[1].getY();
|
int startY = (int) p[1].getY();
|
||||||
|
|
||||||
Color color = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
|
Color color = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
|
||||||
drawArrow(g2d, startX, startY, endX, endY, color);
|
drawArrow(g2d, startX, startY, endX, endY, color);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class VAssignDamage {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active != this.lstDamage.size() -1) {
|
if (active != this.lstDamage.size() - 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user