diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-05-19 17:58:42 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-05-19 17:58:42 +0200 |
commit | 2ab4051c6fe720dc47e99b0c305a0d779ee02d51 (patch) | |
tree | 9510ddbb174a54474934adf7991a5ba2aa39f818 /DSACore/DSA_Game/Save/SaveCommand.cs | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Moved Gamelogic to DSALib
Diffstat (limited to 'DSACore/DSA_Game/Save/SaveCommand.cs')
-rw-r--r-- | DSACore/DSA_Game/Save/SaveCommand.cs | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs deleted file mode 100644 index f358047..0000000 --- a/DSACore/DSA_Game/Save/SaveCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.IO; -using System.Linq; - -namespace DSACore.DSA_Game.Save -{ - public class SaveCommand - { - public void LoadSession(string name = "") - { - if (name.Equals("?") || name.Equals(string.Empty)) - { - Console.WriteLine("Gespeicherte Sessions:"); - Console.WriteLine(ListSessions()); - return; - } - - var path = Session.DirectoryPath + @"\" + name; - - var files = Directory.GetFiles(path); - var session = files.OrderByDescending(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())).First(); - Dsa.Session = Session.Load(session); - - Console.WriteLine($"{name} wurde geladen"); - } - - public void SessionSave(string name = "") - { - //var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif"); - - if (name.Equals("?") || name.Equals(string.Empty)) - { - Console.WriteLine("Gespeicherte Sessions:"); - Console.WriteLine(ListSessions()); - return; - } - - var path = Session.DirectoryPath + @"\" + name; - if (Directory.Exists(path)) - { - var files = Directory.GetFiles(path); - var current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())); - Dsa.Session.SessionName = name; - Dsa.Session.Save(path + "\\" + name + $"-{++current}.json"); - } - else - { - Directory.CreateDirectory(path); - Dsa.Session.SessionName = name; - Dsa.Session.Save(path + "\\" + name + "-0.json"); - } - - Console.WriteLine($"{name} wurde gespeichert"); - //await sendFile; - } - - private string[] ListSessions() - { - var dirs = Directory.GetDirectories(Session.DirectoryPath) - .OrderByDescending(x => new DirectoryInfo(x).LastAccessTime.Ticks).ToArray(); - for (var i = 0; i < dirs.Length; i++) dirs[i] += "; " + new DirectoryInfo(dirs[i]).LastAccessTime; - - return dirs; - } - } -}
\ No newline at end of file |