v0.2.3: improvements to the rankings page

This commit is contained in:
Evan Debenham
2015-01-03 21:55:40 -05:00
parent 0db40dbf87
commit 872199b43e
26 changed files with 115 additions and 44 deletions
@@ -43,6 +43,8 @@ public enum Rankings {
public ArrayList<Record> records;
public int lastRecord;
public int totalNumber;
private boolean saveNeeded = false;
public void submit( boolean win ) {
@@ -54,6 +56,8 @@ public enum Rankings {
rec.win = win;
rec.heroClass = Dungeon.hero.heroClass;
rec.armorTier = Dungeon.hero.tier();
rec.herolevel = Dungeon.hero.lvl;
rec.depth = Dungeon.depth;
rec.score = score( win );
String gameFile = Utils.format( DETAILS_FILE, SystemTime.now );
@@ -138,7 +142,7 @@ public enum Rankings {
if (totalNumber == 0) {
totalNumber = records.size();
}
} catch (IOException e) {
}
}
@@ -149,6 +153,8 @@ public enum Rankings {
private static final String WIN = "win";
private static final String SCORE = "score";
private static final String TIER = "tier";
private static final String LEVEL = "level";
private static final String DEPTH = "depth";
private static final String GAME = "gameFile";
public String info;
@@ -156,6 +162,8 @@ public enum Rankings {
public HeroClass heroClass;
public int armorTier;
public int herolevel; //not currently used, but I may want this here in the future.
public int depth;
public int score;
@@ -172,6 +180,25 @@ public enum Rankings {
armorTier = bundle.getInt( TIER );
gameFile = bundle.getString( GAME );
//for pre 0.2.3 saves
if (!bundle.contains(LEVEL)){
try {
depth = Integer.parseInt(info.replaceAll("[\\D]", ""));
} catch (Exception e) {
depth = 0;
}
info = info.split("on level")[0].trim();
try {
Dungeon.loadGame(gameFile);
herolevel = Dungeon.hero.lvl;
} catch (Exception e){
herolevel = 0;
}
} else {
depth = bundle.getInt( DEPTH );
herolevel = bundle.getInt( LEVEL );
}
}
@Override
@@ -183,6 +210,8 @@ public enum Rankings {
heroClass.storeInBundle( bundle );
bundle.put( TIER, armorTier );
bundle.put( LEVEL, herolevel );
bundle.put( DEPTH, depth );
bundle.put( GAME, gameFile );
}