Skip to content

Commit

Permalink
return Pair values
Browse files Browse the repository at this point in the history
  • Loading branch information
kevlahnota committed Jul 12, 2022
1 parent 4fb89c1 commit 47f240a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
33 changes: 18 additions & 15 deletions forge-core/src/main/java/forge/StaticData.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,9 @@ public String[] getCardArtAvailablePreferences() {
preferences_avails[i] = prettifyCardArtPreferenceName(preferences[i]);
return preferences_avails;
}
public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int notImplementedCount) {
public Pair<Integer, Integer> audit(StringBuffer noImageFound, StringBuffer cardNotImplemented) {
int missingCount = 0;
int notImplementedCount = 0;
for (CardEdition e : editions) {
if (CardEdition.Type.FUNNY.equals(e.getType()))
continue;
Expand Down Expand Up @@ -792,10 +794,10 @@ public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int
if (!loadNonLegalCards && CardEdition.Type.FUNNY.equals(e.getType()))
continue;
if (!cniHeader) {
cniSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
cardNotImplemented.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
cniHeader = true;
}
cniSB.append(" ").append(c).append("\n");
cardNotImplemented.append(" ").append(c).append("\n");
notImplementedCount++;
continue;
}
Expand All @@ -808,10 +810,10 @@ public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int
file = ImageKeys.setLookUpFile(imagePath, imagePath+"border");
if (file == null) {
if (!nifHeader) {
nifSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
noImageFound.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
nifHeader = true;
}
nifSB.append(" ").append(imagePath).append("\n");
noImageFound.append(" ").append(imagePath).append("\n");
missingCount++;
}
}
Expand All @@ -825,10 +827,10 @@ public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int
file = ImageKeys.setLookUpFile(imagePath, imagePath+"border");
if (file == null) {
if (!nifHeader) {
nifSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
noImageFound.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
nifHeader = true;
}
nifSB.append(" ").append(imagePath).append("\n");
noImageFound.append(" ").append(imagePath).append("\n");
missingCount++;
}
}
Expand All @@ -850,14 +852,14 @@ public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int
File file = ImageKeys.getImageFile(imgKey);
if (file == null) {
if (!nifHeader) {
nifSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
noImageFound.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
nifHeader = true;
}
if (!tokenHeader) {
nifSB.append("\nTOKENS\n");
noImageFound.append("\nTOKENS\n");
tokenHeader = true;
}
nifSB.append(" ").append(token.getImageFilename(i + 1)).append("\n");
noImageFound.append(" ").append(token.getImageFilename(i + 1)).append("\n");
missingCount++;
}
}
Expand All @@ -866,15 +868,16 @@ public void audit(StringBuffer nifSB, StringBuffer cniSB, int missingCount, int
}
}
if (nifHeader)
nifSB.append("\n");
noImageFound.append("\n");
}

String totalStats = "Missing images: " + missingCount + "\nUnimplemented cards: " + notImplementedCount + "\n";
cniSB.append("\n-----------\n");
cniSB.append(totalStats);
cniSB.append("-----------\n\n");
cardNotImplemented.append("\n-----------\n");
cardNotImplemented.append(totalStats);
cardNotImplemented.append("-----------\n\n");

nifSB.append(cniSB); // combine things together...
noImageFound.append(cardNotImplemented); // combine things together...
return Pair.of(missingCount, notImplementedCount);
}

private String prettifyCardArtPreferenceName(CardDb.CardArtPreference preference) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import forge.util.Localizer;
import forge.util.RuntimeVersion;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.tuple.Pair;

/**
* Assembles Swing components of utilities submenu singleton.
Expand Down Expand Up @@ -220,9 +221,6 @@ public void run() {
* @param scr
*/
public void auditUpdate(FTextArea tar, FScrollPane scr) {
int missingCount = 0;
int notImplementedCount = 0;

StringBuffer nifSB = new StringBuffer(); // NO IMAGE FOUND BUFFER
StringBuffer cniSB = new StringBuffer(); // CARD NOT IMPLEMENTED BUFFER

Expand All @@ -234,7 +232,7 @@ public void auditUpdate(FTextArea tar, FScrollPane scr) {
cniSB.append("UNIMPLEMENTED CARD LIST\n");
cniSB.append("-------------------\n\n");

StaticData.instance().audit(nifSB, cniSB, missingCount, notImplementedCount);
Pair<Integer, Integer> totalAudit = StaticData.instance().audit(nifSB, cniSB);

tar.setText(nifSB.toString());
tar.setCaretPosition(0); // this will move scroll view to the top...
Expand All @@ -249,7 +247,7 @@ public void actionPerformed(final ActionEvent arg0) {
});
scr.getParent().add(btnClipboardCopy, "w 200!, h pref+12!, center, gaptop 10");

String labelText = "<html>Missing images: " + missingCount + "<br>Unimplemented cards: " + notImplementedCount + "<br>";
String labelText = "<html>Missing images: " + totalAudit.getLeft() + "<br>Unimplemented cards: " + totalAudit.getRight() + "<br>";
final FLabel statsLabel = new FLabel.Builder().text(labelText).fontSize(15).build();
scr.getParent().add(statsLabel);

Expand Down

0 comments on commit 47f240a

Please sign in to comment.