v1.3.0: added backend functionality for multiple floors at one depth
This commit is contained in:
@@ -136,7 +136,7 @@ public class FileUtils {
|
|||||||
|
|
||||||
//replaces a file with junk data, for as many bytes as given
|
//replaces a file with junk data, for as many bytes as given
|
||||||
//This is helpful as some cloud sync systems do not persist deleted, empty, or zeroed files
|
//This is helpful as some cloud sync systems do not persist deleted, empty, or zeroed files
|
||||||
public static void zeroFile( String name, int bytes ){
|
public static void overwriteFile( String name, int bytes ){
|
||||||
byte[] data = new byte[bytes];
|
byte[] data = new byte[bytes];
|
||||||
Arrays.fill(data, (byte)1);
|
Arrays.fill(data, (byte)1);
|
||||||
getFileHandle( name ).writeBytes(data, false);
|
getFileHandle( name ).writeBytes(data, false);
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ public class Dungeon {
|
|||||||
public static QuickSlot quickslot = new QuickSlot();
|
public static QuickSlot quickslot = new QuickSlot();
|
||||||
|
|
||||||
public static int depth;
|
public static int depth;
|
||||||
|
//determines path the hero is on. Current uses:
|
||||||
|
// 0 is the default path
|
||||||
|
// Other numbers are currently unused
|
||||||
|
public static int branch;
|
||||||
|
|
||||||
public static int gold;
|
public static int gold;
|
||||||
public static int energy;
|
public static int energy;
|
||||||
@@ -212,6 +216,8 @@ public class Dungeon {
|
|||||||
QuickSlotButton.reset();
|
QuickSlotButton.reset();
|
||||||
|
|
||||||
depth = 0;
|
depth = 0;
|
||||||
|
branch = 0;
|
||||||
|
|
||||||
gold = 0;
|
gold = 0;
|
||||||
energy = 0;
|
energy = 0;
|
||||||
|
|
||||||
@@ -256,56 +262,61 @@ public class Dungeon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Level level;
|
Level level;
|
||||||
switch (depth) {
|
if (branch == 0) {
|
||||||
case 1:
|
switch (depth) {
|
||||||
case 2:
|
case 1:
|
||||||
case 3:
|
case 2:
|
||||||
case 4:
|
case 3:
|
||||||
level = new SewerLevel();
|
case 4:
|
||||||
break;
|
level = new SewerLevel();
|
||||||
case 5:
|
break;
|
||||||
level = new SewerBossLevel();
|
case 5:
|
||||||
break;
|
level = new SewerBossLevel();
|
||||||
case 6:
|
break;
|
||||||
case 7:
|
case 6:
|
||||||
case 8:
|
case 7:
|
||||||
case 9:
|
case 8:
|
||||||
level = new PrisonLevel();
|
case 9:
|
||||||
break;
|
level = new PrisonLevel();
|
||||||
case 10:
|
break;
|
||||||
level = new PrisonBossLevel();
|
case 10:
|
||||||
break;
|
level = new PrisonBossLevel();
|
||||||
case 11:
|
break;
|
||||||
case 12:
|
case 11:
|
||||||
case 13:
|
case 12:
|
||||||
case 14:
|
case 13:
|
||||||
level = new CavesLevel();
|
case 14:
|
||||||
break;
|
level = new CavesLevel();
|
||||||
case 15:
|
break;
|
||||||
level = new CavesBossLevel();
|
case 15:
|
||||||
break;
|
level = new CavesBossLevel();
|
||||||
case 16:
|
break;
|
||||||
case 17:
|
case 16:
|
||||||
case 18:
|
case 17:
|
||||||
case 19:
|
case 18:
|
||||||
level = new CityLevel();
|
case 19:
|
||||||
break;
|
level = new CityLevel();
|
||||||
case 20:
|
break;
|
||||||
level = new CityBossLevel();
|
case 20:
|
||||||
break;
|
level = new CityBossLevel();
|
||||||
case 21:
|
break;
|
||||||
case 22:
|
case 21:
|
||||||
case 23:
|
case 22:
|
||||||
case 24:
|
case 23:
|
||||||
level = new HallsLevel();
|
case 24:
|
||||||
break;
|
level = new HallsLevel();
|
||||||
case 25:
|
break;
|
||||||
level = new HallsBossLevel();
|
case 25:
|
||||||
break;
|
level = new HallsBossLevel();
|
||||||
case 26:
|
break;
|
||||||
level = new LastLevel();
|
case 26:
|
||||||
break;
|
level = new LastLevel();
|
||||||
default:
|
break;
|
||||||
|
default:
|
||||||
|
level = new DeadEndLevel();
|
||||||
|
Statistics.deepestFloor--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
level = new DeadEndLevel();
|
level = new DeadEndLevel();
|
||||||
Statistics.deepestFloor--;
|
Statistics.deepestFloor--;
|
||||||
}
|
}
|
||||||
@@ -326,13 +337,16 @@ public class Dungeon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long seedCurDepth(){
|
public static long seedCurDepth(){
|
||||||
return seedForDepth(depth);
|
return seedForDepth(depth, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long seedForDepth(int depth){
|
public static long seedForDepth(int depth, int branch){
|
||||||
|
int lookAhead = depth;
|
||||||
|
lookAhead += 30*branch; //Assumes depth is always 1-30, and branch is always 0 or higher
|
||||||
|
|
||||||
Random.pushGenerator( seed );
|
Random.pushGenerator( seed );
|
||||||
|
|
||||||
for (int i = 0; i < depth; i ++) {
|
for (int i = 0; i < lookAhead; i ++) {
|
||||||
Random.Long(); //we don't care about these values, just need to go through them
|
Random.Long(); //we don't care about these values, just need to go through them
|
||||||
}
|
}
|
||||||
long result = Random.Long();
|
long result = Random.Long();
|
||||||
@@ -455,6 +469,7 @@ public class Dungeon {
|
|||||||
private static final String MOBS_TO_CHAMPION = "mobs_to_champion";
|
private static final String MOBS_TO_CHAMPION = "mobs_to_champion";
|
||||||
private static final String HERO = "hero";
|
private static final String HERO = "hero";
|
||||||
private static final String DEPTH = "depth";
|
private static final String DEPTH = "depth";
|
||||||
|
private static final String BRANCH = "branch";
|
||||||
private static final String GOLD = "gold";
|
private static final String GOLD = "gold";
|
||||||
private static final String ENERGY = "energy";
|
private static final String ENERGY = "energy";
|
||||||
private static final String DROPPED = "dropped%d";
|
private static final String DROPPED = "dropped%d";
|
||||||
@@ -477,6 +492,7 @@ public class Dungeon {
|
|||||||
bundle.put( MOBS_TO_CHAMPION, mobsToChampion );
|
bundle.put( MOBS_TO_CHAMPION, mobsToChampion );
|
||||||
bundle.put( HERO, hero );
|
bundle.put( HERO, hero );
|
||||||
bundle.put( DEPTH, depth );
|
bundle.put( DEPTH, depth );
|
||||||
|
bundle.put( BRANCH, branch );
|
||||||
|
|
||||||
bundle.put( GOLD, gold );
|
bundle.put( GOLD, gold );
|
||||||
bundle.put( ENERGY, energy );
|
bundle.put( ENERGY, energy );
|
||||||
@@ -538,7 +554,7 @@ public class Dungeon {
|
|||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.put( LEVEL, level );
|
bundle.put( LEVEL, level );
|
||||||
|
|
||||||
FileUtils.bundleToFile(GamesInProgress.depthFile( save, depth), bundle);
|
FileUtils.bundleToFile(GamesInProgress.depthFile( save, depth, branch ), bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAll() throws IOException {
|
public static void saveAll() throws IOException {
|
||||||
@@ -626,6 +642,7 @@ public class Dungeon {
|
|||||||
hero = (Hero)bundle.get( HERO );
|
hero = (Hero)bundle.get( HERO );
|
||||||
|
|
||||||
depth = bundle.getInt( DEPTH );
|
depth = bundle.getInt( DEPTH );
|
||||||
|
branch = bundle.getInt( BRANCH );
|
||||||
|
|
||||||
gold = bundle.getInt( GOLD );
|
gold = bundle.getInt( GOLD );
|
||||||
energy = bundle.getInt( ENERGY );
|
energy = bundle.getInt( ENERGY );
|
||||||
@@ -664,7 +681,7 @@ public class Dungeon {
|
|||||||
Dungeon.level = null;
|
Dungeon.level = null;
|
||||||
Actor.clear();
|
Actor.clear();
|
||||||
|
|
||||||
Bundle bundle = FileUtils.bundleFromFile( GamesInProgress.depthFile( save, depth)) ;
|
Bundle bundle = FileUtils.bundleFromFile( GamesInProgress.depthFile( save, depth, branch ));
|
||||||
|
|
||||||
Level level = (Level)bundle.get( LEVEL );
|
Level level = (Level)bundle.get( LEVEL );
|
||||||
|
|
||||||
@@ -686,7 +703,7 @@ public class Dungeon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtils.zeroFile(GamesInProgress.gameFile(save), 1);
|
FileUtils.overwriteFile(GamesInProgress.gameFile(save), 1);
|
||||||
|
|
||||||
GamesInProgress.delete( save );
|
GamesInProgress.delete( save );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class GamesInProgress {
|
|||||||
private static final String GAME_FOLDER = "game%d";
|
private static final String GAME_FOLDER = "game%d";
|
||||||
private static final String GAME_FILE = "game.dat";
|
private static final String GAME_FILE = "game.dat";
|
||||||
private static final String DEPTH_FILE = "depth%d.dat";
|
private static final String DEPTH_FILE = "depth%d.dat";
|
||||||
|
private static final String DEPTH_BRANCH_FILE = "depth%d-branch%d.dat";
|
||||||
|
|
||||||
public static boolean gameExists( int slot ){
|
public static boolean gameExists( int slot ){
|
||||||
return FileUtils.dirExists(gameFolder(slot))
|
return FileUtils.dirExists(gameFolder(slot))
|
||||||
@@ -61,8 +62,12 @@ public class GamesInProgress {
|
|||||||
return gameFolder(slot) + "/" + GAME_FILE;
|
return gameFolder(slot) + "/" + GAME_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String depthFile( int slot, int depth ) {
|
public static String depthFile( int slot, int depth, int branch ) {
|
||||||
return gameFolder(slot) + "/" + Messages.format(DEPTH_FILE, depth);
|
if (branch == 0) {
|
||||||
|
return gameFolder(slot) + "/" + Messages.format(DEPTH_FILE, depth);
|
||||||
|
} else {
|
||||||
|
return gameFolder(slot) + "/" + Messages.format(DEPTH_BRANCH_FILE, depth, branch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int firstEmpty(){
|
public static int firstEmpty(){
|
||||||
|
|||||||
Reference in New Issue
Block a user