summaryrefslogtreecommitdiff
path: root/core/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/com')
-rw-r--r--core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java b/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java
new file mode 100644
index 0000000..c2282cf
--- /dev/null
+++ b/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java
@@ -0,0 +1,30 @@
+package com.ilotterytea.maxoning.utils.serialization;
+
+import com.ilotterytea.maxoning.player.MaxonPlayer;
+
+import java.io.*;
+
+public class GameDataSystem {
+ private static final File file = new File(System.getProperty("user.home") + "/MaxoningSavegame.sav");
+
+ public static boolean exists() { return file.exists(); }
+
+ public static void SaveData(MaxonPlayer player) throws IOException {
+ FileOutputStream fo = new FileOutputStream(file);
+ ObjectOutputStream out = new ObjectOutputStream(fo);
+
+ out.writeObject(player);
+ out.close();
+ }
+
+ public static MaxonPlayer LoadData() throws IOException, ClassNotFoundException {
+ FileInputStream fi = new FileInputStream(file);
+ ObjectInputStream oi = new ObjectInputStream(fi);
+
+ MaxonPlayer pl = (MaxonPlayer) oi.readObject();
+
+ oi.close();
+ fi.close();
+ return pl;
+ }
+}