summaryrefslogtreecommitdiff
path: root/DSALib/Commands/FileHandler.cs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-19 17:58:42 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-19 17:58:42 +0200
commit2ab4051c6fe720dc47e99b0c305a0d779ee02d51 (patch)
tree9510ddbb174a54474934adf7991a5ba2aa39f818 /DSALib/Commands/FileHandler.cs
parentc4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff)
Moved Gamelogic to DSALib
Diffstat (limited to 'DSALib/Commands/FileHandler.cs')
-rw-r--r--DSALib/Commands/FileHandler.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/DSALib/Commands/FileHandler.cs b/DSALib/Commands/FileHandler.cs
new file mode 100644
index 0000000..bce7c54
--- /dev/null
+++ b/DSALib/Commands/FileHandler.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Linq;
+using System.Net;
+using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
+using DSALib;
+
+namespace DSACore.Commands
+{
+ 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.EndsWith(".xml")) throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
+
+ 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));
+
+ return $"{url.Split("/").Last()} wurde erfolgreich gespeichert";
+ }
+ }
+} \ No newline at end of file