Added some content to the textgame files and added some stuff to the logic files. Also fixed formating in TravelGUI

This commit is contained in:
2019-04-07 16:35:22 -06:00
parent f37aa91fad
commit 26064ebac3
14 changed files with 1906 additions and 385 deletions

View File

@@ -18,20 +18,12 @@ public class FileSaving extends Player implements Serializable {
try {
InputStream in = new FileInputStream(new File("src/saves/playerSave.txt"));
ObjectInputStream inObject = new ObjectInputStream(in);
Player player = (Player) inObject.readObject();
in.close();
inObject.close();
return player;
return getPlayer(in);
}
catch (Exception e) {
try {
InputStream in = new FileInputStream(new File("saves/playerSave.txt"));
ObjectInputStream inObject = new ObjectInputStream(in);
Player player = (Player) inObject.readObject();
in.close();
inObject.close();
return player;
return getPlayer(in);
}
catch(Exception e2){
return null;
@@ -39,6 +31,14 @@ public class FileSaving extends Player implements Serializable {
}
}
private Player getPlayer(InputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream inObject = new ObjectInputStream(in);
Player player = (Player) inObject.readObject();
in.close();
inObject.close();
return player;
}
/**
* Saves the file of type player which contains all the player instances
* @param player The player object being saved