v1.4.0: Added logic to award badges lost due to a v1.3.2 bug
This commit is contained in:
@@ -23,12 +23,14 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Rankings;
|
import com.shatteredpixel.shatteredpixeldungeon.Rankings;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||||
@@ -212,10 +214,15 @@ public class WelcomeScene extends PixelScene {
|
|||||||
//update rankings, to update any data which may be outdated
|
//update rankings, to update any data which may be outdated
|
||||||
if (previousVersion < LATEST_UPDATE){
|
if (previousVersion < LATEST_UPDATE){
|
||||||
try {
|
try {
|
||||||
|
Badges.loadGlobal(); //fixing a bug with v1.3.2 saves
|
||||||
Rankings.INSTANCE.load();
|
Rankings.INSTANCE.load();
|
||||||
for (Rankings.Record rec : Rankings.INSTANCE.records.toArray(new Rankings.Record[0])){
|
for (Rankings.Record rec : Rankings.INSTANCE.records.toArray(new Rankings.Record[0])){
|
||||||
try {
|
try {
|
||||||
Rankings.INSTANCE.loadGameData(rec);
|
Rankings.INSTANCE.loadGameData(rec);
|
||||||
|
if (Statistics.gameWon) Badges.unlock(Badges.Badge.VICTORY);
|
||||||
|
if (Challenges.activeChallenges() >= 1) Badges.unlock(Badges.Badge.CHAMPION_1);
|
||||||
|
if (Challenges.activeChallenges() >= 3) Badges.unlock(Badges.Badge.CHAMPION_2);
|
||||||
|
if (Challenges.activeChallenges() >= 6) Badges.unlock(Badges.Badge.CHAMPION_3);
|
||||||
Rankings.INSTANCE.saveGameData(rec);
|
Rankings.INSTANCE.saveGameData(rec);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//if we encounter a fatal per-record error, then clear that record
|
//if we encounter a fatal per-record error, then clear that record
|
||||||
@@ -235,6 +242,7 @@ public class WelcomeScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
Collections.sort(Rankings.INSTANCE.records, Rankings.scoreComparator);
|
Collections.sort(Rankings.INSTANCE.records, Rankings.scoreComparator);
|
||||||
Rankings.INSTANCE.save();
|
Rankings.INSTANCE.save();
|
||||||
|
Badges.saveGlobal();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//if we encounter a fatal error, then just clear the rankings
|
//if we encounter a fatal error, then just clear the rankings
|
||||||
FileUtils.deleteFile( Rankings.RANKINGS_FILE );
|
FileUtils.deleteFile( Rankings.RANKINGS_FILE );
|
||||||
|
|||||||
Reference in New Issue
Block a user