v1.3.0: seeded runs can now show up in rankings

This commit is contained in:
Evan Debenham
2022-06-15 23:11:43 -04:00
parent ab40c650f1
commit 35ef2fc0af
4 changed files with 30 additions and 15 deletions

View File

@@ -51,7 +51,7 @@ scenes.heroselectscene.options=Game Options
scenes.heroselectscene.custom_seed=Custom Seed
scenes.heroselectscene.daily=Daily Run
scenes.heroselectscene.custom_seed_title=Enter a Custom Seed
scenes.heroselectscene.custom_seed_desc=The same seed and game version always generate the same dungeon! Seeds are nine uppercase letters (e.g. ABC-DEF-GHI), but you can enter anything you want and the game will convert it. _Games with a custom seed cannot earn badges or appear in rankings._
scenes.heroselectscene.custom_seed_desc=The same seed and game version always generate the same dungeon! Seeds are nine uppercase letters (e.g. ABC-DEF-GHI), but you can enter anything you want and the game will convert it. _Games with a custom seed cannot earn badges, contribute to games played, and appear at the bottom of the rankings page._
scenes.heroselectscene.custom_seed_duplicate=You already have a regular game in progress with that seed. You must end that game before using that custom seed.
scenes.heroselectscene.custom_seed_set=Set
scenes.heroselectscene.custom_seed_clear=Clear

View File

@@ -168,7 +168,7 @@ windows.wndranking$statstab.gold=Gold Collected
windows.wndranking$statstab.food=Food Eaten
windows.wndranking$statstab.alchemy=Items Crafted
windows.wndranking$statstab.copy_seed=Copy Seed
windows.wndranking$statstab.copy_seed_desc=Would you like to use the dungeon seed from this ranking as a custom seed for a new game? _Note that games with a custom seed cannot earn badges or appear in rankings._\n\nIf this ranking is for an old run, also note that different versions of Shattered Pixel Dungeon may make different dungeons even if the seed is the same.
windows.wndranking$statstab.copy_seed_desc=Would you like to use the dungeon seed from this ranking as a custom seed for a new game? _Note that games with a custom seed cannot earn badges, contribute to games played, and appear at the bottom of the rankings page._\n\nIf this ranking is for an old run, also note that different versions of Shattered Pixel Dungeon may make different dungeons even if the seed is the same.
windows.wndranking$statstab.copy_seed_copy=Use this Seed
windows.wndranking$statstab.copy_seed_cancel=Cancel

View File

@@ -63,9 +63,6 @@ public enum Rankings {
public void submit( boolean win, Class cause ) {
//games with custom seeds do not appear in rankings
if (!Dungeon.customSeedText.isEmpty()) return;
load();
Record rec = new Record();
@@ -83,6 +80,7 @@ public enum Rankings {
rec.ascending = true;
}
rec.score = calculateScore();
rec.customSeed = Dungeon.customSeedText;
Badges.validateHighScore( rec.score );
@@ -107,10 +105,12 @@ public enum Rankings {
size = records.size();
}
totalNumber++;
if (win) {
wonNumber++;
if (rec.customSeed.isEmpty()) {
totalNumber++;
if (win) {
wonNumber++;
}
}
Badges.validateGamesPlayed();
@@ -355,6 +355,7 @@ public enum Rankings {
private static final String ASCEND = "ascending";
private static final String DATA = "gameData";
private static final String ID = "gameID";
private static final String SEED = "custom_seed";
public Class cause;
public boolean win;
@@ -371,6 +372,8 @@ public enum Rankings {
//Note this is for summary purposes, visible score should be re-calculated from game data
public int score;
public String customSeed;
public String desc(){
if (win){
if (ascending){
@@ -399,8 +402,9 @@ public enum Rankings {
cause = null;
}
win = bundle.getBoolean( WIN );
score = bundle.getInt( SCORE );
win = bundle.getBoolean( WIN );
score = bundle.getInt( SCORE );
customSeed = bundle.getString( SEED );
heroClass = bundle.getEnum( CLASS, HeroClass.class );
armorTier = bundle.getInt( TIER );
@@ -422,6 +426,7 @@ public enum Rankings {
bundle.put( WIN, win );
bundle.put( SCORE, score );
bundle.put( SEED, customSeed );
bundle.put( CLASS, heroClass );
bundle.put( TIER, armorTier );
@@ -437,10 +442,16 @@ public enum Rankings {
public static final Comparator<Record> scoreComparator = new Comparator<Rankings.Record>() {
@Override
public int compare( Record lhs, Record rhs ) {
if (rhs.customSeed.isEmpty() && !lhs.customSeed.isEmpty()){
return +1;
} else if (lhs.customSeed.isEmpty() && !rhs.customSeed.isEmpty()){
return -1;
}
int result = (int)Math.signum( rhs.score - lhs.score );
if (result == 0) {
return (int)Math.signum( rhs.gameID.hashCode() - lhs.gameID.hashCode());
} else{
} else {
return result;
}
}

View File

@@ -217,6 +217,10 @@ public class RankingsScene extends PixelScene {
}
if (!rec.customSeed.isEmpty()){
shield.view( ItemSpriteSheet.SEED_SUNGRASS, null );
}
if (rec.herolevel != 0){
level.text( Integer.toString(rec.herolevel) );
level.measure();
@@ -259,7 +263,7 @@ public class RankingsScene extends PixelScene {
super.layout();
shield.x = x;
shield.x = x + (16 - shield.width) / 2f;
shield.y = y + (height - shield.height) / 2f;
align(shield);
@@ -287,8 +291,8 @@ public class RankingsScene extends PixelScene {
depth.y = steps.y + (steps.height - depth.height()) / 2f + 1;
align(depth);
desc.maxWidth((int)(steps.x - (shield.x + shield.width + GAP)));
desc.setPos(shield.x + shield.width + GAP, shield.y + (shield.height - desc.height()) / 2f + 1);
desc.maxWidth((int)(steps.x - (x + 16 + GAP)));
desc.setPos(x + 16 + GAP, shield.y + (shield.height - desc.height()) / 2f + 1);
align(desc);
}