diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /DiscoBot/DSA_Game/Save/SaveCommand.cs | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'DiscoBot/DSA_Game/Save/SaveCommand.cs')
-rw-r--r-- | DiscoBot/DSA_Game/Save/SaveCommand.cs | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/DiscoBot/DSA_Game/Save/SaveCommand.cs b/DiscoBot/DSA_Game/Save/SaveCommand.cs deleted file mode 100644 index 1f160ec..0000000 --- a/DiscoBot/DSA_Game/Save/SaveCommand.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DiscoBot.DSA_Game.Save -{ - using System.Diagnostics; - using System.IO; - using System.Net; - using System.Net.Http; - - using DiscoBot.Auxiliary; - - using Discord.Commands; - - public class SaveCommand : ModuleBase - { - [Command("load"), Summary("Load Session")] - [Alias("session")] - public async Task LoadSessionAsync([Remainder, Summary("Session Name")] string name = "") - { - if (name.Equals("?") || name.Equals(string.Empty)) - { - await this.ReplyAsync($"Gespeicherte Sessions:"); - await this.ReplyAsync(this.ListSessions()); - return; - } - - var path = DSA_Game.Save.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); - - await this.ReplyAsync($"{name} wurde geladen"); - } - - [Command("save", RunMode = RunMode.Async), Summary("Save Session")] - public async Task SessionSaveAsync([Remainder, Summary("Session Name")] string name = "") - { - //var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif"); - - if (name.Equals("?") || name.Equals(string.Empty)) - { - await this.ReplyAsync($"Gespeicherte Sessions:"); - await this.ReplyAsync(this.ListSessions()); - return; - } - - var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name; - if (Directory.Exists(path)) - { - var files = Directory.GetFiles(path); - int 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"); - } - - await this.ReplyAsync($"{name} wurde gespeichert"); - //await sendFile; - } - - 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; - } - - return dirs; - } - } -} |