mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- CheckStyle.
This commit is contained in:
@@ -60,20 +60,21 @@ 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();
|
||||
view.getLblAvatar().getResizeTimer().start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates at a match with a specified number of players
|
||||
* and hands.
|
||||
@@ -83,10 +84,10 @@ public enum CMatchUI implements CardContainer {
|
||||
*/
|
||||
public void initMatch(final List<Player> players, Player localPlayer) {
|
||||
// TODO fix for use with multiplayer
|
||||
|
||||
|
||||
final String[] indices = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||
|
||||
// Instantiate all required field slots (user at 0) <-- that's not guaranteed
|
||||
|
||||
// Instantiate all required field slots (user at 0) <-- that's not guaranteed
|
||||
final List<VField> fields = new ArrayList<VField>();
|
||||
final List<VCommand> commands = new ArrayList<VCommand>();
|
||||
|
||||
@@ -97,14 +98,16 @@ public enum CMatchUI implements CardContainer {
|
||||
setAvatar(humanField, FSkin.getAvatars().get(Integer.parseInt(indices[0])));
|
||||
humanField.getLayoutControl().initialize();
|
||||
humanCommand.getLayoutControl().initialize();
|
||||
|
||||
|
||||
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);
|
||||
@@ -112,11 +115,11 @@ public enum CMatchUI implements CardContainer {
|
||||
commands.add(c);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Instantiate all required hand slots (user at 0)
|
||||
final List<VHand> hands = new ArrayList<VHand>();
|
||||
VHand newHand = new VHand(EDocID.HAND_0, localPlayer);
|
||||
VHand newHand = new VHand(EDocID.HAND_0, localPlayer);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
|
||||
@@ -167,12 +170,13 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Fires up trample dialog. Very old code, due for refactoring with new UI.
|
||||
@@ -235,8 +239,8 @@ public enum CMatchUI implements CardContainer {
|
||||
public void setCard(final InventoryItem c) {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(c);
|
||||
CPicture.SINGLETON_INSTANCE.showCard(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card getCard() {
|
||||
return CDetail.SINGLETON_INSTANCE.getCurrentCard();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final MatchController match;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, MatchController match) {
|
||||
this.view = v;
|
||||
@@ -69,14 +69,14 @@ public class ControlWinLose {
|
||||
public void actionOnContinue() {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
|
||||
|
||||
boolean isAnte = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE);
|
||||
|
||||
//This is called from QuestWinLose also. If we're in a quest, this is already handled elsewhere
|
||||
if (isAnte && match.getGameType() != GameType.Quest) {
|
||||
executeAnte();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
match.startRound();
|
||||
}
|
||||
|
||||
@@ -111,14 +111,19 @@ public class ControlWinLose {
|
||||
*/
|
||||
private void executeAnte() {
|
||||
List<GameOutcome> games = match.getPlayedGames();
|
||||
|
||||
|
||||
|
||||
GameOutcome lastGame = match.getLastGameOutcome();
|
||||
if ( games.isEmpty() ) return;
|
||||
|
||||
for (Player p: Singletons.getModel().getGame().getRegisteredPlayers()) {
|
||||
if (!p.getName().equals(lastGame.getWinner().getName())) continue; // not a loser
|
||||
|
||||
if (games.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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>();
|
||||
for (Player loser : Singletons.getModel().getGame().getRegisteredPlayers()) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* Instantiates a new gauntlet win/lose handler.
|
||||
*
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, MatchController match) {
|
||||
super(view0, match);
|
||||
@@ -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
|
||||
|
||||
@@ -181,7 +181,7 @@ public class LimitedWinLose extends ControlWinLose {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
gauntlet.nextRound();
|
||||
}
|
||||
}
|
||||
else { // noone will get here - if round is lost, the button is inivisible anyway
|
||||
super.actionOnContinue();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* Instantiates a new quest win lose handler.
|
||||
*
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, MatchController match2) {
|
||||
super(view0, match2);
|
||||
@@ -117,28 +117,32 @@ public class QuestWinLose extends ControlWinLose {
|
||||
public final boolean populateCustomPanel() {
|
||||
this.getView().getBtnRestart().setVisible(false);
|
||||
qData.getCards().resetNewList();
|
||||
QuestController qc = Singletons.getModel().getQuest();
|
||||
QuestController qc = Singletons.getModel().getQuest();
|
||||
LobbyPlayer questPlayer = Singletons.getControl().getLobby().getQuestPlayer();
|
||||
if (isAnte) {
|
||||
//do per-game actions
|
||||
GameOutcome outcome = match.getLastGameOutcome();
|
||||
|
||||
|
||||
// Ante returns to owners in a draw
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -159,7 +163,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
// TODO: We don't have a enum for difficulty?
|
||||
int difficulty = qData.getAchievements().getDifficulty();
|
||||
|
||||
|
||||
|
||||
final int wins = qData.getAchievements().getWin();
|
||||
// Win case
|
||||
if (this.wonMatch) {
|
||||
@@ -181,7 +185,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
}
|
||||
|
||||
// Award jackpot every 80 games won (currently 10 rares)
|
||||
|
||||
|
||||
if ((wins > 0) && ((wins % 80) == 0)) {
|
||||
this.awardJackpot();
|
||||
}
|
||||
@@ -335,23 +339,23 @@ public class QuestWinLose extends ControlWinLose {
|
||||
sb.append(diff + " opponent: " + credBase + " credits.<br>");
|
||||
// Gameplay bonuses (for each game win)
|
||||
boolean hasNeverLost = true;
|
||||
|
||||
LobbyPlayer localHuman = Singletons.getControl().getLobby().getQuestPlayer();
|
||||
|
||||
LobbyPlayer localHuman = Singletons.getControl().getLobby().getQuestPlayer();
|
||||
for (final GameOutcome game : match.getPlayedGames()) {
|
||||
if (!game.isWinner(localHuman)) {
|
||||
hasNeverLost = false;
|
||||
continue; // no rewards for losing a game
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
final PlayerOutcome outcome = kvRating.getValue().getOutcome();
|
||||
final GameLossReason whyAiLost = outcome.lossState;
|
||||
final int altReward = this.getCreditsRewardForAltWin(whyAiLost);
|
||||
@@ -375,7 +379,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
credGameplay += 50;
|
||||
sb.append(String.format("Alternate win condition: <u>%s</u>! " + "Bonus: %d credits.<br>",
|
||||
winConditionName, 50));
|
||||
@@ -708,9 +712,11 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* @return int
|
||||
*/
|
||||
private int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
|
||||
QuestPreferences qp = Singletons.getModel().getQuestPreferences();
|
||||
if ( null == whyAiLost) // Felidar, Helix Pinnacle, etc.
|
||||
QuestPreferences qp = Singletons.getModel().getQuestPreferences();
|
||||
if (null == whyAiLost) {
|
||||
// Felidar, Helix Pinnacle, etc.
|
||||
return qp.getPreferenceInt(QPref.REWARDS_UNDEFEATED);
|
||||
}
|
||||
switch (whyAiLost) {
|
||||
case LifeReachedZero:
|
||||
return 0; // nothing special here, ordinary kill
|
||||
|
||||
@@ -58,7 +58,7 @@ public enum TargetingOverlay {
|
||||
private final List<Point[]> arcs = new ArrayList<Point[]>();
|
||||
|
||||
private CardPanel activePanel = null;
|
||||
|
||||
|
||||
/**
|
||||
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ public enum TargetingOverlay {
|
||||
// Only work with the active panel
|
||||
if (activePanel == null) { return; }
|
||||
Card c = activePanel.getCard();
|
||||
|
||||
|
||||
Card enchanting = c.getEnchantingCard();
|
||||
List<Card> enchantedBy = c.getEnchantedBy();
|
||||
List<Card> blocking = c.getBlockedThisTurn();
|
||||
@@ -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();
|
||||
@@ -289,16 +291,16 @@ public enum TargetingOverlay {
|
||||
assembleArcs();
|
||||
if (arcs.size() < 1) { return; }
|
||||
|
||||
|
||||
|
||||
for (Point[] p : arcs) {
|
||||
if (p[0] == null || p[1] == null) {
|
||||
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);
|
||||
|
||||
@@ -82,20 +82,20 @@ public class VAssignDamage {
|
||||
|
||||
private boolean canAssignToIndex(Integer selectedIndex) {
|
||||
Integer active = this.activeIndex;
|
||||
|
||||
|
||||
if (selectedIndex == null) {
|
||||
// Trying to assign to the opponent
|
||||
if (active == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (active != this.lstDamage.size() -1) {
|
||||
|
||||
if (active != this.lstDamage.size() - 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int activeLethal = this.deathtouch ? 1 : lstDefenders.get(active).getLethalDamage();
|
||||
int assignedToActive = lstDamage.get(active);
|
||||
|
||||
int assignedToActive = lstDamage.get(active);
|
||||
|
||||
if (assignedToActive < activeLethal) {
|
||||
return false;
|
||||
}
|
||||
@@ -105,22 +105,22 @@ public class VAssignDamage {
|
||||
if (active == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (active.equals(selectedIndex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int activeLethal = this.deathtouch ? 1 : lstDefenders.get(active).getLethalDamage();
|
||||
int assignedToActive = lstDamage.get(active);
|
||||
|
||||
int assignedToActive = lstDamage.get(active);
|
||||
|
||||
if (active != selectedIndex - 1 || assignedToActive < activeLethal) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Mouse actions
|
||||
private final MouseAdapter madDefender = new MouseAdapter() {
|
||||
@Override
|
||||
@@ -143,7 +143,7 @@ public class VAssignDamage {
|
||||
public void mousePressed(final MouseEvent evt) {
|
||||
Card source = ((CardPanel) evt.getSource()).getCard();
|
||||
int index = lstDefenders.indexOf(source);
|
||||
|
||||
|
||||
// Allow click if this is active, or next to active and active has lethal
|
||||
if (!VAssignDamage.this.canAssignToIndex(index)) {
|
||||
return;
|
||||
@@ -154,7 +154,7 @@ public class VAssignDamage {
|
||||
// If lethal damage has already been assigned just act like it's 0.
|
||||
int lethal = VAssignDamage.this.deathtouch ? 1 : Math.max(0, source.getLethalDamage());
|
||||
int assignedDamage = 1;
|
||||
|
||||
|
||||
// Add damage for left clicks, as much as we can for ctrl clicking
|
||||
if (SwingUtilities.isLeftMouseButton(evt)) {
|
||||
if (meta) {
|
||||
@@ -166,7 +166,7 @@ public class VAssignDamage {
|
||||
|
||||
assignCombatantDamage(source, assignedDamage);
|
||||
}
|
||||
|
||||
|
||||
// Remove damage for right clicks, as much as we can for ctrl clicking
|
||||
else if (SwingUtilities.isRightMouseButton(evt)) {
|
||||
if (meta) {
|
||||
@@ -246,10 +246,10 @@ public class VAssignDamage {
|
||||
|
||||
private final Command cmdOK = new Command() { @Override
|
||||
public void execute() { finish(); } };
|
||||
|
||||
|
||||
private final Command cmdReset = new Command() { @Override
|
||||
public void execute() { resetAssignDamage(); } };
|
||||
|
||||
|
||||
private final Command cmdAuto = new Command() { @Override
|
||||
public void execute() { autoAssignDamage(); } };
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
EDocID.valueOf("FIELD_" + i).setDoc(
|
||||
new VEmptyDoc(EDocID.valueOf("FIELD_" + i)));
|
||||
}
|
||||
|
||||
|
||||
// Create empty docs for all field slots
|
||||
for (int i = 0; i < 8; i++) {
|
||||
EDocID.valueOf("COMMAND_" + i).setDoc(
|
||||
@@ -103,7 +103,7 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
lstFields.get(1).getParentCell().addDoc(lstFields.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add extra players alternatively to existing user/AI field panels.
|
||||
for (int i = 2; i < lstCommands.size(); i++) {
|
||||
// If already in layout, no need to add again.
|
||||
|
||||
Reference in New Issue
Block a user