v0.2.3: improvements to the rankings page
This commit is contained in:
parent
0db40dbf87
commit
872199b43e
BIN
assets/icons.png
BIN
assets/icons.png
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.9 KiB |
|
@ -44,6 +44,8 @@ public enum Rankings {
|
|||
public int lastRecord;
|
||||
public int totalNumber;
|
||||
|
||||
private boolean saveNeeded = false;
|
||||
|
||||
public void submit( boolean win ) {
|
||||
|
||||
load();
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -20,25 +20,25 @@ package com.shatteredpixel.shatteredpixeldungeon;
|
|||
public class ResultDescriptions {
|
||||
|
||||
// Mobs
|
||||
public static final String MOB = "Killed by %s on level %d";
|
||||
public static final String UNIQUE = "Killed by the %s on level %d";
|
||||
public static final String NAMED = "Killed by %s on level %d";
|
||||
public static final String MOB = "Killed by %s";
|
||||
public static final String UNIQUE = "Killed by the %s";
|
||||
public static final String NAMED = "Killed by %s";
|
||||
|
||||
// Items
|
||||
public static final String ITEM = "Killed by your own %s on level %d";
|
||||
public static final String GLYPH = "Killed by the %s on level %d";
|
||||
public static final String ITEM = "Killed by your own %s";
|
||||
public static final String GLYPH = "Killed by the %s";
|
||||
|
||||
// Dungeon features
|
||||
public static final String TRAP = "Killed by a %s on level %d";
|
||||
public static final String TRAP = "Killed by a %s";
|
||||
|
||||
// Debuffs & blobs
|
||||
public static final String BURNING = "Burned to death on level %d";
|
||||
public static final String HUNGER = "Starved to death on level %d";
|
||||
public static final String POISON = "Died from poison on level %d";
|
||||
public static final String GAS = "Died from toxic gas on level %d";
|
||||
public static final String BLEEDING = "Bled to death on level %d";
|
||||
public static final String OOZE = "Corroded to death on level %d";
|
||||
public static final String FALL = "Fell to death on level %d";
|
||||
public static final String BURNING = "Burned to Ash";
|
||||
public static final String HUNGER = "Starved to Death";
|
||||
public static final String POISON = "Succumbed to Poison";
|
||||
public static final String GAS = "Asphyxiated";
|
||||
public static final String BLEEDING = "Bled to Death";
|
||||
public static final String OOZE = "Melted Away";
|
||||
public static final String FALL = "Died on Impact";
|
||||
|
||||
public static final String WIN = "Obtained the Amulet of Yendor";
|
||||
}
|
||||
|
|
|
@ -159,12 +159,11 @@ public abstract class Char extends Actor {
|
|||
|
||||
} else {
|
||||
if ( this instanceof Yog ) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.NAMED, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.NAMED, name) );
|
||||
} if (Bestiary.isUnique( this )) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name) );
|
||||
} else {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB,
|
||||
Utils.indefinite( name ), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name )) );
|
||||
}
|
||||
|
||||
GLog.n( TXT_KILL, name );
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ToxicGas extends Blob implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromGas();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GAS, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.GAS );
|
||||
GLog.n( "You died from a toxic gas.." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class Bleeding extends Buff {
|
|||
}
|
||||
|
||||
if (target == Dungeon.hero && !target.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.BLEEDING, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.BLEEDING );
|
||||
GLog.n( "You bled to death..." );
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class Burning extends Buff implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromFire();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.BURNING, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.BURNING );
|
||||
GLog.n( TXT_BURNED_TO_DEATH );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class Hunger extends Buff implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromHunger();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.HUNGER, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.HUNGER );
|
||||
GLog.n( TXT_DEATH );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Ooze extends Buff {
|
|||
else if (Random.Int(2) == 0)
|
||||
target.damage( 1, this );
|
||||
if (!target.isAlive() && target == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.OOZE, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.OOZE );
|
||||
GLog.n( TXT_HERO_KILLED, toString() );
|
||||
}
|
||||
spend( TICK );
|
||||
|
|
|
@ -90,7 +90,7 @@ public class Poison extends Buff implements Hero.Doom {
|
|||
public void onDeath() {
|
||||
Badges.validateDeathFromPoison();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.POISON, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.POISON );
|
||||
GLog.n( "You died from poison..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class Eye extends Mob {
|
|||
}
|
||||
|
||||
if (!ch.isAlive() && ch == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
GLog.n( TXT_DEATHGAZE_KILLED, name );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -106,8 +106,7 @@ public class Shaman extends Mob implements Callback {
|
|||
Camera.main.shake( 2, 0.3f );
|
||||
|
||||
if (!enemy.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB,
|
||||
Utils.indefinite( name ), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
GLog.n( TXT_LIGHTNING_KILLED, name );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class Skeleton extends Mob {
|
|||
}
|
||||
|
||||
if (heroKilled) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
GLog.n( TXT_HERO_KILLED );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,7 @@ public class Warlock extends Mob implements Callback {
|
|||
enemy.damage( dmg, this );
|
||||
|
||||
if (!enemy.isAlive() && enemy == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB,
|
||||
Utils.indefinite( name ), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
GLog.n( TXT_SHADOWBOLT_KILLED, name );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -335,7 +335,7 @@ public class Yog extends Mob {
|
|||
enemy.sprite.flash();
|
||||
|
||||
if (!enemy.isAlive() && enemy == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name ) );
|
||||
GLog.n( TXT_KILL, name );
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -127,7 +127,7 @@ public class Viscosity extends Glyph {
|
|||
if (target == Dungeon.hero && !target.isAlive()) {
|
||||
// FIXME
|
||||
Glyph glyph = new Viscosity();
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name(), Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name() ) );
|
||||
GLog.n( "%s killed you...", glyph.name() );
|
||||
|
||||
Badges.validateDeathFromGlyph();
|
||||
|
|
|
@ -107,7 +107,7 @@ public class ChaliceOfBlood extends Artifact {
|
|||
hero.damage(damage, this);
|
||||
|
||||
if (!hero.isAlive()) {
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth));
|
||||
Dungeon.fail(Utils.format( ResultDescriptions.ITEM, name ));
|
||||
GLog.n("The Chalice sucks your life essence dry...");
|
||||
} else {
|
||||
upgrade();
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ScrollOfPsionicBlast extends Scroll {
|
|||
curUser.spendAndNext( TIME_TO_READ );
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth));
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name ));
|
||||
GLog.n("The Psionic Blast tears your mind apart...");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class WandOfAvalanche extends Wand {
|
|||
}
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
|
||||
GLog.n( "You killed yourself with your own Wand of Avalanche..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class WandOfFirebolt extends Wand {
|
|||
ch.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
|
||||
|
||||
if (ch == curUser && !ch.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
|
||||
GLog.n( "You killed yourself with your own Wand of Firebolt..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class WandOfLightning extends Wand {
|
|||
protected void onZap( int cell ) {
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
|
||||
GLog.n( "You killed yourself with your own Wand of Lightning..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class WandOfMagicMissile extends Wand {
|
|||
ch.sprite.burst( 0xFF99CCFF, level / 2 + 2 );
|
||||
|
||||
if (ch == curUser && !ch.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
|
||||
GLog.n( "You killed yourself with your own Wand of Magic Missile..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public class Chasm {
|
|||
public void onDeath() {
|
||||
Badges.validateDeathFromFalling();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.FALL, Dungeon.depth ) );
|
||||
Dungeon.fail( ResultDescriptions.FALL );
|
||||
GLog.n( "You fell to death..." );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -45,7 +45,7 @@ public class LightningTrap {
|
|||
Camera.main.shake( 2, 0.3f );
|
||||
|
||||
if (!ch.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name, Dungeon.depth ) );
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
|
||||
GLog.n( "You were killed by a discharge of a lightning trap..." );
|
||||
} else {
|
||||
((Hero)ch).belongings.charge( false );
|
||||
|
|
|
@ -138,7 +138,10 @@ public class RankingsScene extends PixelScene {
|
|||
private Flare flare;
|
||||
private BitmapText position;
|
||||
private BitmapTextMultiline desc;
|
||||
private Image steps;
|
||||
private BitmapText depth;
|
||||
private Image classIcon;
|
||||
private BitmapText level;
|
||||
|
||||
public Record( int pos, boolean latest, Rankings.Record rec ) {
|
||||
super();
|
||||
|
@ -168,9 +171,29 @@ public class RankingsScene extends PixelScene {
|
|||
shield.view( ItemSpriteSheet.AMULET, null );
|
||||
position.hardlight( TEXT_WIN[odd] );
|
||||
desc.hardlight( TEXT_WIN[odd] );
|
||||
depth.hardlight( TEXT_WIN[odd] );
|
||||
level.hardlight( TEXT_WIN[odd] );
|
||||
} else {
|
||||
position.hardlight( TEXT_LOSE[odd] );
|
||||
desc.hardlight( TEXT_LOSE[odd] );
|
||||
depth.hardlight( TEXT_LOSE[odd] );
|
||||
level.hardlight( TEXT_LOSE[odd] );
|
||||
|
||||
if (rec.depth != 0){
|
||||
depth.text( Integer.toString(rec.depth) );
|
||||
depth.measure();
|
||||
steps.copy(Icons.DEPTH_LG.get());
|
||||
|
||||
add(steps);
|
||||
add(depth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (rec.herolevel != 0){
|
||||
level.text( Integer.toString(rec.herolevel) );
|
||||
level.measure();
|
||||
add(level);
|
||||
}
|
||||
|
||||
classIcon.copy( Icons.get( rec.heroClass ) );
|
||||
|
@ -185,13 +208,22 @@ public class RankingsScene extends PixelScene {
|
|||
add( shield );
|
||||
|
||||
position = new BitmapText( PixelScene.font1x );
|
||||
position.alpha(0.8f);
|
||||
add( position );
|
||||
|
||||
desc = createMultiline( 9 );
|
||||
add( desc );
|
||||
|
||||
depth = new BitmapText( PixelScene.font1x );
|
||||
depth.alpha(0.8f);
|
||||
|
||||
steps = new Image();
|
||||
|
||||
classIcon = new Image();
|
||||
add( classIcon );
|
||||
|
||||
level = new BitmapText( PixelScene.font1x );
|
||||
level.alpha(0.8f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,11 +241,20 @@ public class RankingsScene extends PixelScene {
|
|||
flare.point( shield.center() );
|
||||
}
|
||||
|
||||
classIcon.x = align( x + width - classIcon.width );
|
||||
classIcon.x = align(x + width - classIcon.width);
|
||||
classIcon.y = shield.y;
|
||||
|
||||
level.x = align( classIcon.x + (classIcon.width - level.width()) / 2 );
|
||||
level.y = align( classIcon.y + (classIcon.height - level.height()) / 2 + 1 );
|
||||
|
||||
steps.x = align(x + width - steps.width - classIcon.width);
|
||||
steps.y = shield.y;
|
||||
|
||||
depth.x = align( steps.x + (steps.width - depth.width()) / 2 );
|
||||
depth.y = align( steps.y + (steps.height - depth.height()) / 2 + 1 );
|
||||
|
||||
desc.x = shield.x + shield.width + GAP;
|
||||
desc.maxWidth = (int)(classIcon.x - desc.x);
|
||||
desc.maxWidth = (int)(steps.x - desc.x);
|
||||
desc.measure();
|
||||
desc.y = align( shield.y + (shield.height - desc.height()) / 2 + 1 );
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public enum Icons {
|
|||
HUNTRESS,
|
||||
CLOSE,
|
||||
DEPTH,
|
||||
DEPTH_LG,
|
||||
SLEEP,
|
||||
ALERT,
|
||||
BACKPACK,
|
||||
|
@ -106,6 +107,9 @@ public enum Icons {
|
|||
case DEPTH:
|
||||
icon.frame( icon.texture.uvRect( 45, 12, 54, 20 ) );
|
||||
break;
|
||||
case DEPTH_LG:
|
||||
icon.frame( icon.texture.uvRect( 34, 46, 50, 62 ) );
|
||||
break;
|
||||
case SLEEP:
|
||||
icon.frame( icon.texture.uvRect( 13, 45, 22, 53 ) );
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user