v2.4.0: improved badge save/display logic when game is ended

This commit is contained in:
Evan Debenham
2024-02-25 12:58:01 -05:00
parent 9f230b4952
commit e8c824e6eb
4 changed files with 11 additions and 21 deletions

View File

@@ -1000,21 +1000,11 @@ public class Badges {
displayBadge( badge );
}
//necessary in order to display the happy end badge in the surface scene
public static void silentValidateHappyEnd() {
if (!local.contains( Badge.HAPPY_END )){
local.add( Badge.HAPPY_END );
}
if(!local.contains( Badge.HAPPY_END_REMAINS ) && Dungeon.hero.belongings.getItem(RemainsItem.class) != null){
local.add( Badge.HAPPY_END_REMAINS );
}
}
public static void validateHappyEnd() {
displayBadge( Badge.HAPPY_END );
if (local.contains(Badge.HAPPY_END_REMAINS)) {
displayBadge(Badge.HAPPY_END_REMAINS);
if( Dungeon.hero.belongings.getItem(RemainsItem.class) != null ){
displayBadge( Badge.HAPPY_END_REMAINS );
}
}

View File

@@ -22,9 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.levels;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
@@ -154,9 +152,6 @@ public class SewerLevel extends RegularLevel {
return false;
} else {
Statistics.ascended = true;
Badges.silentValidateHappyEnd();
Dungeon.win( Amulet.class );
Dungeon.deleteGame( GamesInProgress.curSlot, true );
Game.switchScene( SurfaceScene.class );
return true;
}

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
@@ -78,6 +79,7 @@ public class AmuletScene extends PixelScene {
protected void onClick() {
Dungeon.win( Amulet.class );
Dungeon.deleteGame( GamesInProgress.curSlot, true );
Badges.saveGlobal();
btnExit.enable(false);
btnStay.enable(false);

View File

@@ -24,8 +24,10 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.Ratmogrify;
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.remains.RemainsItem;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLivingEarth;
@@ -264,8 +266,11 @@ public class SurfaceScene extends PixelScene {
gameOver.setSize( SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT );
gameOver.setPos( frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4 );
add( gameOver );
Badges.validateHappyEnd();
Dungeon.win( Amulet.class );
Dungeon.deleteGame( GamesInProgress.curSlot, true );
Badges.saveGlobal();
fadeIn();
}
@@ -287,8 +292,6 @@ public class SurfaceScene extends PixelScene {
@Override
public void destroy() {
Badges.saveGlobal();
Camera.remove( viewport );
super.destroy();
}