v0.3.4: improved how pre-0.3.4 rankings are handled
This commit is contained in:
parent
0b43873d65
commit
a2d6a7bda5
|
@ -20,7 +20,21 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon;
|
package com.shatteredpixel.shatteredpixeldungeon;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM300;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Goo;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Tengu;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.utils.Bundlable;
|
import com.watabou.utils.Bundlable;
|
||||||
|
@ -191,14 +205,21 @@ public enum Rankings {
|
||||||
public String gameFile;
|
public String gameFile;
|
||||||
|
|
||||||
public String desc(){
|
public String desc(){
|
||||||
if (cause == null && (info == null || info.equals("")))
|
if (cause == null) {
|
||||||
return "Killed by Something";
|
if (info != null){
|
||||||
else if (cause == null){
|
//support for pre-0.3.4 saves
|
||||||
return info; //pre 0.3.4 saves
|
if (Messages.lang() == Languages.ENGLISH) {
|
||||||
|
return info;
|
||||||
|
} else {
|
||||||
|
return Messages.get(this, "something");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Messages.get(this, "something");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String result = Messages.get(cause, "rankings_desc", (Messages.get(cause, "name")));
|
String result = Messages.get(cause, "rankings_desc", (Messages.get(cause, "name")));
|
||||||
if (result.contains("!!!NO TEXT FOUND!!!")){
|
if (result.contains("!!!NO TEXT FOUND!!!")){
|
||||||
return "Killed By Something";
|
return Messages.get(this, "something");
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -208,10 +229,30 @@ public enum Rankings {
|
||||||
@Override
|
@Override
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
|
|
||||||
//pre-0.3.4
|
//conversion logic for pre-0.3.4 saves
|
||||||
info = bundle.getString( REASON );
|
if (bundle.contains( REASON )){
|
||||||
|
String info = bundle.getString( REASON ).toLowerCase();
|
||||||
|
if (info.equals("obtained the amulet of yendor")) cause = Amulet.class;
|
||||||
|
else if (info.contains("goo")) cause = Goo.class;
|
||||||
|
else if (info.contains("tengu")) cause = Tengu.class;
|
||||||
|
else if (info.contains("dm-300")) cause = DM300.class;
|
||||||
|
else if (info.contains("king")) cause = King.class;
|
||||||
|
else if (info.contains("yog")) cause = Yog.class;
|
||||||
|
else if (info.contains("fist")) cause = Yog.class;
|
||||||
|
else if (info.contains("larva")) cause = Yog.class;
|
||||||
|
else if (info.equals("burned to ash")) cause = Burning.class;
|
||||||
|
else if (info.equals("starved to death")) cause = Hunger.class;
|
||||||
|
else if (info.equals("succumbed to poison")) cause = Poison.class;
|
||||||
|
else if (info.equals("suffocated")) cause = ToxicGas.class;
|
||||||
|
else if (info.equals("bled to death")) cause = Bleeding.class;
|
||||||
|
else if (info.equals("melted away")) cause = Ooze.class;
|
||||||
|
else if (info.equals("died on impact")) cause = Chasm.class;
|
||||||
|
//can't get the all, just keep what remains as-is
|
||||||
|
else this.info = info;
|
||||||
|
} else {
|
||||||
|
cause = bundle.getClass( CAUSE );
|
||||||
|
}
|
||||||
|
|
||||||
cause = bundle.getClass( CAUSE );
|
|
||||||
win = bundle.getBoolean( WIN );
|
win = bundle.getBoolean( WIN );
|
||||||
score = bundle.getInt( SCORE );
|
score = bundle.getInt( SCORE );
|
||||||
|
|
||||||
|
@ -220,47 +261,15 @@ public enum Rankings {
|
||||||
|
|
||||||
gameFile = bundle.getString( GAME );
|
gameFile = bundle.getString( GAME );
|
||||||
|
|
||||||
//Here lies a collection of messy logic, some to account for transferring pre-0.2.3 rankings to the new
|
depth = bundle.getInt( DEPTH );
|
||||||
//system, some to account for errors in that process which were patched.
|
herolevel = bundle.getInt( LEVEL );
|
||||||
//commented here is info about what was added when, and why, eventually after almost everyone has
|
|
||||||
//dropped 0.2.2 this can be phased out.
|
|
||||||
|
|
||||||
//0.2.3, adds depth and parses info, works almost perfectly, except for the edge case in the next comment.
|
|
||||||
if (!bundle.contains(DEPTH)){
|
|
||||||
try {
|
|
||||||
depth = Integer.parseInt(info.replaceAll("[\\D]", ""));
|
|
||||||
} catch (Exception e) {
|
|
||||||
depth = 0;
|
|
||||||
}
|
|
||||||
info = info.split("on level")[0].trim();
|
|
||||||
} else
|
|
||||||
depth = bundle.getInt( DEPTH );
|
|
||||||
|
|
||||||
//0.2.3d, fixes a case where a player who died to dm-300 would have a recorded depth of 30015.
|
|
||||||
if (depth == 30015) depth = 15;
|
|
||||||
|
|
||||||
//basically every patch until 0.2.3d, extracts the hero's level from the bundle structure.
|
|
||||||
//the second condition in the if is important, helps account for bugged rankings from pre 0.2.3d
|
|
||||||
if (!bundle.contains(LEVEL) || bundle.getInt(LEVEL) == 0 && ShatteredPixelDungeon.version() < 30) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
InputStream input = Game.instance.openFileInput(gameFile);
|
|
||||||
Bundle gameBundle = Bundle.read(input);
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
herolevel = gameBundle.getBundle("hero").getInt("lvl");
|
|
||||||
} catch (Exception e) {
|
|
||||||
herolevel = 0;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
herolevel = bundle.getInt( LEVEL );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle( Bundle bundle ) {
|
public void storeInBundle( Bundle bundle ) {
|
||||||
|
|
||||||
if (info != null && !info.equals("")) bundle.put( REASON, info );
|
if (info != null) bundle.put( REASON, info );
|
||||||
else bundle.put( CAUSE, cause );
|
else bundle.put( CAUSE, cause );
|
||||||
|
|
||||||
bundle.put( WIN, win );
|
bundle.put( WIN, win );
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class Messages {
|
||||||
private static final HashSet<String> noCaps = new HashSet<>(
|
private static final HashSet<String> noCaps = new HashSet<>(
|
||||||
Arrays.asList(new String[]{
|
Arrays.asList(new String[]{
|
||||||
//English
|
//English
|
||||||
"a", "of", "by", "to",
|
"a", "of", "by", "to", "the"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -84,3 +84,5 @@ journal$feature.ghost=Sad ghost
|
||||||
journal$feature.wandmaker=Old wandmaker
|
journal$feature.wandmaker=Old wandmaker
|
||||||
journal$feature.troll=Troll blacksmith
|
journal$feature.troll=Troll blacksmith
|
||||||
journal$feature.imp=Ambitious imp
|
journal$feature.imp=Ambitious imp
|
||||||
|
|
||||||
|
rankings$record.something=Killed by Something
|
|
@ -185,7 +185,7 @@ public class RankingsScene extends PixelScene {
|
||||||
position.text(" ");
|
position.text(" ");
|
||||||
position.measure();
|
position.measure();
|
||||||
|
|
||||||
desc.text( rec.desc() );
|
desc.text( Messages.titleCase(rec.desc()) );
|
||||||
|
|
||||||
//desc.measure();
|
//desc.measure();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user