mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Add Statistics screen for Planar Conquest
This commit is contained in:
@@ -312,7 +312,7 @@ public final class ConquestData {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getUnlockedCount() {
|
||||
public int getUnlockedCardCount() {
|
||||
return unlockedCards.size();
|
||||
}
|
||||
|
||||
@@ -384,6 +384,95 @@ public final class ConquestData {
|
||||
return chaosBattleRecord;
|
||||
}
|
||||
|
||||
public void updateStatLabels(IVConquestStats view, ConquestPlane plane) {
|
||||
int wins = 0;
|
||||
int losses = 0;
|
||||
int conqueredCount = 0;
|
||||
int totalEventCount = 0;
|
||||
int unlockedCardCount = 0;
|
||||
int totalCardCount = 0;
|
||||
int commanderCount = 0;
|
||||
int totalCommanderCount = 0;
|
||||
int planeswalkerCount = 0;
|
||||
int totalPlaneswalkerCount = 0;
|
||||
|
||||
if (plane != null) {
|
||||
ConquestPlaneData planeData = planeDataMap.get(plane.getName());
|
||||
if (planeData != null) {
|
||||
wins = planeData.getTotalWins();
|
||||
losses = planeData.getTotalLosses();
|
||||
conqueredCount = planeData.getConqueredCount();
|
||||
}
|
||||
|
||||
for (ConquestCommander commander : commanders) {
|
||||
if (plane.getCommanders().contains(commander.getCard())) {
|
||||
commanderCount++;
|
||||
}
|
||||
}
|
||||
|
||||
totalEventCount = plane.getEventCount();
|
||||
totalCardCount = plane.getCardPool().size();
|
||||
totalCommanderCount = plane.getCommanders().size();
|
||||
|
||||
for (PaperCard card : plane.getCardPool().getAllCards()) {
|
||||
boolean unlocked = hasUnlockedCard(card);
|
||||
if (unlocked) {
|
||||
unlockedCardCount++;
|
||||
}
|
||||
if (card.getRules().getType().isPlaneswalker()) {
|
||||
if (unlocked) {
|
||||
planeswalkerCount++;
|
||||
}
|
||||
totalPlaneswalkerCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ConquestPlane p : FModel.getPlanes()) {
|
||||
ConquestPlaneData planeData = planeDataMap.get(p.getName());
|
||||
if (planeData != null) {
|
||||
wins += planeData.getTotalWins();
|
||||
losses += planeData.getTotalLosses();
|
||||
conqueredCount += planeData.getConqueredCount();
|
||||
}
|
||||
|
||||
totalEventCount += p.getEventCount();
|
||||
totalCardCount += p.getCardPool().size();
|
||||
totalCommanderCount += p.getCommanders().size();
|
||||
|
||||
for (PaperCard card : p.getCardPool().getAllCards()) {
|
||||
boolean unlocked = hasUnlockedCard(card);
|
||||
if (unlocked) {
|
||||
unlockedCardCount++;
|
||||
}
|
||||
if (card.getRules().getType().isPlaneswalker()) {
|
||||
if (unlocked) {
|
||||
planeswalkerCount++;
|
||||
}
|
||||
totalPlaneswalkerCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
commanderCount = commanders.size();
|
||||
}
|
||||
|
||||
view.getLblAEtherShards().setText("AEther Shards: " + aetherShards);
|
||||
view.getLblPlaneswalkEmblems().setText("Planeswalk Emblems: " + planeswalkEmblems);
|
||||
view.getLblTotalWins().setText("Total Wins: " + wins);
|
||||
view.getLblTotalLosses().setText("Total Losses: " + losses);
|
||||
view.getLblConqueredEvents().setText("Conquered Events: " + formatRatio(conqueredCount, totalEventCount));
|
||||
view.getLblUnlockedCards().setText("Unlocked Cards: " + formatRatio(unlockedCardCount, totalCardCount));
|
||||
view.getLblCommanders().setText("Commanders: " + formatRatio(commanderCount, totalCommanderCount));
|
||||
view.getLblPlaneswalkers().setText("Planeswalkers: " + formatRatio(planeswalkerCount, totalPlaneswalkerCount));
|
||||
}
|
||||
|
||||
private String formatRatio(int numerator, int denominator) {
|
||||
if (denominator == 0) {
|
||||
return "0 / 0 (0%)";
|
||||
}
|
||||
return numerator + " / " + denominator + " (" + Math.round(100f * (float)numerator / (float)denominator) + "%)";
|
||||
}
|
||||
|
||||
public void rename(final String newName) {
|
||||
name = newName;
|
||||
File directory0 = new File(ForgeConstants.CONQUEST_SAVE_DIR, name.replace(' ', '_'));
|
||||
|
||||
@@ -80,7 +80,29 @@ public class ConquestPlaneData implements IXmlWritable {
|
||||
return conquered;
|
||||
}
|
||||
|
||||
public int getUnlockedCount() {
|
||||
public int getTotalWins() {
|
||||
int wins = 0;
|
||||
for (int i = 0; i < eventResults.length; i++) {
|
||||
ConquestEventRecord result = eventResults[i];
|
||||
if (result != null) {
|
||||
wins += result.getTotalWins();
|
||||
}
|
||||
}
|
||||
return wins;
|
||||
}
|
||||
|
||||
public int getTotalLosses() {
|
||||
int losses = 0;
|
||||
for (int i = 0; i < eventResults.length; i++) {
|
||||
ConquestEventRecord result = eventResults[i];
|
||||
if (result != null) {
|
||||
losses += result.getTotalLosses();
|
||||
}
|
||||
}
|
||||
return losses;
|
||||
}
|
||||
|
||||
public int getUnlockedCardCount() {
|
||||
int count = 0;
|
||||
ConquestData model = FModel.getConquest().getModel();
|
||||
for (PaperCard pc : location.getPlane().getCardPool().getAllCards()) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import forge.interfaces.IButton;
|
||||
|
||||
public interface IVConquestStats {
|
||||
IButton getLblAEtherShards();
|
||||
IButton getLblPlaneswalkEmblems();
|
||||
IButton getLblTotalWins();
|
||||
IButton getLblTotalLosses();
|
||||
IButton getLblConqueredEvents();
|
||||
IButton getLblUnlockedCards();
|
||||
IButton getLblCommanders();
|
||||
IButton getLblPlaneswalkers();
|
||||
}
|
||||
Reference in New Issue
Block a user