summaryrefslogtreecommitdiff
path: root/DSACore/DSA_Game/Save/SaveCommand.cs
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-05-19 17:40:59 +0200
committernatrixaeria <janng@gmx.de>2019-05-19 17:40:59 +0200
commit1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch)
tree78300ffff230958101b422a4e6026925b287822f /DSACore/DSA_Game/Save/SaveCommand.cs
parentc3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff)
parentc4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff)
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DSACore/DSA_Game/Save/SaveCommand.cs')
-rw-r--r--DSACore/DSA_Game/Save/SaveCommand.cs32
1 files changed, 14 insertions, 18 deletions
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs
index 198d707..f358047 100644
--- a/DSACore/DSA_Game/Save/SaveCommand.cs
+++ b/DSACore/DSA_Game/Save/SaveCommand.cs
@@ -1,23 +1,21 @@
using System;
+using System.IO;
using System.Linq;
-using System.Threading.Tasks;
namespace DSACore.DSA_Game.Save
{
- using System.IO;
-
- public class SaveCommand
+ public class SaveCommand
{
public void LoadSession(string name = "")
{
if (name.Equals("?") || name.Equals(string.Empty))
{
- Console.WriteLine($"Gespeicherte Sessions:");
- Console.WriteLine(this.ListSessions());
+ Console.WriteLine("Gespeicherte Sessions:");
+ Console.WriteLine(ListSessions());
return;
}
- var path = Save.Session.DirectoryPath + @"\" + name;
+ var path = Session.DirectoryPath + @"\" + name;
var files = Directory.GetFiles(path);
var session = files.OrderByDescending(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())).First();
@@ -32,16 +30,16 @@ namespace DSACore.DSA_Game.Save
if (name.Equals("?") || name.Equals(string.Empty))
{
- Console.WriteLine($"Gespeicherte Sessions:");
- Console.WriteLine(this.ListSessions());
+ Console.WriteLine("Gespeicherte Sessions:");
+ Console.WriteLine(ListSessions());
return;
}
- var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name;
+ var path = Session.DirectoryPath + @"\" + name;
if (Directory.Exists(path))
{
var files = Directory.GetFiles(path);
- int current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First()));
+ var current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First()));
Dsa.Session.SessionName = name;
Dsa.Session.Save(path + "\\" + name + $"-{++current}.json");
}
@@ -49,7 +47,7 @@ namespace DSACore.DSA_Game.Save
{
Directory.CreateDirectory(path);
Dsa.Session.SessionName = name;
- Dsa.Session.Save(path + "\\" + name + $"-0.json");
+ Dsa.Session.Save(path + "\\" + name + "-0.json");
}
Console.WriteLine($"{name} wurde gespeichert");
@@ -58,13 +56,11 @@ namespace DSACore.DSA_Game.Save
private string[] ListSessions()
{
- string[] dirs = Directory.GetDirectories(Session.DirectoryPath).OrderByDescending(x => new DirectoryInfo(x).LastAccessTime.Ticks).ToArray();
- for (int i = 0; i < dirs.Length; i++)
- {
- dirs[i] += "; " + new DirectoryInfo(dirs[i]).LastAccessTime;
- }
+ 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