v1.3.0: prevented using custom seeds that match runs in progress

This commit is contained in:
Evan Debenham
2022-05-23 14:58:29 -04:00
parent 71189917e2
commit 8d8783d172
2 changed files with 12 additions and 0 deletions
@@ -49,6 +49,7 @@ scenes.gamescene.examine=Examine
scenes.heroselectscene.title=Choose Your Hero
scenes.heroselectscene.custom_seed_title=Enter a Custom Seed
scenes.heroselectscene.custom_seed_desc=The same seed and game version always generate the same dungeon! Seeds are nine uppercase letters (e.g. ABC-DEF-GHI), but you can enter anything you want and the game will convert it. _Games with a custom seed cannot earn badges or appear in rankings._
scenes.heroselectscene.custom_seed_duplicate=You already have a regular game in progress with that seed. You must end that game before using that custom seed.
scenes.heroselectscene.custom_seed_set=Set
scenes.heroselectscene.custom_seed_clear=Clear
@@ -211,7 +211,18 @@ public class HeroSelectScene extends PixelScene {
public void onSelect(boolean positive, String text) {
text = DungeonSeed.formatText(text);
long seed = DungeonSeed.convertFromText(text);
if (positive && seed != -1){
for (GamesInProgress.Info info : GamesInProgress.checkAll()){
if (info.customSeed.isEmpty() && info.seed == seed){
SPDSettings.customSeed("");
icon.resetColor();
ShatteredPixelDungeon.scene().addToFront(new WndMessage(Messages.get(HeroSelectScene.class, "custom_seed_duplicate")));
return;
}
}
SPDSettings.customSeed(text);
icon.hardlight(1f, 1.5f, 0.67f);
} else {