summaryrefslogtreecommitdiff
path: root/dsa/DSALib/Commands
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-06-12 21:47:51 +0200
committerDennis Kobert <d-kobert@web.de>2019-06-12 21:47:51 +0200
commit304437b834e8c87687f68333ae67a13ee1377a73 (patch)
tree51dd246568e8a159627d9cb92e99890adb5cbef8 /dsa/DSALib/Commands
parent2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (diff)
Adjust Codestyle
Diffstat (limited to 'dsa/DSALib/Commands')
-rw-r--r--dsa/DSALib/Commands/CommandHandler.cs25
-rw-r--r--dsa/DSALib/Commands/CommandTypes.cs6
-rw-r--r--dsa/DSALib/Commands/FileHandler.cs13
-rw-r--r--dsa/DSALib/Commands/Gm.cs3
-rw-r--r--dsa/DSALib/Commands/HeldList.cs24
-rw-r--r--dsa/DSALib/Commands/Help.cs18
-rw-r--r--dsa/DSALib/Commands/LebenUndAstral.cs77
-rw-r--r--dsa/DSALib/Commands/List.cs15
-rw-r--r--dsa/DSALib/Commands/MiscCommands.cs6
-rw-r--r--dsa/DSALib/Commands/NpcCommands.cs17
-rw-r--r--dsa/DSALib/Commands/ProbenTest.cs6
11 files changed, 69 insertions, 141 deletions
diff --git a/dsa/DSALib/Commands/CommandHandler.cs b/dsa/DSALib/Commands/CommandHandler.cs
index e63d7b8..ebe2039 100644
--- a/dsa/DSALib/Commands/CommandHandler.cs
+++ b/dsa/DSALib/Commands/CommandHandler.cs
@@ -1,20 +1,15 @@
using System;
using DSALib.Auxiliary;
using DSALib.Auxiliary.Calculator;
-using DSALib.Commands;
using DSALib.DSA_Game;
using DSALib.Models.Network;
-namespace DSALib.Commands
-{
- public class CommandHandler
- {
- public static CommandResponse ExecuteCommand(Command cmd)
- {
+namespace DSALib.Commands {
+ public class CommandHandler {
+ public static CommandResponse ExecuteCommand(Command cmd) {
var res = string.Empty;
var type = ResponseType.Broadcast;
- switch (cmd.CmdIdentifier.ToLower())
- {
+ switch (cmd.CmdIdentifier.ToLower()) {
case "addChar":
res = FileHandler.AddChar(cmd.CharId, cmd.CmdText);
break;
@@ -62,11 +57,9 @@ namespace DSALib.Commands
return new CommandResponse($"Kommando {cmd.CmdIdentifier} nicht gefunden", ResponseType.Error);
}
- private static string Proben(string name, string command, string waffe, int erschwernis = 0)
- {
+ private static string Proben(string name, string command, string waffe, int erschwernis = 0) {
var res = string.Empty;
- switch (command.ToLower())
- {
+ switch (command.ToLower()) {
case "f":
case "fern":
case "fernkampf":
@@ -107,12 +100,10 @@ namespace DSALib.Commands
return res;
}
- private static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
- {
+ private static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0) {
var chr = Dsa.GetCharacter(0);
- switch (command)
- {
+ switch (command) {
case CommandTypes.Talent:
return chr.TestTalent(waffe, erschwernis);
case CommandTypes.Eigenschaft:
diff --git a/dsa/DSALib/Commands/CommandTypes.cs b/dsa/DSALib/Commands/CommandTypes.cs
index 62b8b0f..ac69bfc 100644
--- a/dsa/DSALib/Commands/CommandTypes.cs
+++ b/dsa/DSALib/Commands/CommandTypes.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Commands
-{
- public enum CommandTypes
- {
+namespace DSALib.Commands {
+ public enum CommandTypes {
Talent,
Eigenschaft,
Angriff,
diff --git a/dsa/DSALib/Commands/FileHandler.cs b/dsa/DSALib/Commands/FileHandler.cs
index d117040..bd38fa9 100644
--- a/dsa/DSALib/Commands/FileHandler.cs
+++ b/dsa/DSALib/Commands/FileHandler.cs
@@ -3,22 +3,17 @@ using System.Linq;
using System.Net;
using DSALib.DSA_Game;
using DSALib.DSA_Game.Characters;
-using DSALib;
using DSALib.Models.Dsa;
-namespace DSALib.Commands
-{
- public class FileHandler
- {
- public static string AddChar(ulong id, string url)
- {
+namespace DSALib.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())
- {
+ using (var client = new WebClient()) {
client.DownloadFile(url, "helden\\" + url.Split("/").Last());
}
diff --git a/dsa/DSALib/Commands/Gm.cs b/dsa/DSALib/Commands/Gm.cs
index 74fd673..e4b37a5 100644
--- a/dsa/DSALib/Commands/Gm.cs
+++ b/dsa/DSALib/Commands/Gm.cs
@@ -1,5 +1,4 @@
-namespace DSALib.Commands
-{
+namespace DSALib.Commands {
/*public class Iam
{
diff --git a/dsa/DSALib/Commands/HeldList.cs b/dsa/DSALib/Commands/HeldList.cs
index ef29a14..6943f21 100644
--- a/dsa/DSALib/Commands/HeldList.cs
+++ b/dsa/DSALib/Commands/HeldList.cs
@@ -5,12 +5,9 @@ using DSALib.Auxiliary;
using DSALib.DSA_Game;
using DSALib.DSA_Game.Characters;
-namespace DSALib.Commands
-{
- public class HeldList
- {
- public static string ListAsync(ulong id, params string[] prop_list)
- {
+namespace DSALib.Commands {
+ public class HeldList {
+ public static string ListAsync(ulong id, params string[] prop_list) {
var res = new List<string>();
var character = Dsa.GetCharacter(id) as Character;
@@ -19,8 +16,7 @@ namespace DSALib.Commands
if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") ||
- prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel"))
- {
+ prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel")) {
res.Add(character.Name + ":\n");
//Eigenschaften
res.AddRange(
@@ -64,18 +60,14 @@ namespace DSALib.Commands
" " + s.Probe));
}
else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") ||
- prop_list[0].ToLower().StartsWith("hilf"))
- {
+ prop_list[0].ToLower().StartsWith("hilf")) {
return "```xl\n" + Help.Get_Specific_Help("Held") + "\n```";
}
- else
- {
+ else {
res.Add(character.Name + ":\n");
- foreach (var prop in prop_list)
- {
- switch (prop.ToLower())
- {
+ foreach (var prop in prop_list) {
+ switch (prop.ToLower()) {
case "e":
case "eig":
case "eigenschaft":
diff --git a/dsa/DSALib/Commands/Help.cs b/dsa/DSALib/Commands/Help.cs
index 4506821..b81a9ba 100644
--- a/dsa/DSALib/Commands/Help.cs
+++ b/dsa/DSALib/Commands/Help.cs
@@ -2,26 +2,21 @@
using DSALib.Auxiliary;
using DSALib.DSA_Game.Save;
-namespace DSALib.Commands
-{
- public class Help
- {
+namespace DSALib.Commands {
+ public class Help {
//public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
- public static string Get_Specific_Help(string command)
- {
+ public static string Get_Specific_Help(string command) {
// return command specific help
var com = Properties.CommandInfos
.OrderBy(x => SpellCorrect.Compare(x.Name, command.ToLower())).Last(); // get best fit command
return com.GetDescription();
}
- public static string Get_Generic_Help()
- {
+ public static string Get_Generic_Help() {
var res = "";
- foreach (var com in Properties.CommandInfos)
- {
+ foreach (var com in Properties.CommandInfos) {
var first_column_width = 8;
res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief;
@@ -35,8 +30,7 @@ namespace DSALib.Commands
return res;
}
- public static string ShowHelp(params string[] commandList)
- {
+ public static string ShowHelp(params string[] commandList) {
var command = "";
if (commandList.Length > 0) command = commandList.Aggregate((s, c) => s + " " + c);
diff --git a/dsa/DSALib/Commands/LebenUndAstral.cs b/dsa/DSALib/Commands/LebenUndAstral.cs
index ac11c91..20f05cb 100644
--- a/dsa/DSALib/Commands/LebenUndAstral.cs
+++ b/dsa/DSALib/Commands/LebenUndAstral.cs
@@ -1,14 +1,11 @@
using System;
using DSALib.Auxiliary;
-using DSALib.DSA_Game;
using DSALib.Characters;
+using DSALib.DSA_Game;
-namespace DSALib.Commands
-{
- public class LE
- {
- public static string LEAsync(ulong id, string modifier)
- {
+namespace DSALib.Commands {
+ public class LE {
+ public static string LEAsync(ulong id, string modifier) {
//This is the string that will be printed
var res = "";
@@ -21,10 +18,8 @@ namespace DSALib.Commands
}
}
- public class AE
- {
- public static string AEAsync(ulong id, string modifier)
- {
+ public class AE {
+ public static string AEAsync(ulong id, string modifier) {
//This is the string that will be printed
var res = "";
@@ -36,10 +31,8 @@ namespace DSALib.Commands
}
}
- public static class StatExtension
- {
- public static string get_LE_Text(this ICharacter c, string prop)
- {
+ public static class StatExtension {
+ public static string get_LE_Text(this ICharacter c, string prop) {
var res = "";
var comp = new SpellCorrect();
var character = c;
@@ -47,27 +40,22 @@ namespace DSALib.Commands
res += character.Name + ":\n";
//If there is actual input we process it
- if (prop.Length > 0)
- {
+ if (prop.Length > 0) {
res += "LE: ";
res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis + " -> ";
// Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
+ if (prop.StartsWith("+") || prop.StartsWith("-")) {
//Allow overflowing the max
- if (prop.StartsWith("++"))
- {
+ if (prop.StartsWith("++")) {
character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell +
Convert.ToInt32(prop.Substring(1, prop.Length - 1));
}
- else
- {
+ else {
var temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) -
character.Lebenspunkte_Basis;
//Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
+ if (temp > 0 && prop.StartsWith("+")) {
character.Lebenspunkte_Aktuell =
character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell
? character.Lebenspunkte_Basis
@@ -75,16 +63,14 @@ namespace DSALib.Commands
res += " Maximale Lebenspunkte sind erreicht ";
}
//Simply apply change
- else
- {
+ else {
character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop);
}
}
res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
}
- else
- {
+ else {
// Set to new value regardless of original
character.Lebenspunkte_Aktuell = Convert.ToInt32(prop);
@@ -92,16 +78,14 @@ namespace DSALib.Commands
}
}
//If no value is passed, the curent value is displayed
- else
- {
+ else {
res += "LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
}
return res;
}
- public static string get_AE_Text(this ICharacter c, string prop)
- {
+ public static string get_AE_Text(this ICharacter c, string prop) {
var res = "";
var comp = new SpellCorrect();
var character = c;
@@ -109,27 +93,22 @@ namespace DSALib.Commands
res += character.Name + ":\n";
//If there is actual input we process it
- if (prop.Length > 0)
- {
+ if (prop.Length > 0) {
res += "AE: ";
res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis + " -> ";
// Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
+ if (prop.StartsWith("+") || prop.StartsWith("-")) {
//Allow overflowing the max
- if (prop.StartsWith("++"))
- {
+ if (prop.StartsWith("++")) {
character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell +
Convert.ToInt32(prop.Substring(1, prop.Length - 1));
}
- else
- {
+ else {
var temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) -
character.Astralpunkte_Basis;
//Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
+ if (temp > 0 && prop.StartsWith("+")) {
character.Astralpunkte_Aktuell =
character.Astralpunkte_Basis > character.Astralpunkte_Aktuell
? character.Astralpunkte_Basis
@@ -137,14 +116,12 @@ namespace DSALib.Commands
res += " Maximale Astralpunkte sind erreicht ";
}
//Simply apply change
- else
- {
+ else {
character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop);
}
}
- if (character.Astralpunkte_Aktuell < 0)
- {
+ if (character.Astralpunkte_Aktuell < 0) {
res += "Nicht genügend Astralpunkte! ";
character.Astralpunkte_Aktuell = 0;
}
@@ -152,16 +129,14 @@ namespace DSALib.Commands
res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
}
//Set to new value regardless of original
- else
- {
+ else {
character.Astralpunkte_Aktuell = Convert.ToInt32(prop);
res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
}
}
//If no value is passed, the curent value is displayed
- else
- {
+ else {
res += "AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
}
diff --git a/dsa/DSALib/Commands/List.cs b/dsa/DSALib/Commands/List.cs
index 1213f85..8106c89 100644
--- a/dsa/DSALib/Commands/List.cs
+++ b/dsa/DSALib/Commands/List.cs
@@ -1,20 +1,15 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using DSALib.DSA_Game;
-namespace DSALib.Commands
-{
- public class List
- {
- public static string ListAsync(string prop)
- {
+namespace DSALib.Commands {
+ public class List {
+ public static string ListAsync(string prop) {
var res = new List<string>();
//int persist = 0;
- switch (prop.ToLower())
- {
+ switch (prop.ToLower()) {
case "man":
case "help":
return Help.Get_Specific_Help("List");
diff --git a/dsa/DSALib/Commands/MiscCommands.cs b/dsa/DSALib/Commands/MiscCommands.cs
index 69b2ffe..e5afd3d 100644
--- a/dsa/DSALib/Commands/MiscCommands.cs
+++ b/dsa/DSALib/Commands/MiscCommands.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Commands
-{
- public class MiscCommands
- {
+namespace DSALib.Commands {
+ public class MiscCommands {
/*[Command("r"), Summary("Würfelt ")]
[Alias("R", "Roll", "roll", "Würfle")]
public Task RollAsync([Remainder, Summary("Weapon")] string roll)
diff --git a/dsa/DSALib/Commands/NpcCommands.cs b/dsa/DSALib/Commands/NpcCommands.cs
index 510b78b..5e20d65 100644
--- a/dsa/DSALib/Commands/NpcCommands.cs
+++ b/dsa/DSALib/Commands/NpcCommands.cs
@@ -1,30 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using DSALib.Characters;
using DSALib.DSA_Game;
-using DSALib.DSA_Game.Characters;
-namespace DSALib.Commands
-{
- public class NpcCommands
- {
- public static string CreateNpc(ulong id, IEnumerable<string> props, int modifier)
- {
+namespace DSALib.Commands {
+ public class NpcCommands {
+ public static string CreateNpc(ulong id, IEnumerable<string> props, int modifier) {
if (int.TryParse(props.Last(), out var mean)) return Random(id, props.First(), mean, modifier);
return Copy(id, props.First(), props.Last(), modifier);
}
- private static string Random(ulong id, string npcName, int mean = 9, int stDv = 1)
- {
+ private static string Random(ulong id, string npcName, int mean = 9, int stDv = 1) {
throw new NotImplementedException();
//Dsa.Chars.Add(new Npc(npcName, mean, stDv));
//return $"{npcName} wurde zufällig generiert";
}
- private static string Copy(ulong id, string npcName, string source, int stDv = 1)
- {
+ private static string Copy(ulong id, string npcName, string source, int stDv = 1) {
if (Dsa.Chars.Exists(x => x.Name.Equals(npcName))) throw new Exception("Char gibt es schon");
throw new NotImplementedException();
//var chr = Dsa.GetCharacter(id);
diff --git a/dsa/DSALib/Commands/ProbenTest.cs b/dsa/DSALib/Commands/ProbenTest.cs
index 7c88480..6896e15 100644
--- a/dsa/DSALib/Commands/ProbenTest.cs
+++ b/dsa/DSALib/Commands/ProbenTest.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Commands
-{
- public class ProbenTest
- {
+namespace DSALib.Commands {
+ public class ProbenTest {
/*[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
[Alias("T", "Talent", "talent", "versuche")]
public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)