Files
OcheCompanion/TestCheckoutGeneration.java
Alexander Doerflinger c2f18d9328 feat: implement comprehensive statistics tracking and refactor checkout engine
BREAKING CHANGE: Database schema updated from v3 to v9 (destructive migration)

Major Features:
- Statistics system: Track player performance (darts, points, matches, double-outs)
- Match state management: ONGOING/COMPLETED/CANCELED with state-based queries
- Settings activity: Day/night mode and standard game mode preferences
- CheckoutEngine refactored to standalone utility class with 1/2/3-dart methods

CheckoutConstants Overhaul:
- Generate all possible double-out combinations (~37,200 routes)
- Intelligent route selection (fewer darts > T20/T19 > higher doubles)
- Store both optimal routes and complete alternatives

GameActivity Enhancements:
- Automatic statistics tracking on turn submission and win
- Career average calculation and database updates
- Fixed race condition with dart value capture

Database Changes:
- Added Statistics entity and StatisticsDao
- Player ID migration: int → long for consistency
- Match entity: added MatchState enum and helper methods
- MatchDao: new state-based query methods

Developer Experience:
- Comprehensive JavaDoc across all new/modified classes
- Test harness for checkout generation validation
- Improved code organization with utils package separation
2026-01-30 08:21:26 +01:00

39 lines
1.7 KiB
Java

import com.aldo.apps.ochecompanion.utils.CheckoutConstants;
import java.util.List;
/**
* Quick test to verify checkout generation statistics.
*/
public class TestCheckoutGeneration {
public static void main(String[] args) {
System.out.println("=== Checkout Generation Statistics ===");
System.out.println("Total unique scores with checkouts: " + CheckoutConstants.getAvailableCheckouts().size());
System.out.println("Total checkout combinations: " + CheckoutConstants.getTotalRoutesCount());
System.out.println("\n=== Sample Checkouts ===");
// Test some common scores
int[] testScores = {2, 40, 50, 100, 120, 141, 170};
for (int score : testScores) {
String[] optimal = CheckoutConstants.getCheckoutRoute(score);
List<String[]> all = CheckoutConstants.getAllCheckoutRoutes(score);
if (optimal != null) {
System.out.println("\nScore " + score + ":");
System.out.println(" Optimal: " + String.join(", ", optimal));
System.out.println(" Total routes: " + (all != null ? all.size() : 0));
// Show first 3 alternatives if available
if (all != null && all.size() > 1) {
System.out.println(" Alternatives:");
for (int i = 0; i < Math.min(3, all.size()); i++) {
if (!java.util.Arrays.equals(all.get(i), optimal)) {
System.out.println(" - " + String.join(", ", all.get(i)));
}
}
}
}
}
}
}