Skip to content

Commit

Permalink
Jungle princess support
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Sep 10, 2024
1 parent eaf1e0a commit 8fec0de
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
13 changes: 13 additions & 0 deletions testsystem/vPinball/VisualPinball/User/jungleprincess_1977_v2a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
75000
70000
60000
55000
50000
AAA
ZZZ
XXX
ABC
BBB



Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
0
0
0
0
0
???
???
???
???
???



Binary file modified testsystem/vpin-studio.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.mephisto.vpin.restclient.system.ScoringDB;
import de.mephisto.vpin.server.AbstractVPinServerTest;
import de.mephisto.vpin.server.highscores.HighscoreMetadata;
import de.mephisto.vpin.server.highscores.Score;
import de.mephisto.vpin.server.highscores.parsing.text.TextHighscoreConverters;
import org.apache.commons.io.FilenameUtils;
Expand All @@ -13,8 +14,7 @@
import java.util.Date;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
public class TextParsingTest extends AbstractVPinServerTest {
Expand All @@ -29,13 +29,41 @@ public void testAllTextFiles() {
File[] files = folder.listFiles((dir, name) -> name.endsWith(".txt") && !FilenameUtils.getBaseName(name).endsWith("LUT"));
int count = 0;
for (File entry : files) {
HighscoreMetadata highscoreMetadata = new HighscoreMetadata();
System.out.println("Reading '" + entry.getName() + "'");
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(scoringDB, entry);
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(highscoreMetadata, scoringDB, entry);
assertNull(highscoreMetadata.getStatus());
if (raw != null) {
List<Score> scores = highscoreParsingService.parseScores(new Date(entry.lastModified()), raw, -1, -1);
assertNotNull(scores, "Reading failed for " + entry);
assertFalse(scores.isEmpty(), "No score entry found for " + entry);
assertNotNull(scores.get(0).getPlayerInitials(), "No score initials found for " + entry);
assertNull(highscoreMetadata.getStatus());
}
}
System.out.println("Tested " + count + " entries");
}

@Test
public void testSingleTextFiles() {
ScoringDB scoringDB = ScoringDB.load();
File folder = new File("../testsystem/vPinball/VisualPinball/User/");
File[] files = folder.listFiles((dir, name) -> name.endsWith(".txt") && !FilenameUtils.getBaseName(name).endsWith("LUT"));
int count = 0;
for (File entry : files) {
HighscoreMetadata highscoreMetadata = new HighscoreMetadata();
if(entry.getName().equals("jungleprincess_1977_v2a.txt")) {
System.out.println("Reading '" + entry.getName() + "'");
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(highscoreMetadata, scoringDB, entry);
assertNull(highscoreMetadata.getStatus());
if (raw != null) {
List<Score> scores = highscoreParsingService.parseScores(new Date(entry.lastModified()), raw, -1, -1);
assertNotNull(scores, "Reading failed for " + entry);
assertFalse(scores.isEmpty(), "No score entry found for " + entry);
assertNotNull(scores.get(0).getPlayerInitials(), "No score initials found for " + entry);
assertNull(highscoreMetadata.getStatus());
}
break;
}
}
System.out.println("Tested " + count + " entries");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.mephisto.vpin.restclient.highscores.DefaultHighscoresTitles;
import de.mephisto.vpin.restclient.highscores.logging.SLOG;
import de.mephisto.vpin.restclient.system.ScoringDB;
import de.mephisto.vpin.server.highscores.HighscoreMetadata;
import de.mephisto.vpin.server.highscores.Score;
import de.mephisto.vpin.server.highscores.parsing.RawScoreParser;
import de.mephisto.vpin.server.highscores.parsing.text.adapters.ScoreTextFileAdapter;
Expand Down Expand Up @@ -39,7 +40,7 @@ public void testAllTextFiles() {
}

System.out.println("Reading '" + entry.getName() + "'");
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(scoringDB, entry);
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(new HighscoreMetadata(), scoringDB, entry);

System.out.println(raw);

Expand Down Expand Up @@ -102,7 +103,7 @@ public void testSingle() {
ScoringDB scoringDB = ScoringDB.load();
File entry = new File("../testsystem/vPinball/VisualPinball/User/", "MountainClimbingHS.txt");
System.out.println("Reading '" + entry.getName() + "'");
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(scoringDB, entry);
String raw = TextHighscoreConverters.convertTextFileTextToMachineReadable(new HighscoreMetadata(), scoringDB, entry);

System.out.println(raw);

Expand Down

0 comments on commit 8fec0de

Please sign in to comment.