Refactor shared parts of certain descriptions into separate field so it can be displayed on its own line

This commit is contained in:
drdev
2014-09-17 04:13:17 +00:00
parent 2a871c2525
commit 69255650a8
14 changed files with 73 additions and 57 deletions

View File

@@ -14,18 +14,19 @@ import forge.util.FileUtil;
import forge.util.gui.SOptionPane;
public abstract class Achievement {
private final String displayName, bronzeDesc, silverDesc, goldDesc;
private final String displayName, sharedDesc, bronzeDesc, silverDesc, goldDesc;
private final int bronzeThreshold, silverThreshold, goldThreshold;
private final boolean checkGreaterThan;
private String imagePrefix;
private ISkinImage customImage;
protected int best, current;
public Achievement(String displayName0,
public Achievement(String displayName0, String sharedDesc0,
String bronzeDesc0, int bronzeThreshold0,
String silverDesc0, int silverThreshold0,
String goldDesc0, int goldThreshold0) {
displayName = displayName0;
sharedDesc = sharedDesc0;
bronzeDesc = bronzeDesc0;
bronzeThreshold = bronzeThreshold0;
silverDesc = silverDesc0;
@@ -38,6 +39,9 @@ public abstract class Achievement {
public String getDisplayName() {
return displayName;
}
public String getSharedDesc() {
return sharedDesc;
}
public String getBronzeDesc() {
return bronzeDesc;
}
@@ -157,8 +161,11 @@ public abstract class Achievement {
updateCustomImage();
}
});
if (sharedDesc != null) {
desc = sharedDesc + " " + desc;
}
SOptionPane.showMessageDialog(gui, "You've earned a " + type + " trophy!\n\n" +
displayName + " - " + desc, "Achievement Earned", image);
displayName + "\n" + desc + ".", "Achievement Earned", image);
}
}

View File

@@ -8,10 +8,10 @@ public class Blackjack extends Achievement {
private static final int THRESHOLD = 21;
public Blackjack(int silver0, int gold0) {
super("Blackjack",
String.format("Win a game by dealing %d combat damage with your commander.", THRESHOLD), THRESHOLD,
String.format("Win a game by dealing %d combat damage with your commander.", silver0), silver0,
String.format("Win a game by dealing %d combat damage with your commander.", gold0), gold0);
super("Blackjack", "Win a game from your commander dealing",
String.format("%d combat damage", THRESHOLD), THRESHOLD,
String.format("%d combat damage", silver0), silver0,
String.format("%d combat damage", gold0), gold0);
}
@Override

View File

@@ -6,10 +6,10 @@ import forge.game.player.Player;
public class DeckedOut extends Achievement {
public DeckedOut(int silver0, int gold0) {
super("Decked Out",
"Win a game from opponent drawing into an empty library.", Integer.MAX_VALUE - 1,
String.format("Win a game this way by turn %d.", silver0), silver0,
String.format("Win a game this way by turn %d.", gold0), gold0);
super("Decked Out", "Win a game from opponent",
"drawing into an empty library", Integer.MAX_VALUE - 1,
String.format("drawing into an empty library by turn %d", silver0), silver0,
String.format("drawing into an empty library by turn %d", gold0), gold0);
best = Integer.MAX_VALUE;
}

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class GameWinStreak extends Achievement {
public GameWinStreak(int bronze0, int silver0, int gold0) {
super("Game Win Streak",
String.format("Win %d games in a row.", bronze0), bronze0,
String.format("Win %d games in a row.", silver0), silver0,
String.format("Win %d games in a row.", gold0), gold0);
super("Game Win Streak", null,
String.format("Win %d games in a row", bronze0), bronze0,
String.format("Win %d games in a row", silver0), silver0,
String.format("Win %d games in a row", gold0), gold0);
}
@Override

View File

@@ -6,10 +6,10 @@ import forge.game.zone.ZoneType;
public class Hellbent extends Achievement {
public Hellbent() {
super("Hellbent",
"Win game with no cards in hand.", 1,
"Win game with no cards in hand or library.", 2,
"Win game with no cards in hand, library, or graveyard.", 3);
super("Hellbent", "Win a game with no cards",
"in your hand", 1,
"in your hand or library", 2,
"in your hand, library, or graveyard", 3);
}
@Override

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class LifeToSpare extends Achievement {
public LifeToSpare(int bronze0, int silver0, int gold0) {
super("Life to Spare",
String.format("Win game with %d life more than you started with.", bronze0), bronze0,
String.format("Win game with %d life more than you started with.", silver0), silver0,
String.format("Win game with %d life more than you started with.", gold0), gold0);
super("Life to Spare", "Win a game with",
String.format("%d life more than you started with", bronze0), bronze0,
String.format("%d life more than you started with", silver0), silver0,
String.format("%d life more than you started with", gold0), gold0);
}
@Override

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class MatchWinStreak extends Achievement {
public MatchWinStreak(int bronze0, int silver0, int gold0) {
super("Match Win Streak",
String.format("Win %d matches in a row.", bronze0), bronze0,
String.format("Win %d matches in a row.", silver0), silver0,
String.format("Win %d matches in a row.", gold0), gold0);
super("Match Win Streak", null,
String.format("Win %d matches in a row", bronze0), bronze0,
String.format("Win %d matches in a row", silver0), silver0,
String.format("Win %d matches in a row", gold0), gold0);
}
@Override

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class NeedForSpeed extends Achievement {
public NeedForSpeed(int bronze0, int silver0, int gold0) {
super("Need for Speed",
String.format("Win a game by turn %d.", bronze0), bronze0,
String.format("Win a game by turn %d.", silver0), silver0,
String.format("Win a game by turn %d.", gold0), gold0);
super("Need for Speed", null,
String.format("Win a game by turn %d", bronze0), bronze0,
String.format("Win a game by turn %d", silver0), silver0,
String.format("Win a game by turn %d", gold0), gold0);
best = Integer.MAX_VALUE; //initialize best to max value so any
}

View File

@@ -7,10 +7,10 @@ import forge.game.player.Player;
public class Overkill extends Achievement {
public Overkill(int bronze0, int silver0, int gold0) {
super("Overkill",
String.format("Win game with opponent at %d life or less.", bronze0), bronze0,
String.format("Win game with opponent at %d life or less.", silver0), silver0,
String.format("Win game with opponent at %d life or less.", gold0), gold0);
super("Overkill", "Win a game with opponent at",
String.format("%d life.", bronze0), bronze0,
String.format("%d life", silver0), silver0,
String.format("%d life", gold0), gold0);
}
@Override

View File

@@ -8,10 +8,10 @@ public class Poisoned extends Achievement {
private static final int THRESHOLD = 10;
public Poisoned(int silver0, int gold0) {
super("Poisoned",
String.format("Win a game by giving opponent %d poison counters.", THRESHOLD), THRESHOLD,
String.format("Win a game by giving opponent %d poison counters.", silver0), silver0,
String.format("Win a game by giving opponent %d poison counters.", gold0), gold0);
super("Poisoned", "Win a game by giving opponent",
String.format("%d poison counters", THRESHOLD), THRESHOLD,
String.format("%d poison counters", silver0), silver0,
String.format("%d poison counters", gold0), gold0);
}
@Override

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class TotalGameWins extends Achievement {
public TotalGameWins(int bronze0, int silver0, int gold0) {
super("Total Game Wins",
String.format("Win %d games.", bronze0), bronze0,
String.format("Win %d games.", silver0), silver0,
String.format("Win %d games.", gold0), gold0);
super("Total Game Wins", null,
String.format("Win %d games", bronze0), bronze0,
String.format("Win %d games", silver0), silver0,
String.format("Win %d games", gold0), gold0);
}
@Override

View File

@@ -5,10 +5,10 @@ import forge.game.player.Player;
public class TotalMatchWins extends Achievement {
public TotalMatchWins(int bronze0, int silver0, int gold0) {
super("Total Match Wins",
String.format("Win %d matches.", bronze0), bronze0,
String.format("Win %d matches.", silver0), silver0,
String.format("Win %d matches.", gold0), gold0);
super("Total Match Wins", null,
String.format("Win %d matches", bronze0), bronze0,
String.format("Win %d matches", silver0), silver0,
String.format("Win %d matches", gold0), gold0);
}
@Override

View File

@@ -8,10 +8,10 @@ public class VariantWins extends Achievement {
private GameType variant;
public VariantWins(GameType variant0, int silver0, int gold0) {
super(variant0.toString(),
String.format("Win a %s game.", variant0.toString()), 1,
String.format("Win %d %s games.", silver0, variant0.toString()), silver0,
String.format("Win %d %s games.", gold0, variant0.toString()), gold0);
super(variant0.toString(), null,
String.format("Win a %s game", variant0.toString()), 1,
String.format("Win %d %s games", silver0, variant0.toString()), silver0,
String.format("Win %d %s games", gold0, variant0.toString()), gold0);
variant = variant0;
}