v0.3.4: reworked rankings to store their cause instead of a result string
This commit is contained in:
parent
0e2fbc05fb
commit
ac967fad27
|
@ -126,8 +126,6 @@ public class Dungeon {
|
|||
|
||||
public static int depth;
|
||||
public static int gold;
|
||||
// Reason of death
|
||||
public static String resultDescription;
|
||||
|
||||
public static HashSet<Integer> chapters;
|
||||
|
||||
|
@ -672,14 +670,13 @@ public class Dungeon {
|
|||
Hero.preview( info, bundle.getBundle( HERO ) );
|
||||
}
|
||||
|
||||
public static void fail( String desc ) {
|
||||
resultDescription = desc;
|
||||
public static void fail( Class cause ) {
|
||||
if (hero.belongings.getItem( Ankh.class ) == null) {
|
||||
Rankings.INSTANCE.submit( false );
|
||||
Rankings.INSTANCE.submit( false, cause );
|
||||
}
|
||||
}
|
||||
|
||||
public static void win( String desc ) {
|
||||
public static void win( Class cause ) {
|
||||
|
||||
hero.belongings.identify();
|
||||
|
||||
|
@ -687,8 +684,7 @@ public class Dungeon {
|
|||
Badges.validateChampion();
|
||||
}
|
||||
|
||||
resultDescription = desc;
|
||||
Rankings.INSTANCE.submit( true );
|
||||
Rankings.INSTANCE.submit( true, cause );
|
||||
}
|
||||
|
||||
public static void observe() {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
@ -49,13 +50,13 @@ public enum Rankings {
|
|||
public int totalNumber;
|
||||
public int wonNumber;
|
||||
|
||||
public void submit( boolean win ) {
|
||||
public void submit( boolean win, Class cause ) {
|
||||
|
||||
load();
|
||||
|
||||
Record rec = new Record();
|
||||
|
||||
rec.info = Dungeon.resultDescription;
|
||||
rec.cause = cause;
|
||||
rec.win = win;
|
||||
rec.heroClass = Dungeon.hero.heroClass;
|
||||
rec.armorTier = Dungeon.hero.tier();
|
||||
|
@ -166,16 +167,20 @@ public enum Rankings {
|
|||
}
|
||||
|
||||
public static class Record implements Bundlable {
|
||||
|
||||
|
||||
//pre 0.3.4
|
||||
public String info;
|
||||
private static final String REASON = "reason";
|
||||
|
||||
private static final String CAUSE = "cause";
|
||||
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;
|
||||
|
||||
public Class cause;
|
||||
public boolean win;
|
||||
|
||||
public HeroClass heroClass;
|
||||
|
@ -187,10 +192,28 @@ public enum Rankings {
|
|||
|
||||
public String gameFile;
|
||||
|
||||
public String deathDesc(){
|
||||
if (cause == null && (info == null || info.equals("")))
|
||||
return "Killed by Something";
|
||||
else if (cause == null){
|
||||
return info; //pre 0.3.4 saves
|
||||
} else {
|
||||
String result = Messages.get(cause, "rankings_desc", (Messages.get(cause, "name")));
|
||||
if (result.contains("!!!NO TEXT FOUND!!!")){
|
||||
return "Killed By Something";
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
|
||||
|
||||
//pre-0.3.4
|
||||
info = bundle.getString( REASON );
|
||||
|
||||
cause = bundle.getClass( CAUSE );
|
||||
win = bundle.getBoolean( WIN );
|
||||
score = bundle.getInt( SCORE );
|
||||
|
||||
|
@ -239,7 +262,9 @@ public enum Rankings {
|
|||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
|
||||
bundle.put( REASON, info );
|
||||
if (info != null && !info.equals("")) bundle.put( REASON, info );
|
||||
else bundle.put( CAUSE, cause );
|
||||
|
||||
bundle.put( WIN, win );
|
||||
bundle.put( SCORE, score );
|
||||
|
||||
|
|
|
@ -42,6 +42,6 @@ public class ResultDescriptions {
|
|||
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";
|
||||
}
|
||||
|
|
|
@ -153,15 +153,8 @@ public abstract class Char extends Actor {
|
|||
if (!enemy.isAlive() && visibleFight) {
|
||||
if (enemy == Dungeon.hero) {
|
||||
|
||||
if ( this instanceof Yog ) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.NAMED, name) );
|
||||
} else if (properties().contains(Property.MINIBOSS) || properties().contains(Property.BOSS)) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name) );
|
||||
} else {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name )) );
|
||||
}
|
||||
|
||||
GLog.n( Messages.get(Char.class, "kill", name) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(Char.class, "kill", name) );
|
||||
|
||||
} else if (this == Dungeon.hero) {
|
||||
GLog.i( Messages.get(Char.class, "defeat", enemy.name) );
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ToxicGas extends Blob implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromGas();
|
||||
|
||||
Dungeon.fail( ResultDescriptions.GAS );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class Bleeding extends Buff {
|
|||
|
||||
public void set( int level ) {
|
||||
this.level = level;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
|
@ -80,7 +80,7 @@ public class Bleeding extends Buff {
|
|||
}
|
||||
|
||||
if (target == Dungeon.hero && !target.isAlive()) {
|
||||
Dungeon.fail( ResultDescriptions.BLEEDING );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public class Burning extends Buff implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromFire();
|
||||
|
||||
Dungeon.fail( ResultDescriptions.BURNING );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ public class Hunger extends Buff implements Hero.Doom {
|
|||
|
||||
Badges.validateDeathFromHunger();
|
||||
|
||||
Dungeon.fail( ResultDescriptions.HUNGER );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class Ooze extends Buff {
|
|||
else if (Random.Int(2) == 0)
|
||||
target.damage( 1, this );
|
||||
if (!target.isAlive() && target == Dungeon.hero) {
|
||||
Dungeon.fail( ResultDescriptions.OOZE );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
spend( TICK );
|
||||
|
|
|
@ -58,7 +58,7 @@ public class Poison extends Buff implements Hero.Doom {
|
|||
|
||||
public void set( float duration ) {
|
||||
this.left = duration;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
|
@ -118,7 +118,7 @@ public class Poison extends Buff implements Hero.Doom {
|
|||
public void onDeath() {
|
||||
Badges.validateDeathFromPoison();
|
||||
|
||||
Dungeon.fail( ResultDescriptions.POISON );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( "You died from poison..." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -770,7 +770,7 @@ public class Hero extends Char {
|
|||
GameScene.show( new WndMessage( Messages.get(this, "leave") ) );
|
||||
ready();
|
||||
} else {
|
||||
Dungeon.win( ResultDescriptions.WIN );
|
||||
Dungeon.win( Amulet.class );
|
||||
Dungeon.deleteGame( Dungeon.hero.heroClass, true );
|
||||
Game.switchScene( SurfaceScene.class );
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public class Eye extends Mob {
|
|||
}
|
||||
|
||||
if (!ch.isAlive() && ch == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "deathgaze_kill") );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -107,7 +107,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.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "zap_kill") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class Skeleton extends Mob {
|
|||
}
|
||||
|
||||
if (heroKilled) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "explo_kill") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,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.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "bolt_kill") );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -346,7 +346,7 @@ public class Yog extends Mob {
|
|||
enemy.sprite.flash();
|
||||
|
||||
if (!enemy.isAlive() && enemy == Dungeon.hero) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.UNIQUE, name ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(Char.class, "kill", name) );
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -149,7 +149,7 @@ public class Bomb extends Item {
|
|||
}
|
||||
|
||||
if (ch == Dungeon.hero && !ch.isAlive())
|
||||
Dungeon.fail( Messages.get(this, "ondeath") );
|
||||
Dungeon.fail( getClass() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class Armor extends EquipableItem {
|
|||
if (inscribe) {
|
||||
inscribe( Glyph.random() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
STR--;
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class Armor extends EquipableItem {
|
|||
public boolean checkOwner( Char owner ) {
|
||||
if (!owner.isAlive() && owner instanceof Hero) {
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, name() ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "killed", name()) );
|
||||
|
||||
Badges.validateDeathFromGlyph();
|
||||
|
|
|
@ -104,7 +104,7 @@ public class Viscosity extends Glyph {
|
|||
|
||||
public void prolong( int damage ) {
|
||||
this.damage += damage;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
|
@ -124,7 +124,7 @@ public class Viscosity extends Glyph {
|
|||
if (target == Dungeon.hero && !target.isAlive()) {
|
||||
|
||||
Glyph glyph = new Viscosity();
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name() ) );
|
||||
Dungeon.fail( glyph.getClass() );
|
||||
GLog.n( Messages.get(Glyph.class, "killed", glyph.name()) );
|
||||
|
||||
Badges.validateDeathFromGlyph();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ChaliceOfBlood extends Artifact {
|
|||
protected void onSelect(int index) {
|
||||
if (index == 0)
|
||||
prick(Dungeon.hero);
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class ChaliceOfBlood extends Artifact {
|
|||
hero.damage(damage, this);
|
||||
|
||||
if (!hero.isAlive()) {
|
||||
Dungeon.fail(Utils.format( ResultDescriptions.ITEM, name ));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
} else {
|
||||
upgrade();
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ScrollOfPsionicBlast extends Scroll {
|
|||
curUser.spendAndNext( TIME_TO_READ ); //no animation here, the flash interrupts it anyway.
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name ));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ public class CursedWand {
|
|||
target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3);
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
if (!user.isAlive()) {
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.ITEM, wand.name()));
|
||||
Dungeon.fail( wand.getClass() );
|
||||
GLog.n(Messages.get(CursedWand.class, "ondeath", wand.name()));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -100,7 +100,7 @@ public class WandOfBlastWave extends Wand {
|
|||
}
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get( this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class WandOfLightning extends Wand {
|
|||
}
|
||||
|
||||
if (!curUser.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n(Messages.get(this, "ondeath"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,6 @@ public class WandOfTransfusion extends Wand {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//this wand costs health too
|
||||
private void damageHero(){
|
||||
// 15% of max hp
|
||||
|
@ -181,7 +180,7 @@ public class WandOfTransfusion extends Wand {
|
|||
curUser.damage(damage, this);
|
||||
|
||||
if (!curUser.isAlive()){
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class Chasm {
|
|||
jumpConfirmed = true;
|
||||
hero.resume();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class Chasm {
|
|||
public void onDeath() {
|
||||
Badges.validateDeathFromFalling();
|
||||
|
||||
Dungeon.fail( ResultDescriptions.FALL );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(Chasm.class, "ondeath") );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ChillingTrap extends Trap{
|
|||
Chill.prolong(ch, Chill.class, 5f + Random.Int(Dungeon.depth));
|
||||
ch.damage(Random.NormalIntRange(1 , Dungeon.depth), this);
|
||||
if (!ch.isAlive() && ch == Dungeon.hero){
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.TRAP, name) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DisintegrationTrap extends Trap {
|
|||
if (ch == Dungeon.hero){
|
||||
Hero hero = (Hero)ch;
|
||||
if (!hero.isAlive()){
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.TRAP, name));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
} else {
|
||||
Item item = hero.belongings.randomUnequipped();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FrostTrap extends Trap {
|
|||
ch.damage(Random.NormalIntRange(1 , Dungeon.depth), this);
|
||||
Chill.prolong(ch, Frost.class, 10f + Random.Int(Dungeon.depth));
|
||||
if (!ch.isAlive() && ch == Dungeon.hero){
|
||||
Dungeon.fail( Utils.format(ResultDescriptions.TRAP, name) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class GrimTrap extends Trap {
|
|||
}
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
if (!finalTarget.isAlive()) {
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.TRAP, name));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class LightningTrap extends Trap {
|
|||
Camera.main.shake( 2, 0.3f );
|
||||
|
||||
if (!ch.isAlive()) {
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RockfallTrap extends Trap {
|
|||
Buff.prolong( ch, Paralysis.class, Paralysis.duration(ch)*2);
|
||||
|
||||
if (!ch.isAlive() && ch == Dungeon.hero){
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.TRAP, name));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SpearTrap extends Trap {
|
|||
damage -= Random.IntRange( 0, ch.dr());
|
||||
ch.damage( Math.max(damage, 0) , this);
|
||||
if (!ch.isAlive() && ch == Dungeon.hero){
|
||||
Dungeon.fail(Utils.format(ResultDescriptions.TRAP, name));
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
|
@ -61,7 +62,7 @@ public class AmuletScene extends PixelScene {
|
|||
RedButton btnExit = new RedButton( Messages.get(this, "exit") ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
Dungeon.win( ResultDescriptions.WIN );
|
||||
Dungeon.win( Amulet.class );
|
||||
Dungeon.deleteGame( Dungeon.hero.heroClass, true );
|
||||
Game.switchScene( noText ? TitleScene.class : RankingsScene.class );
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class RankingsScene extends PixelScene {
|
|||
position.text(" ");
|
||||
position.measure();
|
||||
|
||||
desc.text( rec.info );
|
||||
desc.text( rec.deathDesc() );
|
||||
|
||||
//desc.measure();
|
||||
|
||||
|
@ -277,8 +277,8 @@ public class RankingsScene extends PixelScene {
|
|||
depth.x = steps.x + (steps.width - depth.width()) / 2;
|
||||
depth.y = steps.y + (steps.height - depth.height()) / 2 + 1;
|
||||
|
||||
desc.setPos(shield.x + shield.width + GAP, shield.y + (shield.height - desc.height()) / 2 + 1);
|
||||
desc.maxWidth((int)(steps.x - desc.left()));
|
||||
desc.setPos(shield.x + shield.width + GAP, shield.y + (shield.height - desc.height()) / 2 + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -79,7 +79,7 @@ public class WndResurrect extends Window {
|
|||
protected void onClick() {
|
||||
hide();
|
||||
|
||||
Rankings.INSTANCE.submit( false );
|
||||
Rankings.INSTANCE.submit( false, WndResurrect.causeOfDeath.getClass() );
|
||||
Hero.reallyDie( WndResurrect.causeOfDeath );
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user