diff options
Diffstat (limited to 'DSACore/Commands/FileHandler.cs')
-rw-r--r-- | DSACore/Commands/FileHandler.cs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/DSACore/Commands/FileHandler.cs b/DSACore/Commands/FileHandler.cs index af4698a..bce7c54 100644 --- a/DSACore/Commands/FileHandler.cs +++ b/DSACore/Commands/FileHandler.cs @@ -1,37 +1,29 @@ -using DSACore.DSA_Game; +using System; +using System.Linq; +using System.Net; +using DSACore.DSA_Game; using DSACore.DSA_Game.Characters; +using DSALib; namespace DSACore.Commands { - using System; - using System.Linq; - using System.Net; - - using DSALib; - public class FileHandler { public static string AddChar(ulong id, string url) { - if (url == string.Empty) - { - throw new ArgumentException("Es wurde keine Datei angehängt"); - } - + if (url == string.Empty) throw new ArgumentException("Es wurde keine Datei angehängt"); + + + if (!url.EndsWith(".xml")) throw new ArgumentException("Es wurde kein xml Held mitgeschickt"); - if (!url.EndsWith(".xml")) + using (var client = new WebClient()) { - throw new ArgumentException("Es wurde kein xml Held mitgeschickt"); + client.DownloadFile(url, "helden\\" + url.Split("/").Last()); } - - using (var client = new WebClient()) - { - client.DownloadFile(url, "helden\\" + url.Split("/").Last()); - } - Dsa.Chars.Add(new Character("helden\\" + url.Split("/").Last())); - (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0)) - .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v)); + Dsa.Chars.Add(new Character("helden\\" + url.Split("/").Last())); + (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0)) + .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v)); return $"{url.Split("/").Last()} wurde erfolgreich gespeichert"; } |