summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-19 16:03:38 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-19 16:03:38 +0200
commitf89f308c525e9deebc6d2cf6416e27dfe1a299dc (patch)
tree7097ef871ead0245efda696198443eab8e443d3a /DSACore
parentf3983341be939235c1a6cd522b3bb5cc318a6d1a (diff)
Cleanup DiscoBot Project
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Audio/Sound.cs8
-rw-r--r--DSACore/Auxiliary/Calculator/Argument.cs17
-rw-r--r--DSACore/Auxiliary/Calculator/ISolvable.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/Operator.cs16
-rw-r--r--DSACore/Auxiliary/Calculator/Ops.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/StringSolver.cs90
-rw-r--r--DSACore/Auxiliary/CommandInfo.cs12
-rw-r--r--DSACore/Auxiliary/Dice.cs23
-rw-r--r--DSACore/Auxiliary/Extensions.cs18
-rw-r--r--DSACore/Auxiliary/RandomMisc.cs32
-rw-r--r--DSACore/Auxiliary/SpellCorrect.cs103
-rw-r--r--DSACore/Auxiliary/TalentEnumerableExtension.cs39
-rw-r--r--DSACore/Auxiliary/WeaponImporter.cs53
-rw-r--r--DSACore/Commands/CommandHandler.cs21
-rw-r--r--DSACore/Commands/CommandTypes.cs2
-rw-r--r--DSACore/Commands/FileHandler.cs25
-rw-r--r--DSACore/Commands/Gm.cs2
-rw-r--r--DSACore/Commands/HeldList.cs72
-rw-r--r--DSACore/Commands/Help.cs29
-rw-r--r--DSACore/Commands/LebenUndAstral.cs52
-rw-r--r--DSACore/Commands/List.cs6
-rw-r--r--DSACore/Commands/MiscCommands.cs2
-rw-r--r--DSACore/Commands/NpcCommands.cs14
-rw-r--r--DSACore/Commands/ProbenTest.cs4
-rw-r--r--DSACore/Controllers/CommandsController.cs5
-rw-r--r--DSACore/Controllers/LobbyController.cs8
-rw-r--r--DSACore/Controllers/TokensController.cs10
-rw-r--r--DSACore/DSA_Game/Characters/Character.cs176
-rw-r--r--DSACore/DSA_Game/Characters/NPC.cs80
-rw-r--r--DSACore/DSA_Game/Characters/SaveChar.cs3
-rw-r--r--DSACore/DSA_Game/Dsa.cs18
-rw-r--r--DSACore/DSA_Game/Save/Properties.cs17
-rw-r--r--DSACore/DSA_Game/Save/SaveCommand.cs22
-rw-r--r--DSACore/DSA_Game/Save/Session.cs21
-rw-r--r--DSACore/FireBase/Database.cs39
-rw-r--r--DSACore/Hubs/Login.cs71
-rw-r--r--DSACore/Models/Database/DSA/Advantage.cs2
-rw-r--r--DSACore/Models/Database/DSA/CharSpell.cs2
-rw-r--r--DSACore/Models/Database/DSA/DatabaseChar.cs5
-rw-r--r--DSACore/Models/Database/DSA/Field.cs4
-rw-r--r--DSACore/Models/Database/DSA/GeneralSpell.cs4
-rw-r--r--DSACore/Models/Database/DSA/GroupChar.cs2
-rw-r--r--DSACore/Models/Database/DSA/Inventory.cs2
-rw-r--r--DSACore/Models/Database/DSA/Talent.cs4
-rw-r--r--DSACore/Models/Database/DSA/Weapon.cs8
-rw-r--r--DSACore/Models/Database/DSA/WeaponTalent.cs2
-rw-r--r--DSACore/Models/Database/Groups/DSAGroup.cs2
-rw-r--r--DSACore/Models/Database/Groups/Group.cs5
-rw-r--r--DSACore/Models/Network/Command.cs4
-rw-r--r--DSACore/Models/Network/CommandResponse.cs6
-rw-r--r--DSACore/Models/Network/Group.cs10
-rw-r--r--DSACore/Models/Network/User.cs2
-rw-r--r--DSACore/Program.cs9
-rw-r--r--DSACore/Startup.cs10
54 files changed, 501 insertions, 696 deletions
diff --git a/DSACore/Audio/Sound.cs b/DSACore/Audio/Sound.cs
index d259850..aee3060 100644
--- a/DSACore/Audio/Sound.cs
+++ b/DSACore/Audio/Sound.cs
@@ -4,9 +4,9 @@
{
public Sound(string name, string url, int volume)
{
- this.Name = name;
- this.Url = url;
- this.Volume = volume;
+ Name = name;
+ Url = url;
+ Volume = volume;
}
public string Name { get; }
@@ -15,4 +15,4 @@
public int Volume { get; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Calculator/Argument.cs b/DSACore/Auxiliary/Calculator/Argument.cs
index 52f33a9..14982aa 100644
--- a/DSACore/Auxiliary/Calculator/Argument.cs
+++ b/DSACore/Auxiliary/Calculator/Argument.cs
@@ -1,7 +1,7 @@
namespace DSACore.Auxiliary.Calculator
{
using System;
-
+
/// <summary>
/// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
/// </summary>
@@ -12,27 +12,24 @@
public Argument(string value)
{
// check whether the value given is an empty string
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("Argument kann nicht mit einem leeren string instanziert werden. ", nameof(value));
- }
+ if (string.IsNullOrEmpty(value))
+ throw new ArgumentException("Argument kann nicht mit einem leeren string instanziert werden. ",
+ nameof(value));
- if (!int.TryParse(value, out int result))
- {
+ if (!int.TryParse(value, out var result))
throw new ArgumentException($"Kann {value} nicht in Integer konvertieren");
- }
this.value = result;
}
public int Solve()
{
- return this.value;
+ return value;
}
public override string ToString()
{
- return this.value.ToString();
+ return value.ToString();
}
}
} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Calculator/ISolvable.cs b/DSACore/Auxiliary/Calculator/ISolvable.cs
index 1f571d0..2acbd11 100644
--- a/DSACore/Auxiliary/Calculator/ISolvable.cs
+++ b/DSACore/Auxiliary/Calculator/ISolvable.cs
@@ -7,4 +7,4 @@
{
int Solve();
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Calculator/Operator.cs b/DSACore/Auxiliary/Calculator/Operator.cs
index 440e21e..ed46186 100644
--- a/DSACore/Auxiliary/Calculator/Operator.cs
+++ b/DSACore/Auxiliary/Calculator/Operator.cs
@@ -14,7 +14,7 @@ namespace DSACore.Auxiliary.Calculator
{
this.arg1 = arg1;
this.arg2 = arg2;
- this.OperatorType = operatorType;
+ OperatorType = operatorType;
}
public Ops OperatorType { get; set; }
@@ -22,19 +22,19 @@ namespace DSACore.Auxiliary.Calculator
public int Solve()
{
int result;
- switch (this.OperatorType)
+ switch (OperatorType)
{
case Ops.Dice:
- result = Dice.Roll(this.arg1.Solve(), this.arg2.Solve());
+ result = Dice.Roll(arg1.Solve(), arg2.Solve());
break;
case Ops.Multiply:
- result = this.arg1.Solve() * this.arg2.Solve();
+ result = arg1.Solve() * arg2.Solve();
break;
case Ops.Add:
- result = this.arg1.Solve() + this.arg2.Solve();
+ result = arg1.Solve() + arg2.Solve();
break;
case Ops.Subtract:
- result = this.arg1.Solve() - this.arg2.Solve();
+ result = arg1.Solve() - arg2.Solve();
break;
default:
throw new ArgumentOutOfRangeException();
@@ -45,7 +45,7 @@ namespace DSACore.Auxiliary.Calculator
public override string ToString()
{
- return $"({this.arg1} {this.OperatorType} {this.arg2})";
+ return $"({arg1} {OperatorType} {arg2})";
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Calculator/Ops.cs b/DSACore/Auxiliary/Calculator/Ops.cs
index 702558d..c804257 100644
--- a/DSACore/Auxiliary/Calculator/Ops.cs
+++ b/DSACore/Auxiliary/Calculator/Ops.cs
@@ -10,4 +10,4 @@
Subtract,
Add
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Calculator/StringSolver.cs b/DSACore/Auxiliary/Calculator/StringSolver.cs
index 2eff5b4..212f812 100644
--- a/DSACore/Auxiliary/Calculator/StringSolver.cs
+++ b/DSACore/Auxiliary/Calculator/StringSolver.cs
@@ -24,30 +24,31 @@ namespace DSACore.Auxiliary.Calculator
public override string ToString()
{
- return "(0+" + this.input.Replace(" ", string.Empty).ToLower() + ")";
+ return "(0+" + input.Replace(" ", string.Empty).ToLower() + ")";
}
public int Solve()
{
- string workInput = "0+" + this.input.Replace(" ", string.Empty).ToLower();
+ var workInput = "0+" + input.Replace(" ", string.Empty).ToLower();
workInput = ExpandParentheses(workInput);
-
+
// Create a List of the different parts of the calculation, e.g.:{"0", "+", "(5+6)", "d", "3"}.
- this.AtomizeOperations(workInput);
+ AtomizeOperations(workInput);
// traverse the List in order of Operation to Create the binary operation tree .
- this.NestOperations();
+ NestOperations();
// the List now contains only the top operation node, witch can be solved recursively,
- return ((ISolvable)this.arguments.First()).Solve();
+ return ((ISolvable) arguments.First()).Solve();
}
- private static string GetInner(ref string input) // extract the inner bracket an remove the section from the input string
+ private static string
+ GetInner(ref string input) // extract the inner bracket an remove the section from the input string
{
- int depth = 0;
+ var depth = 0;
for (var index = 1; index < input.Length; index++)
{
- char c = input[index];
+ var c = input[index];
switch (c)
{
case '(':
@@ -92,21 +93,13 @@ namespace DSACore.Auxiliary.Calculator
private static string ExpandParentheses(string input) // insert * between Parentheses and digits
{
- for (int i = 0; i < input.Length - 1; i++)
- {
+ for (var i = 0; i < input.Length - 1; i++)
if (input[i + 1] == '(' && char.IsNumber(input[i]))
- {
input = input.Insert(i + 1, "*");
- }
- }
- for (int i = 1; i < input.Length; i++)
- {
+ for (var i = 1; i < input.Length; i++)
if (input[i - 1] == ')' && char.IsNumber(input[i]))
- {
input = input.Insert(i, "*");
- }
- }
return input;
}
@@ -115,16 +108,14 @@ namespace DSACore.Auxiliary.Calculator
{
for (var index = 0; index < workInput.Length; index++)
{
- char c = workInput[index];
+ var c = workInput[index];
if (char.IsNumber(c))
{
// if char number, check if at end of string, else continue looping
if (index == workInput.Length - 1)
- {
// if at end of string; add remaining number to arguments
- this.arguments.Add(new Argument(workInput.Substring(0, index + 1)));
- }
+ arguments.Add(new Argument(workInput.Substring(0, index + 1)));
continue;
}
@@ -134,16 +125,13 @@ namespace DSACore.Auxiliary.Calculator
case ')':
throw new ArgumentException($"Unmögliche Anordnung von Klammern");
case '(':
- this.arguments.Add(new StringSolver(GetInner(ref workInput)));
+ arguments.Add(new StringSolver(GetInner(ref workInput)));
index = -1;
break;
default:
- if (index > 0)
- {
- this.arguments.Add(new Argument(workInput.Substring(0, index)));
- }
+ if (index > 0) arguments.Add(new Argument(workInput.Substring(0, index)));
- this.arguments.Add(GetOps(c));
+ arguments.Add(GetOps(c));
workInput = workInput.Remove(0, index + 1);
index = -1;
break;
@@ -154,58 +142,44 @@ namespace DSACore.Auxiliary.Calculator
private void NestOperations()
{
foreach (Ops currentOp in Enum.GetValues(typeof(Ops)))
- {
// cycle through operators in operational order
- for (var index = 0; index < this.arguments.Count; index++)
+ for (var index = 0; index < arguments.Count; index++)
{
- var arg = this.arguments[index];
+ var arg = arguments[index];
- if (arg.GetType() != typeof(Ops))
- {
- continue;
- }
+ if (arg.GetType() != typeof(Ops)) continue;
// arg is of type Ops
- var op = (Ops)arg;
+ var op = (Ops) arg;
- if (op != currentOp)
- {
- continue;
- }
+ if (op != currentOp) continue;
// arg describes the current operation
- this.HandleSpecialFormatting(ref index, op); // Deal with special needs...
+ HandleSpecialFormatting(ref index, op); // Deal with special needs...
// replace the previous current and next Element in the List with one Operation object
- var temp = new Operator((ISolvable)this.arguments[index - 1], (ISolvable)this.arguments[index + 1], op);
- this.arguments[index - 1] = temp;
- this.arguments.RemoveRange(index, 2);
+ var temp = new Operator((ISolvable) arguments[index - 1], (ISolvable) arguments[index + 1], op);
+ arguments[index - 1] = temp;
+ arguments.RemoveRange(index, 2);
index--;
}
- }
}
private void HandleSpecialFormatting(ref int index, Ops op)
{
- var arg1 = this.arguments[index - 1];
+ var arg1 = arguments[index - 1];
if (arg1.GetType() == typeof(Ops))
{
- if (op == Ops.Dice)
- {
- this.arguments.Insert(index++, new Argument("1")); // w6 -> 1w6
- }
+ if (op == Ops.Dice) arguments.Insert(index++, new Argument("1")); // w6 -> 1w6
- if (op == Ops.Subtract)
- {
- this.arguments.Insert(index++, new Argument("0")); // +-3 -> +0-3
- }
+ if (op == Ops.Subtract) arguments.Insert(index++, new Argument("0")); // +-3 -> +0-3
}
- var arg2 = this.arguments[index + 1]; // 3+-5 -> 3+(0-5)
+ var arg2 = arguments[index + 1]; // 3+-5 -> 3+(0-5)
if (arg2.GetType() == typeof(Ops))
{
- this.arguments[index + 1] = new Operator(new Argument("0"), (ISolvable)this.arguments[index + 2], (Ops)arg2);
- this.arguments.RemoveAt(index + 2);
+ arguments[index + 1] = new Operator(new Argument("0"), (ISolvable) arguments[index + 2], (Ops) arg2);
+ arguments.RemoveAt(index + 2);
}
}
}
diff --git a/DSACore/Auxiliary/CommandInfo.cs b/DSACore/Auxiliary/CommandInfo.cs
index a83e30a..9afe6c0 100644
--- a/DSACore/Auxiliary/CommandInfo.cs
+++ b/DSACore/Auxiliary/CommandInfo.cs
@@ -10,10 +10,10 @@ namespace DSACore.Auxiliary
{
public CommandInfo(string name, string brief, string[] description, string scope)
{
- this.Name = name;
- this.Scope = scope;
- this.Brief = brief;
- this.Description = description;
+ Name = name;
+ Scope = scope;
+ Brief = brief;
+ Description = description;
}
public string Name { get; }
@@ -26,7 +26,7 @@ namespace DSACore.Auxiliary
public string GetDescription()
{
- return this.Description.Aggregate((s, c) => s + c);
+ return Description.Aggregate((s, c) => s + c);
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Dice.cs b/DSACore/Auxiliary/Dice.cs
index 2df8aa7..3dd6562 100644
--- a/DSACore/Auxiliary/Dice.cs
+++ b/DSACore/Auxiliary/Dice.cs
@@ -5,7 +5,7 @@ namespace DSACore.Auxiliary
{
public static class Dice // roll it!
{
- private static readonly System.Random Rnd = new System.Random();
+ private static readonly Random Rnd = new Random();
public static int Roll(int d = 20)
{
@@ -14,29 +14,24 @@ namespace DSACore.Auxiliary
public static int Roll(string input)
{
- var strings = input.ToLower().Split(new[] { 'w', 'd' }, 2, StringSplitOptions.RemoveEmptyEntries).ToList();
- int count = Convert.ToInt32(strings[0]);
- int d = Convert.ToInt32(strings[0]);
+ var strings = input.ToLower().Split(new[] {'w', 'd'}, 2, StringSplitOptions.RemoveEmptyEntries).ToList();
+ var count = Convert.ToInt32(strings[0]);
+ var d = Convert.ToInt32(strings[0]);
if (strings.Count != 2)
- {
throw new ArgumentException($"{input}: erfüllt nicht die Formatvogaben( Anzahl d Augenzahl)");
- }
return Roll(count, d);
}
public static int Roll(int count, int d)
{
- if (d <= 0)
- {
- return 0;
- }
+ if (d <= 0) return 0;
- int sum = 0;
- for (int i = 0; i < Math.Abs(count); i++)
+ var sum = 0;
+ for (var i = 0; i < Math.Abs(count); i++)
{
- var roll = Dice.Roll(d);
+ var roll = Roll(d);
sum += roll;
}
@@ -45,4 +40,4 @@ namespace DSACore.Auxiliary
return sum;
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/Extensions.cs b/DSACore/Auxiliary/Extensions.cs
index 8ef6298..f8e9d8e 100644
--- a/DSACore/Auxiliary/Extensions.cs
+++ b/DSACore/Auxiliary/Extensions.cs
@@ -6,14 +6,10 @@
//If the original string is already longer, it is returner unmodified.
public static string AddSpaces(this string str, int length)
{
- string temp = str;
- for(int i = str.Length; i < length; i++)
- {
- temp += " ";
- }
+ var temp = str;
+ for (var i = str.Length; i < length; i++) temp += " ";
return temp;
}
-
//This mehod extends string.
@@ -21,13 +17,9 @@
//If the original string is already longer, it is returner unmodified.
public static string AddSpacesAtHead(this string str, int length)
{
- string temp = "";
- for (int i = str.Length; i < length; i++)
- {
- temp += " ";
- }
+ var temp = "";
+ for (var i = str.Length; i < length; i++) temp += " ";
return temp + str;
}
}
-
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/RandomMisc.cs b/DSACore/Auxiliary/RandomMisc.cs
index 1295f02..72c2234 100644
--- a/DSACore/Auxiliary/RandomMisc.cs
+++ b/DSACore/Auxiliary/RandomMisc.cs
@@ -13,40 +13,40 @@ namespace DSACore.Auxiliary
{
var output = new StringBuilder();
var strings = input.Split('w', 'd').ToList();
- int count = Convert.ToInt32(strings[0]);
+ var count = Convert.ToInt32(strings[0]);
strings = strings[1].Split(' ').ToList();
- int d = Convert.ToInt32(strings[0]);
+ var d = Convert.ToInt32(strings[0]);
if (strings.Count > 0)
{
}
- int sum = 0;
- for (int i = 0; i < count; i++)
+ var sum = 0;
+ for (var i = 0; i < count; i++)
{
var roll = Dice.Roll(d);
sum += roll;
output.Append("[" + roll + "] ");
}
-
- if (strings.Count > 1)
- {
- sum += Convert.ToInt32(strings[1]);
- output.Append("sum: " + sum);
- }
+
+ if (strings.Count > 1)
+ {
+ sum += Convert.ToInt32(strings[1]);
+ output.Append("sum: " + sum);
+ }
return output.ToString();
}
public static double Random(double stdDev = 1, double mean = 0)
{
- double u1 = Rand.NextDouble(); // uniform(0,1) random doubles
- double u2 = Rand.NextDouble();
- double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
- Math.Sin(2.0 * Math.PI * u2); // random normal(0,1)
- double randNormal =
+ var u1 = Rand.NextDouble(); // uniform(0,1) random doubles
+ var u2 = Rand.NextDouble();
+ var randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
+ Math.Sin(2.0 * Math.PI * u2); // random normal(0,1)
+ var randNormal =
mean + stdDev * randStdNormal; // random normal(mean,stdDev^2)
return randNormal;
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/SpellCorrect.cs b/DSACore/Auxiliary/SpellCorrect.cs
index c9603f6..3ef7bb6 100644
--- a/DSACore/Auxiliary/SpellCorrect.cs
+++ b/DSACore/Auxiliary/SpellCorrect.cs
@@ -15,44 +15,25 @@
public static int CompareEasy(string x, string y)
{
- if (string.IsNullOrEmpty(x))
- {
- throw new ArgumentException("message", nameof(x));
- }
+ if (string.IsNullOrEmpty(x)) throw new ArgumentException("message", nameof(x));
- if (string.IsNullOrEmpty(y))
- {
- throw new ArgumentException("message", nameof(y));
- }
+ if (string.IsNullOrEmpty(y)) throw new ArgumentException("message", nameof(y));
- if (x.Equals(y))
- {
- return 0;
- }
+ if (x.Equals(y)) return 0;
x = x.ToLower();
y = y.ToLower();
- if (x.Equals(y))
- {
- return 1;
- }
+ if (x.Equals(y)) return 1;
var subs = y.Split(' ', '/');
- int score = subs.Count();
- foreach (string s in subs)
- {
+ var score = subs.Count();
+ foreach (var s in subs)
if (s.Equals(x))
- {
score--;
- }
- }
- if (score < subs.Count())
- {
- return score + 1;
- }
+ if (score < subs.Count()) return score + 1;
- return 100000 - (int)(CompareExact(x, y) * 1000.0);
+ return 100000 - (int) (CompareExact(x, y) * 1000.0);
/*if (y.Contains(x))
return 6;*/
}
@@ -70,7 +51,6 @@
public static double CompareExact(string s, string q)
{
-
s = s.ToLower();
q = q.ToLower();
@@ -81,67 +61,46 @@
double decay;
- double[,] matrix = new double[s.Length + 1, q.Length + 1];
- double max = 0.0;
+ var matrix = new double[s.Length + 1, q.Length + 1];
+ var max = 0.0;
matrix[0, 0] = 0.0;
-
+
for (i = 1; i < s.Length; i++)
- {
- // matrix[i, 0] = 0.0;
+ // matrix[i, 0] = 0.0;
matrix[i, 0] = i * Gap;
- }
- for (i = 1; i < q.Length; i++)
- {
- matrix[0, i] = 0.0;
- }
+ for (i = 1; i < q.Length; i++) matrix[0, i] = 0.0;
for (i = 1; i <= s.Length; i++)
+ for (j = 1; j <= q.Length; j++)
{
- for (j = 1; j <= q.Length; j++)
- {
- decay = j / (double)(s.Length * 1000);
- double add = s[i - 1] == q[j - 1] ? (Match - decay) : Mismatch;
- double score = matrix[i - 1, j - 1] + add;
+ decay = j / (double) (s.Length * 1000);
+ var add = s[i - 1] == q[j - 1] ? Match - decay : Mismatch;
+ var score = matrix[i - 1, j - 1] + add;
- if (score < (matrix[i - 1, j] + Gap))
- {
- score = matrix[i - 1, j] + Gap;
- }
+ if (score < matrix[i - 1, j] + Gap) score = matrix[i - 1, j] + Gap;
- if (score < (matrix[i, j - 1] + Gap))
- {
- score = matrix[i, j - 1] + Gap;
- }
+ if (score < matrix[i, j - 1] + Gap) score = matrix[i, j - 1] + Gap;
- if (i > 1 && j > 1)
+ if (i > 1 && j > 1)
+ if (s[i - 1] == q[j - 2] && s[i - 2] == q[j - 1])
{
- if (s[i - 1] == q[j - 2] && s[i - 2] == q[j - 1])
- {
- add = (3 / 2.0) * Match - decay;
- if (score < matrix[i - 2, j - 2] + add)
- {
- score = matrix[i - 2, j - 2] + add;
- }
- }
+ add = 3 / 2.0 * Match - decay;
+ if (score < matrix[i - 2, j - 2] + add) score = matrix[i - 2, j - 2] + add;
}
-
- // if (score < 0)
- // {
- // score = 0;
- // }
- if (max < score && i == s.Length)
- {
- max = score;
- }
+ // if (score < 0)
+ // {
+ // score = 0;
+ // }
+
+ if (max < score && i == s.Length) max = score;
- matrix[i, j] = score;
- }
+ matrix[i, j] = score;
}
return max;
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/TalentEnumerableExtension.cs b/DSACore/Auxiliary/TalentEnumerableExtension.cs
index a4ace2f..159480d 100644
--- a/DSACore/Auxiliary/TalentEnumerableExtension.cs
+++ b/DSACore/Auxiliary/TalentEnumerableExtension.cs
@@ -15,12 +15,10 @@ namespace DSACore.Auxiliary
var tTalent = List.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, tTalent.Name) > SpellCorrect.ErrorThreshold)
- {
return $"{c.Name} kann nicht {talent}...";
- }
var props = tTalent.GetEigenschaften(); // get the required properties
- int tap = tTalent.Value; // get taw
+ var tap = tTalent.Value; // get taw
var werte = props.Select(p => c.Eigenschaften[c.PropTable[p]]).ToList();
output.AppendFormat(
@@ -34,51 +32,42 @@ namespace DSACore.Auxiliary
output.Append(" ");
tap -= erschwernis;
- int gesamtErschwernis = tap;
+ var gesamtErschwernis = tap;
if (gesamtErschwernis < 0)
{
tap = 0;
- for (int i = 0; i <= 2; i++)
+ for (var i = 0; i <= 2; i++)
{
// foreach property, dice and tap
- int temp = Dice.Roll();
- int eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
+ var temp = Dice.Roll();
+ var eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
- if (eigenschaft + gesamtErschwernis < temp)
- {
- tap -= temp - (eigenschaft + gesamtErschwernis);
- }
+ if (eigenschaft + gesamtErschwernis < temp) tap -= temp - (eigenschaft + gesamtErschwernis);
output.Append($"[{temp}]"); // add to string
}
- if (tap >= 0)
- {
- tap = 1;
- }
+ if (tap >= 0) tap = 1;
}
else
{
- for (int i = 0; i <= 2; i++)
+ for (var i = 0; i <= 2; i++)
{
// foreach property, dice and tap
- int temp = Dice.Roll();
- int eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
+ var temp = Dice.Roll();
+ var eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
- if (eigenschaft < temp)
- {
- tap -= temp - eigenschaft;
- }
+ if (eigenschaft < temp) tap -= temp - eigenschaft;
output.Append($"[{temp}]"); // add to string
}
}
- tap = (tap == 0) ? 1 : tap;
-
+ tap = tap == 0 ? 1 : tap;
+
output.AppendFormat(" tap: {0,2}", tap);
return output.ToString(); // return output
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Auxiliary/WeaponImporter.cs b/DSACore/Auxiliary/WeaponImporter.cs
index 635d477..ab51efb 100644
--- a/DSACore/Auxiliary/WeaponImporter.cs
+++ b/DSACore/Auxiliary/WeaponImporter.cs
@@ -20,13 +20,13 @@ namespace DSACore.Auxiliary
{
var client = new HttpClient();
-
- for (int i = 1; i <= 25; i++)
+ for (var i = 1; i <= 25; i++)
{
- var responseString = await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/categoryChanged/" + i);
+ var responseString =
+ await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/categoryChanged/" + i);
- Regex talentRegex = new Regex(@"(?<=<option value="")([0-9]*)("">)(.*?)(?=<)");
+ var talentRegex = new Regex(@"(?<=<option value="")([0-9]*)("">)(.*?)(?=<)");
//Regex idsRegex = new Regex(@"(?<=<option value=\"")([0-9]*)");
@@ -37,25 +37,25 @@ namespace DSACore.Auxiliary
var ids = new List<int>();
foreach (var matchGroup in talentMatch.ToList())
- {
if (matchGroup.Success)
{
lines.Add(matchGroup.Groups[3].Value);
ids.Add(int.Parse(matchGroup.Groups[1].Value));
}
- }
-
- for (int j = 0; j < lines.Count; j++)
+ for (var j = 0; j < lines.Count; j++)
{
var talent = lines[j];
- var values = await client.GetStringAsync($"http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" + ids[j] + "/0/0/0/0/0/10/0/0/0");
+ var values = await client.GetStringAsync($"http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" +
+ ids[j] + "/0/0/0/0/0/10/0/0/0");
values = Regex.Unescape(values.Replace(@"\t", ""));
// ... Use named group in regular expression.
- Regex expression = new Regex(@"(((?<=(<td>))|(?<=(<td style=\""padding:2px\"">))).*?(?=<\/td>))|((?<=<span style=\""font-weight:bold;text-decoration:underline;\"">).*?(?=<\/span>))");
+ var expression =
+ new Regex(
+ @"(((?<=(<td>))|(?<=(<td style=\""padding:2px\"">))).*?(?=<\/td>))|((?<=<span style=\""font-weight:bold;text-decoration:underline;\"">).*?(?=<\/span>))");
// ... See if we matched.
var matches = expression.Matches(values).Select(x => x.ToString()).ToList();
@@ -64,7 +64,6 @@ namespace DSACore.Auxiliary
await AddMelee(i, talent, matches);
Console.Write(j + ",");
//await Task.Delay(TimeSpan.FromSeconds(5));
-
}
Console.WriteLine($"{i}: {ids.Count} => {Weapons.Count}");
@@ -76,17 +75,17 @@ namespace DSACore.Auxiliary
private async Task AddMelee(int i, string talent, List<string> matches)
{
- string name = talent.Replace(' ', '_').Replace(".", "");
+ var name = talent.Replace(' ', '_').Replace(".", "");
if (!matches[1].Equals(string.Empty))
{
var temp = new MeleeWeapon(
name,
matches[1],
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- INI = int.TryParse(matches[3], out int ini) ? ini : 0,
+ INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
};
@@ -94,6 +93,7 @@ namespace DSACore.Auxiliary
Weapons.Add(temp);
await Database.AddWeapon(temp);
}
+
/*if (i > 23)
{
var range = new RangedWeapon(
@@ -118,15 +118,15 @@ namespace DSACore.Auxiliary
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- AtMod = int.TryParse(matches[18], out int atMod) ? atMod : 0,
- KKMod = int.TryParse(matches[17], out int kkMod) ? kkMod : 0,
+ AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
+ KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
TpReach = matches[15],
- LoadTime = int.TryParse(matches[18], out int loadTime) ? loadTime : 0
+ LoadTime = int.TryParse(matches[18], out var loadTime) ? loadTime : 0
};
Range.Add(range);
await Database.AddWeapon(range);
@@ -135,17 +135,17 @@ namespace DSACore.Auxiliary
private async Task AddRanged(int i, string talent, List<string> matches)
{
- string name = talent.Replace(' ', '_').Replace(".", "");
+ var name = talent.Replace(' ', '_').Replace(".", "");
if (!matches[1].Equals(string.Empty))
{
var temp = new MeleeWeapon(
name,
matches[1],
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- INI = int.TryParse(matches[3], out int ini) ? ini : 0,
+ INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
};
@@ -159,20 +159,19 @@ namespace DSACore.Auxiliary
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- AtMod = int.TryParse(matches[18], out int atMod) ? atMod : 0,
- KKMod = int.TryParse(matches[17], out int kkMod) ? kkMod : 0,
+ AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
+ KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
TpReach = matches[15],
- LoadTime = int.TryParse(matches[18], out int loadTime) ? loadTime : 0
+ LoadTime = int.TryParse(matches[18], out var loadTime) ? loadTime : 0
};
Range.Add(range);
await Database.AddWeapon(range);
}
}
}
-}
-
+} \ No newline at end of file
diff --git a/DSACore/Commands/CommandHandler.cs b/DSACore/Commands/CommandHandler.cs
index f43633f..6879045 100644
--- a/DSACore/Commands/CommandHandler.cs
+++ b/DSACore/Commands/CommandHandler.cs
@@ -10,8 +10,8 @@ namespace DSACore.Commands
{
public static CommandResponse ExecuteCommand(Command cmd)
{
- string res = string.Empty;
- ResponseType type = ResponseType.Broadcast;
+ var res = string.Empty;
+ var type = ResponseType.Broadcast;
switch (cmd.CmdIdentifier.ToLower())
{
case "addChar":
@@ -21,7 +21,7 @@ namespace DSACore.Commands
case "wert":
case "werte":
case "char":
- res = Commands.HeldList.ListAsync(cmd.CharId, cmd.CmdText);
+ res = HeldList.ListAsync(cmd.CharId, cmd.CmdText);
break;
case "help":
case "man":
@@ -54,23 +54,16 @@ namespace DSACore.Commands
case "npc":
res = NpcCommands.CreateNpc(cmd.CharId, cmd.CmdTexts, cmd.Cmdmodifier);
break;
-
}
- if (res == string.Empty)
- {
- res= Proben(cmd.Name, cmd.CmdIdentifier, cmd.CmdText, cmd.Cmdmodifier);
- }
- if (res != string.Empty)
- {
- return new CommandResponse(res, type);
- }
+ if (res == string.Empty) res = Proben(cmd.Name, cmd.CmdIdentifier, cmd.CmdText, cmd.Cmdmodifier);
+ if (res != string.Empty) return new CommandResponse(res, type);
return new CommandResponse($"Kommando {cmd.CmdIdentifier} nicht gefunden", ResponseType.Error);
}
private static string Proben(string name, string command, string waffe, int erschwernis = 0)
{
- string res = string.Empty;
+ var res = string.Empty;
switch (command.ToLower())
{
case "f":
@@ -138,4 +131,4 @@ namespace DSACore.Commands
throw new NotImplementedException("access char by id ore name and group id");
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/CommandTypes.cs b/DSACore/Commands/CommandTypes.cs
index d53328b..6838ac2 100644
--- a/DSACore/Commands/CommandTypes.cs
+++ b/DSACore/Commands/CommandTypes.cs
@@ -10,4 +10,4 @@
KeinChar,
Zauber
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/FileHandler.cs b/DSACore/Commands/FileHandler.cs
index af4698a..d8fb585 100644
--- a/DSACore/Commands/FileHandler.cs
+++ b/DSACore/Commands/FileHandler.cs
@@ -6,32 +6,25 @@ 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";
}
diff --git a/DSACore/Commands/Gm.cs b/DSACore/Commands/Gm.cs
index a320269..59b3129 100644
--- a/DSACore/Commands/Gm.cs
+++ b/DSACore/Commands/Gm.cs
@@ -180,4 +180,4 @@ namespace DSACore.Commands
return res;
}
}*/
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/HeldList.cs b/DSACore/Commands/HeldList.cs
index 825474c..73861b7 100644
--- a/DSACore/Commands/HeldList.cs
+++ b/DSACore/Commands/HeldList.cs
@@ -15,63 +15,65 @@ namespace DSACore.Commands
var character = Dsa.GetCharacter(id) as Character;
- int first_column_width = 18;
-
+ var first_column_width = 18;
- if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") || prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel"))
- {
+ if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") ||
+ prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel"))
+ {
res.Add(character.Name + ":\n");
//Eigenschaften
res.AddRange(
- character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
+ character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
res.Add("");
//LE/AE
res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
if (character.Astralpunkte_Basis > 0)
- {
res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
res.Add("");
//Kampfwerte
res.Add("".AddSpaces(first_column_width) + " AT/PA");
res.AddRange(
- character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
+ character.Kampftalente.Select(s =>
+ s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" +
+ s.Pa.ToString().AddSpacesAtHead(2)));
res.Add("");
//Fernkampf
res.Add("".AddSpaces(first_column_width) + " FK");
res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
+ character.Talente.Where(x => x.IstFernkampftalent()).Select(s =>
+ s.Name.AddSpaces(first_column_width) + " " +
+ (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
res.Add("");
//Vorteile
res.AddRange(
character.Vorteile
- .Select(s => s.Name + "\t " + s.Value));
+ .Select(s => s.Name + "\t " + s.Value));
res.Add("");
//Talente
res.AddRange(
- character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ character.Talente.Select(s =>
+ (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " +
+ s.Probe));
res.Add("");
//evtl Zauber
if (character.Zauber.Count > 0)
- {
res.AddRange(
- character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
- }
-
+ character.Zauber.Select(s =>
+ (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) +
+ " " + s.Probe));
}
- else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") || prop_list[0].ToLower().StartsWith("hilf"))
+ else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") ||
+ prop_list[0].ToLower().StartsWith("hilf"))
{
return "```xl\n" + Help.Get_Specific_Help("Held") + "\n```";
}
else
{
-
res.Add(character.Name + ":\n");
- foreach (string prop in prop_list)
+ foreach (var prop in prop_list)
{
-
switch (prop.ToLower())
{
case "e":
@@ -79,18 +81,16 @@ namespace DSACore.Commands
case "eigenschaft":
case "eigenschaften":
res.AddRange(
- character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value));
+ character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value));
break;
case "stat":
case "stats":
res.AddRange(
- character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
+ character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
res.Add("");
res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
if (character.Astralpunkte_Basis > 0)
- {
res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
break;
case "le":
res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
@@ -103,12 +103,16 @@ namespace DSACore.Commands
case "talent":
case "talente":
res.AddRange(
- character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ character.Talente.Select(s =>
+ (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(
+ first_column_width + 5) + " " + s.Probe));
break;
case "zauber":
case "z":
res.AddRange(
- character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ character.Zauber.Select(s =>
+ (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(
+ first_column_width + 5) + " " + s.Probe));
break;
case "w":
case "waffe":
@@ -118,13 +122,17 @@ namespace DSACore.Commands
case "kampfwerte":
res.Add("".AddSpaces(first_column_width) + " AT/PA");
res.AddRange(
- character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
+ character.Kampftalente.Select(s =>
+ s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) +
+ "/" + s.Pa.ToString().AddSpacesAtHead(2)));
break;
case "f":
case "fern":
res.Add("".AddSpaces(first_column_width) + " FK");
res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
+ character.Talente.Where(x => x.IstFernkampftalent()).Select(s =>
+ s.Name.AddSpaces(first_column_width) + " " +
+ (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
break;
case "v":
case "vt":
@@ -135,7 +143,7 @@ namespace DSACore.Commands
case "nachteile":
res.AddRange(
character.Vorteile
- .Select(s => s.Name + "\t " + s.Value));
+ .Select(s => s.Name + "\t " + s.Value));
break;
default:
@@ -145,15 +153,11 @@ namespace DSACore.Commands
res.Add("");
}
-
}
var sb = new StringBuilder();
- foreach (string re in res)
- {
- sb.AppendLine(re);
- }
+ foreach (var re in res) sb.AppendLine(re);
return sb.ToString();
/*
@@ -167,4 +171,4 @@ namespace DSACore.Commands
}*/
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/Help.cs b/DSACore/Commands/Help.cs
index 1575b36..6458c20 100644
--- a/DSACore/Commands/Help.cs
+++ b/DSACore/Commands/Help.cs
@@ -33,44 +33,43 @@ namespace DSACore.Commands
public static string Get_Specific_Help(string command)
{
// return command specific help
- var com = DSACore.DSA_Game.Save.Properties.CommandInfos.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
+ var com = DSA_Game.Save.Properties.CommandInfos
+ .OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
return com.GetDescription();
}
public static string Get_Generic_Help()
{
- string res = "";
- foreach (var com in DSACore.DSA_Game.Save.Properties.CommandInfos)
+ var res = "";
+ foreach (var com in DSA_Game.Save.Properties.CommandInfos)
{
- int first_column_width = 8;
+ var first_column_width = 8;
res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief;
if (com.Description.Length > 1)
- {
- res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + "\" gibt genauere Informationen)";
- }
+ res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name +
+ "\" gibt genauere Informationen)";
res += "\n\n";
}
+
return res;
}
-
+
public static string ShowHelp(params string[] commandList)
{
var command = "";
- if (commandList.Length > 0) {
- command = commandList.Aggregate((s, c) => s + " " + c);
- }
+ if (commandList.Length > 0) command = commandList.Aggregate((s, c) => s + " " + c);
if (command.Equals(string.Empty)) // return generic Help
{
- string res = Get_Generic_Help();
-
+ var res = Get_Generic_Help();
+
return res;
}
-
+
return Get_Specific_Help(command);
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/LebenUndAstral.cs b/DSACore/Commands/LebenUndAstral.cs
index b5bc260..7e0cb5c 100644
--- a/DSACore/Commands/LebenUndAstral.cs
+++ b/DSACore/Commands/LebenUndAstral.cs
@@ -12,9 +12,9 @@ namespace DSACore.Commands
public static string LEAsync(ulong id, string modifier)
{
//This is the string that will be printed
- string res = "";
+ var res = "";
+
-
//Get the actual text
res += Dsa.GetCharacter(id).get_LE_Text(modifier);
@@ -23,17 +23,17 @@ namespace DSACore.Commands
}
}
- public class AE
+ public class AE
{
public static string AEAsync(ulong id, string modifier)
{
//This is the string that will be printed
- string res = "";
+ var res = "";
//Get the actual text
res += Dsa.GetCharacter(id).get_AE_Text(modifier);
-
+
return res;
}
}
@@ -42,11 +42,11 @@ namespace DSACore.Commands
{
public static string get_LE_Text(this ICharacter c, string prop)
{
- string res = "";
+ var res = "";
var comp = new SpellCorrect();
var character = c;
- res += (character.Name + ":\n");
+ res += character.Name + ":\n";
//If there is actual input we process it
if (prop.Length > 0)
@@ -60,15 +60,20 @@ namespace DSACore.Commands
//Allow overflowing the max
if (prop.StartsWith("++"))
{
- character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
+ character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell +
+ Convert.ToInt32(prop.Substring(1, prop.Length - 1));
}
else
{
- int temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) - character.Lebenspunkte_Basis;
+ var temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) -
+ character.Lebenspunkte_Basis;
//Stop from overflow overflow
if (temp > 0 && prop.StartsWith("+"))
{
- character.Lebenspunkte_Aktuell = (character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell) ? character.Lebenspunkte_Basis : character.Lebenspunkte_Aktuell;
+ character.Lebenspunkte_Aktuell =
+ character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell
+ ? character.Lebenspunkte_Basis
+ : character.Lebenspunkte_Aktuell;
res += " Maximale Lebenspunkte sind erreicht ";
}
//Simply apply change
@@ -91,23 +96,23 @@ namespace DSACore.Commands
//If no value is passed, the curent value is displayed
else
{
- res += ("LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
+ res += "LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
}
return res;
}
+
public static string get_AE_Text(this ICharacter c, string prop)
{
- string res = "";
+ var res = "";
var comp = new SpellCorrect();
var character = c;
- res += (character.Name + ":\n");
+ res += character.Name + ":\n";
//If there is actual input we process it
if (prop.Length > 0)
{
-
res += "AE: ";
res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis + " -> ";
@@ -117,15 +122,20 @@ namespace DSACore.Commands
//Allow overflowing the max
if (prop.StartsWith("++"))
{
- character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
+ character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell +
+ Convert.ToInt32(prop.Substring(1, prop.Length - 1));
}
else
{
- int temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) - character.Astralpunkte_Basis;
+ var temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) -
+ character.Astralpunkte_Basis;
//Stop from overflow overflow
if (temp > 0 && prop.StartsWith("+"))
{
- character.Astralpunkte_Aktuell = (character.Astralpunkte_Basis > character.Astralpunkte_Aktuell) ? character.Astralpunkte_Basis : character.Astralpunkte_Aktuell;
+ character.Astralpunkte_Aktuell =
+ character.Astralpunkte_Basis > character.Astralpunkte_Aktuell
+ ? character.Astralpunkte_Basis
+ : character.Astralpunkte_Aktuell;
res += " Maximale Astralpunkte sind erreicht ";
}
//Simply apply change
@@ -142,7 +152,6 @@ namespace DSACore.Commands
}
res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
-
}
//Set to new value regardless of original
else
@@ -155,14 +164,11 @@ namespace DSACore.Commands
//If no value is passed, the curent value is displayed
else
{
- res += ("AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
+ res += "AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
}
return res;
}
}
-}
-
-
-
+} \ No newline at end of file
diff --git a/DSACore/Commands/List.cs b/DSACore/Commands/List.cs
index 1fa0dde..2c8f3d0 100644
--- a/DSACore/Commands/List.cs
+++ b/DSACore/Commands/List.cs
@@ -12,7 +12,7 @@ namespace DSACore.Commands
public static string ListAsync(string prop)
{
var res = new List<string>();
-
+
//int persist = 0;
switch (prop.ToLower())
@@ -20,7 +20,7 @@ namespace DSACore.Commands
case "man":
case "help":
return Help.Get_Specific_Help("List");
- // break;
+ // break;
case "chars":
res.AddRange(Dsa.Chars.Select(x => x.Name));
break;
@@ -44,4 +44,4 @@ namespace DSACore.Commands
return res.ToString();
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/MiscCommands.cs b/DSACore/Commands/MiscCommands.cs
index 21646e7..36d5fb1 100644
--- a/DSACore/Commands/MiscCommands.cs
+++ b/DSACore/Commands/MiscCommands.cs
@@ -227,4 +227,4 @@ namespace DSACore.Commands
}*/
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Commands/NpcCommands.cs b/DSACore/Commands/NpcCommands.cs
index 50ea966..9a27e6a 100644
--- a/DSACore/Commands/NpcCommands.cs
+++ b/DSACore/Commands/NpcCommands.cs
@@ -12,16 +12,11 @@ namespace DSACore.Commands
{
public class NpcCommands
{
-
public static string CreateNpc(ulong id, IEnumerable<string> props, int modifier)
{
- if (int.TryParse(props.Last(), out int mean))
- {
- return Random(id, props.First(), mean, 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)
@@ -30,13 +25,10 @@ namespace DSACore.Commands
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)
{
- if (Dsa.Chars.Exists(x => x.Name.Equals(npcName)))
- {
- throw new Exception("Char gibt es schon");
- }
+ if (Dsa.Chars.Exists(x => x.Name.Equals(npcName))) throw new Exception("Char gibt es schon");
throw new NotImplementedException();
var chr = Dsa.GetCharacter(id);
Dsa.Chars.Add(new Character(chr as Character, npcName, stDv));
diff --git a/DSACore/Commands/ProbenTest.cs b/DSACore/Commands/ProbenTest.cs
index a927cd9..d0800d6 100644
--- a/DSACore/Commands/ProbenTest.cs
+++ b/DSACore/Commands/ProbenTest.cs
@@ -1,6 +1,6 @@
namespace DSACore.Commands
{
- public class ProbenTest
+ public class ProbenTest
{
/*[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
[Alias("T", "Talent", "talent", "versuche")]
@@ -82,4 +82,4 @@
return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Fernkampf(waffe, erschwernis) + "\n```");
}*/
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
index d35690c..e9700ff 100644
--- a/DSACore/Controllers/CommandsController.cs
+++ b/DSACore/Controllers/CommandsController.cs
@@ -29,7 +29,7 @@ namespace DSACore.Controllers
// POST api/<controller>/Felis
[HttpPost]
- public string Post([FromBody]Command cmd)
+ public string Post([FromBody] Command cmd)
{
try
{
@@ -39,7 +39,6 @@ namespace DSACore.Controllers
{
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
-
}
/*
@@ -56,4 +55,4 @@ namespace DSACore.Controllers
{
}*/
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs
index a946184..100fb5b 100644
--- a/DSACore/Controllers/LobbyController.cs
+++ b/DSACore/Controllers/LobbyController.cs
@@ -13,9 +13,9 @@ namespace DSACore.Controllers
{
return "Usage: get /tokens/{Token}";
}
-
+
[HttpPost]
- public string Post([FromBody]Command cmd)
+ public string Post([FromBody] Command cmd)
{
try
{
@@ -25,8 +25,6 @@ namespace DSACore.Controllers
{
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
-
- }
-
+ }
}
} \ No newline at end of file
diff --git a/DSACore/Controllers/TokensController.cs b/DSACore/Controllers/TokensController.cs
index 1d49f44..6a59db4 100644
--- a/DSACore/Controllers/TokensController.cs
+++ b/DSACore/Controllers/TokensController.cs
@@ -6,23 +6,17 @@ namespace DSACore.Controllers
[ApiController]
public class TokensController : Controller
{
-
// GET
[HttpGet("{token}")]
public ActionResult<string> Get(string token)
{
if (!int.TryParse(token, out var inttoken))
- {
return BadRequest("The token has to be a 32 bit unsigned integer");
- }
- if (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == inttoken))
- {
- return NotFound();
- }
+ if (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == inttoken)) return NotFound();
var group = Hubs.Users.Tokens.Find(x => x.GetHashCode() == inttoken);
return Ok(group);
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Characters/Character.cs b/DSACore/DSA_Game/Characters/Character.cs
index 247fc58..62d2e11 100644
--- a/DSACore/DSA_Game/Characters/Character.cs
+++ b/DSACore/DSA_Game/Characters/Character.cs
@@ -10,120 +10,110 @@ namespace DSACore.DSA_Game.Characters
using System.Linq;
using System.Text;
using System.Xml;
-
+
public class Character : Being, ICharacter
{
public Character()
{
- this.PropTable.Add("MU", "Mut"); // routing
- this.PropTable.Add("KL", "Klugheit");
- this.PropTable.Add("IN", "Intuition");
- this.PropTable.Add("CH", "Charisma");
- this.PropTable.Add("FF", "Fingerfertigkeit");
- this.PropTable.Add("GE", "Gewandtheit");
- this.PropTable.Add("KO", "Konstitution");
- this.PropTable.Add("KK", "Körperkraft");
-
+ PropTable.Add("MU", "Mut"); // routing
+ PropTable.Add("KL", "Klugheit");
+ PropTable.Add("IN", "Intuition");
+ PropTable.Add("CH", "Charisma");
+ PropTable.Add("FF", "Fingerfertigkeit");
+ PropTable.Add("GE", "Gewandtheit");
+ PropTable.Add("KO", "Konstitution");
+ PropTable.Add("KK", "Körperkraft");
}
public Character(string path) : this()
{
- this.Load(new MemoryStream(File.ReadAllBytes(path))); // load
- this.Post_process(); // calculate derived values
+ Load(new MemoryStream(File.ReadAllBytes(path))); // load
+ Post_process(); // calculate derived values
}
+
public Character(MemoryStream stream) : this()
{
- this.Load(stream); // load
- this.Post_process(); // calculate derived values
+ Load(stream); // load
+ Post_process(); // calculate derived values
}
public Character(Character c, string name, int stDv = 2) : this()
{
- this.Name = name;
+ Name = name;
foreach (var i in c.Eigenschaften)
- {
- this.Eigenschaften.Add(i.Key, i.Value + (int)Math.Round(RandomMisc.Random(stDv)));
- }
+ Eigenschaften.Add(i.Key, i.Value + (int) Math.Round(RandomMisc.Random(stDv)));
foreach (var i in c.Vorteile)
- {
- this.Vorteile.Add(new Vorteil(i.Name, i.Value + (int)Math.Round(RandomMisc.Random(stDv))));
- }
+ Vorteile.Add(new Vorteil(i.Name, i.Value + (int) Math.Round(RandomMisc.Random(stDv))));
foreach (var i in c.Talente)
- {
- this.Talente.Add(new Talent(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv))));
- }
+ Talente.Add(new Talent(i.Name, i.Probe, i.Value + (int) Math.Round(RandomMisc.Random(stDv))));
foreach (var i in c.Zauber)
- {
- this.Zauber.Add(new Zauber(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv)), i.Complexity, i.Representation));
- }
+ Zauber.Add(new Zauber(i.Name, i.Probe, i.Value + (int) Math.Round(RandomMisc.Random(stDv)),
+ i.Complexity, i.Representation));
foreach (var i in c.Kampftalente)
- {
- this.Kampftalente.Add(new KampfTalent(i.Name, i.At + (int)Math.Round(RandomMisc.Random(stDv)), i.Pa + (int)Math.Round(RandomMisc.Random(stDv))));
- }
+ Kampftalente.Add(new KampfTalent(i.Name, i.At + (int) Math.Round(RandomMisc.Random(stDv)),
+ i.Pa + (int) Math.Round(RandomMisc.Random(stDv))));
- this.Post_process(); // calculate derived values
+ Post_process(); // calculate derived values
}
- public Dictionary<string, int> Eigenschaften { get; set; } = new Dictionary<string, int>(); // char properties
+ public Dictionary<string, int> Eigenschaften { get; set; } = new Dictionary<string, int>(); // char properties
- public List<Talent> Talente { get; set; } = new List<Talent>(); // list of talent objects (talents)
+ public List<Talent> Talente { get; set; } = new List<Talent>(); // list of talent objects (talents)
- public List<Zauber> Zauber { get; set; } = new List<Zauber>(); // list of spell objects
+ public List<Zauber> Zauber { get; set; } = new List<Zauber>(); // list of spell objects
- public List<KampfTalent> Kampftalente { get; set; } = new List<KampfTalent>(); // list of combat objects
+ public List<KampfTalent> Kampftalente { get; set; } = new List<KampfTalent>(); // list of combat objects
public List<Vorteil> Vorteile { get; set; } = new List<Vorteil>();
public Dictionary<string, string> PropTable { get; set; } = new Dictionary<string, string>(); // -> Körperkraft
- public string TestTalent(string talent, int erschwernis = 0) // Talentprobe
+ public string TestTalent(string talent, int erschwernis = 0) // Talentprobe
{
- return this.Talente.ProbenTest(this, talent, erschwernis);
+ return Talente.ProbenTest(this, talent, erschwernis);
}
- public string TestZauber(string zauber, int erschwernis = 0) // Talentprobe
+ public string TestZauber(string zauber, int erschwernis = 0) // Talentprobe
{
- return this.Zauber.ProbenTest(this, zauber, erschwernis);
+ return Zauber.ProbenTest(this, zauber, erschwernis);
}
public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
{
var output = new StringBuilder();
- var prop = this.PropTable[eigenschaft.ToUpper()];
- int tap = this.Eigenschaften[prop];
+ var prop = PropTable[eigenschaft.ToUpper()];
+ var tap = Eigenschaften[prop];
output.AppendFormat(
"{0}-Eigenschaftsprobe ew:{1} {2} \n",
prop,
tap,
erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
- int roll = Dice.Roll();
+ var roll = Dice.Roll();
output.Append($"Gewürfelt: {roll} übrig: {tap - roll - erschwernis}");
return output.ToString();
}
- public string Angriff(string talent, int erschwernis = 0) // pretty self explanatory
+ public string Angriff(string talent, int erschwernis = 0) // pretty self explanatory
{
var output = new StringBuilder();
var sc = new SpellCorrect();
- var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
+ var attack = Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
+ return $"{Name} kann nicht mit der Waffenart {talent} umgehen...";
- int tap = attack.At;
+ var tap = attack.At;
output.AppendFormat(
"{0}-Angriff taw:{1} {2} \n",
attack.Name,
tap,
erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
output.Append(temp - erschwernis);
return output.ToString();
}
@@ -132,21 +122,19 @@ namespace DSACore.DSA_Game.Characters
{
var output = new StringBuilder();
var sc = new SpellCorrect();
- var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
+ var attack = Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
+ return $"{Name} kann nicht mit der Waffenart {talent} umgehen...";
- int tap = attack.Pa;
+ var tap = attack.Pa;
output.AppendFormat(
"{0}-Parade taw:{1} {2}\n",
attack.Name,
tap,
erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
output.Append(temp - erschwernis);
return output.ToString();
}
@@ -155,21 +143,19 @@ namespace DSACore.DSA_Game.Characters
{
var output = new StringBuilder();
var sc = new SpellCorrect();
- int fk = this.Eigenschaften["fk"];
- var attack = this.Talente.OrderBy(x => sc.Compare(talent, x.Name)).First();
+ var fk = Eigenschaften["fk"];
+ var attack = Talente.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
+ return $"{Name} kann nicht mit der Waffenart {talent} umgehen...";
- int tap = attack.Value;
+ var tap = attack.Value;
output.AppendFormat(
"{0} taw:{1} {2} \n",
attack.Name,
tap,
erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
tap -= erschwernis;
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
tap -= temp > fk ? temp - fk : 0;
output.Append($"W20: {temp} tap: {tap}");
return output.ToString();
@@ -177,34 +163,30 @@ namespace DSACore.DSA_Game.Characters
private void Post_process()
{
- var LE_Wert = this.Eigenschaften["Lebensenergie"];
- var AE_Wert = this.Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value;
+ var LE_Wert = Eigenschaften["Lebensenergie"];
+ var AE_Wert = Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value;
//var KL_Wert = this.Eigenschaften.First(s => s.Key.Contains("Klugheit")).Value;
- var MU_Wert = this.Eigenschaften.First(s => s.Key.Contains("Mut")).Value;
- var IN_Wert = this.Eigenschaften.First(s => s.Key.Contains("Intuition")).Value;
- var CH_Wert = this.Eigenschaften.First(s => s.Key.Contains("Charisma")).Value;
- var KK_Wert = this.Eigenschaften["Körperkraft"];
- var KO__Wert = this.Eigenschaften["Konstitution"];
-
- this.Astralpunkte_Basis = 0;
+ var MU_Wert = Eigenschaften.First(s => s.Key.Contains("Mut")).Value;
+ var IN_Wert = Eigenschaften.First(s => s.Key.Contains("Intuition")).Value;
+ var CH_Wert = Eigenschaften.First(s => s.Key.Contains("Charisma")).Value;
+ var KK_Wert = Eigenschaften["Körperkraft"];
+ var KO__Wert = Eigenschaften["Konstitution"];
- this.Ausdauer_Basis = 0;
+ Astralpunkte_Basis = 0;
- this.Lebenspunkte_Basis = LE_Wert + (int)(KO__Wert + (KK_Wert / 2.0) + 0.5);
+ Ausdauer_Basis = 0;
- if (this.Vorteile.Exists(x => x.Name.ToLower().Contains("zauberer")))
- {
- this.Astralpunkte_Basis = AE_Wert + (int)((MU_Wert + IN_Wert + CH_Wert) / 2.0 + 0.5);
- }
+ Lebenspunkte_Basis = LE_Wert + (int) (KO__Wert + KK_Wert / 2.0 + 0.5);
- this.Lebenspunkte_Aktuell = this.Lebenspunkte_Basis;
- this.Astralpunkte_Aktuell = this.Astralpunkte_Basis;
- this.Ausdauer_Aktuell = this.Ausdauer_Basis;
+ if (Vorteile.Exists(x => x.Name.ToLower().Contains("zauberer")))
+ Astralpunkte_Basis = AE_Wert + (int) ((MU_Wert + IN_Wert + CH_Wert) / 2.0 + 0.5);
+ Lebenspunkte_Aktuell = Lebenspunkte_Basis;
+ Astralpunkte_Aktuell = Astralpunkte_Basis;
+ Ausdauer_Aktuell = Ausdauer_Basis;
}
-
private void Load(MemoryStream stream)
{
@@ -212,10 +194,7 @@ namespace DSACore.DSA_Game.Characters
while (reader.Read())
{
// read until he hits keywords
- if (reader.NodeType != XmlNodeType.Element)
- {
- continue;
- }
+ if (reader.NodeType != XmlNodeType.Element) continue;
switch (reader.Name)
{
@@ -223,12 +202,13 @@ namespace DSACore.DSA_Game.Characters
reader.Skip();
break;
case "held":
- this.Name = reader.GetAttribute("name"); // name
+ Name = reader.GetAttribute("name"); // name
break;
case "eigenschaft":
- this.Eigenschaften.Add(
+ Eigenschaften.Add(
reader.GetAttribute("name") ?? throw new InvalidOperationException(),
- Convert.ToInt32(reader.GetAttribute("value")) + Convert.ToInt32(reader.GetAttribute("mod")));
+ Convert.ToInt32(reader.GetAttribute("value")) +
+ Convert.ToInt32(reader.GetAttribute("mod")));
break;
case "vt":
reader.Read();
@@ -236,14 +216,14 @@ namespace DSACore.DSA_Game.Characters
{
try
{
- this.Vorteile.Add(new Vorteil(
+ Vorteile.Add(new Vorteil(
reader.GetAttribute("name"),
- // Convert.ToInt32(reader.GetAttribute("value"))));
- reader.GetAttribute("value")));
+ // Convert.ToInt32(reader.GetAttribute("value"))));
+ reader.GetAttribute("value")));
}
catch
{
- this.Vorteile.Add(new Vorteil(reader.GetAttribute("name")));
+ Vorteile.Add(new Vorteil(reader.GetAttribute("name")));
}
reader.Read();
@@ -254,7 +234,7 @@ namespace DSACore.DSA_Game.Characters
reader.Read();
while (reader.Name.Equals("talent"))
{
- this.Talente.Add(
+ Talente.Add(
new Talent(
reader.GetAttribute("name"),
reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'),
@@ -267,7 +247,7 @@ namespace DSACore.DSA_Game.Characters
reader.Read();
while (reader.Name.Equals("zauber"))
{
- this.Zauber.Add(
+ Zauber.Add(
new Zauber(
reader.GetAttribute("name"),
reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'),
@@ -279,12 +259,12 @@ namespace DSACore.DSA_Game.Characters
break;
case "kampfwerte":
- string atName = reader.GetAttribute("name");
+ var atName = reader.GetAttribute("name");
reader.Read();
- int at = Convert.ToInt32(reader.GetAttribute("value"));
+ var at = Convert.ToInt32(reader.GetAttribute("value"));
reader.Read();
- int pa = Convert.ToInt32(reader.GetAttribute("value"));
- this.Kampftalente.Add(new KampfTalent(atName, at, pa));
+ var pa = Convert.ToInt32(reader.GetAttribute("value"));
+ Kampftalente.Add(new KampfTalent(atName, at, pa));
break;
}
}
diff --git a/DSACore/DSA_Game/Characters/NPC.cs b/DSACore/DSA_Game/Characters/NPC.cs
index 0a660ee..e6b7bed 100644
--- a/DSACore/DSA_Game/Characters/NPC.cs
+++ b/DSACore/DSA_Game/Characters/NPC.cs
@@ -5,8 +5,7 @@ using DSALib.Characters;
namespace DSACore.Characters
{
using System;
-
- using DSACore.Auxiliary;
+ using Auxiliary;
using DSACore.DSA_Game.Characters;
public class Npc : Being, ICharacter
@@ -17,94 +16,67 @@ namespace DSACore.Characters
{
this.mean = mean;
this.stDv = stDv;
- this.Name = name;
+ Name = name;
}
public string TestTalent(string talent, int tap = 3)
{
- for (int i = 0; i <= 2; i++)
+ for (var i = 0; i <= 2; i++)
{
// foreach property, dice and tap
- int temp = Dice.Roll();
- int eigenschaft = (int)Math.Round(RandomMisc.Random(this.stDv, this.mean));
+ var temp = Dice.Roll();
+ var eigenschaft = (int) Math.Round(RandomMisc.Random(stDv, mean));
- if (eigenschaft < temp)
- {
- tap -= temp - eigenschaft;
- }
+ if (eigenschaft < temp) tap -= temp - eigenschaft;
}
- if (tap >= 0)
- {
- return $"{this.Name} vollführt {talent} erfolgreich";
- }
+ if (tap >= 0) return $"{Name} vollführt {talent} erfolgreich";
- return $"{this.Name} scheitert an {talent}";
+ return $"{Name} scheitert an {talent}";
}
public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
{
- int temp = Dice.Roll();
- int prop = (int)Math.Round(RandomMisc.Random(this.stDv, this.stDv));
-
- if (temp + erschwernis < prop)
- {
- return $"{this.Name} vollführt {eigenschaft} erfolgreich";
- }
+ var temp = Dice.Roll();
+ var prop = (int) Math.Round(RandomMisc.Random(stDv, stDv));
- return $"{this.Name} scheitert an {eigenschaft}";
+ if (temp + erschwernis < prop) return $"{Name} vollführt {eigenschaft} erfolgreich";
+
+ return $"{Name} scheitert an {eigenschaft}";
}
public string Angriff(string waffe, int erschwernis = 0)
{
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
- if (temp == 1)
- {
- return $"{this.Name} greift kritisch mit {waffe} an";
- }
+ if (temp == 1) return $"{Name} greift kritisch mit {waffe} an";
- if (temp < erschwernis)
- {
- return $"{this.Name} greift mit {waffe} an";
- }
+ if (temp < erschwernis) return $"{Name} greift mit {waffe} an";
- return $"{this.Name} haut mit {waffe} daneben";
+ return $"{Name} haut mit {waffe} daneben";
}
public string Parade(string waffe, int erschwernis = 0)
{
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
- if (temp == 1)
- {
- return $"{this.Name} pariert mit {waffe} meisterlich";
- }
+ if (temp == 1) return $"{Name} pariert mit {waffe} meisterlich";
- if (temp < erschwernis)
- {
- return $"{this.Name} pariert mit {waffe} an";
- }
+ if (temp < erschwernis) return $"{Name} pariert mit {waffe} an";
- return $"{this.Name} schafft es nicht mit {waffe} zu parieren";
+ return $"{Name} schafft es nicht mit {waffe} zu parieren";
}
public string Fernkampf(string waffe, int erschwernis = 0)
{
- int temp = Dice.Roll();
+ var temp = Dice.Roll();
- if (temp == 1)
- {
- return $"{this.Name} trifft kritisch mit {waffe}";
- }
+ if (temp == 1) return $"{Name} trifft kritisch mit {waffe}";
- if (temp < erschwernis)
- {
- return $"{this.Name} greift mit {waffe} an";
- }
+ if (temp < erschwernis) return $"{Name} greift mit {waffe} an";
- return $"{this.Name} schießt mit {waffe} daneben";
+ return $"{Name} schießt mit {waffe} daneben";
}
public string TestZauber(string zauber, int erschwernis)
@@ -112,4 +84,4 @@ namespace DSACore.Characters
return TestTalent(zauber, erschwernis);
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Characters/SaveChar.cs b/DSACore/DSA_Game/Characters/SaveChar.cs
index 87c2566..7b29b4e 100644
--- a/DSACore/DSA_Game/Characters/SaveChar.cs
+++ b/DSACore/DSA_Game/Characters/SaveChar.cs
@@ -2,7 +2,6 @@
namespace DSACore.DSA_Game.Characters
{
-
public class SaveChar
{
public string Name { get; set; }
@@ -36,4 +35,4 @@ namespace DSACore.DSA_Game.Characters
c.Name = s.Name;
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Dsa.cs b/DSACore/DSA_Game/Dsa.cs
index cbdb734..f2ffe48 100644
--- a/DSACore/DSA_Game/Dsa.cs
+++ b/DSACore/DSA_Game/Dsa.cs
@@ -10,19 +10,20 @@ namespace DSACore.DSA_Game
using System.Collections.Generic;
using System.IO;
using System.Linq;
- using DSACore.DSA_Game.Characters;
- using DSACore.DSA_Game.Save;
+ using Characters;
+ using Save;
public static class Dsa
{
#if DEBUG
- public const string rootPath = "";//"C:\\Users\\Dennis\\Source\\Repos\\DiscoBot\\DSACore\\";//"DiscoBot\\DSACore\\";
+ public const string
+ rootPath = ""; //"C:\\Users\\Dennis\\Source\\Repos\\DiscoBot\\DSACore\\";//"DiscoBot\\DSACore\\";
#else
public const string rootPath = "";//"DiscoBot\\DSACore\\";
#endif
private static Session s_session;
- public static List<ICharacter> Chars { get; set; } = new List<ICharacter>(); // list of all characters
+ public static List<ICharacter> Chars { get; set; } = new List<ICharacter>(); // list of all characters
public static List<Talent> Talente { get; set; } = new List<Talent>();
@@ -39,10 +40,7 @@ namespace DSACore.DSA_Game
set
{
s_session = value;
- foreach (var x in value.Chars)
- {
- Chars.Find(c => c.Name.Equals(x.Name)).Update(x);
- }
+ foreach (var x in value.Chars) Chars.Find(c => c.Name.Equals(x.Name)).Update(x);
}
}
@@ -61,9 +59,9 @@ namespace DSACore.DSA_Game
}
*/
- Properties.Deserialize(rootPath+"Properties");
+ Properties.Deserialize(rootPath + "Properties");
Properties.Serialize(rootPath + "Properties");
-
+
Talente = Talente.OrderBy(x => x.Name).ToList();
Zauber = Zauber.OrderBy(x => x.Name).ToList();
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs
index 459a9c7..50bd8fa 100644
--- a/DSACore/DSA_Game/Save/Properties.cs
+++ b/DSACore/DSA_Game/Save/Properties.cs
@@ -39,17 +39,13 @@ namespace DSACore.DSA_Game.Save
{
var files = Directory.GetFiles(path, "*.json");
- foreach (string file in files)
- {
+ foreach (var file in files)
try
{
- string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
- string data = File.ReadAllText(file);
- Type type = Type.GetType(name);
- if (data.StartsWith("["))
- {
- type = typeof(List<>).MakeGenericType(type);
- }
+ var name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
+ var data = File.ReadAllText(file);
+ var type = Type.GetType(name);
+ if (data.StartsWith("[")) type = typeof(List<>).MakeGenericType(type);
var o = JsonConvert.DeserializeObject(data, type);
objects.Add(name.Split('.').Last(), o);
@@ -59,7 +55,6 @@ namespace DSACore.DSA_Game.Save
// ignored
Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e);
}
- }
}
public static void Serialize(string path = @"..\..\Properties\")
@@ -68,7 +63,7 @@ namespace DSACore.DSA_Game.Save
{
foreach (var o in objects)
{
- string assembly = o.Value is IList list
+ var assembly = o.Value is IList list
? ((IList) list)[0]?.GetType().FullName
: o.Value.GetType().FullName;
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs
index 198d707..80d4426 100644
--- a/DSACore/DSA_Game/Save/SaveCommand.cs
+++ b/DSACore/DSA_Game/Save/SaveCommand.cs
@@ -6,18 +6,18 @@ 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(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();
@@ -33,15 +33,15 @@ namespace DSACore.DSA_Game.Save
if (name.Equals("?") || name.Equals(string.Empty))
{
Console.WriteLine($"Gespeicherte Sessions:");
- Console.WriteLine(this.ListSessions());
+ 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");
}
@@ -58,13 +58,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
diff --git a/DSACore/DSA_Game/Save/Session.cs b/DSACore/DSA_Game/Save/Session.cs
index b402656..595f0e8 100644
--- a/DSACore/DSA_Game/Save/Session.cs
+++ b/DSACore/DSA_Game/Save/Session.cs
@@ -11,22 +11,25 @@ namespace DSACore.DSA_Game.Save
{
public static string DirectoryPath { get; set; } = Dsa.rootPath + @"sessions";
- public Dictionary<string, string> Relation { get; set; } = new Dictionary<string, string>(); // dictionary to match the char
+ public Dictionary<string, string> Relation { get; set; } =
+ new Dictionary<string, string>(); // dictionary to match the char
- public List<SaveChar> Chars { get; set; } = new List<SaveChar>(); // list of all characters
+ public List<SaveChar> Chars { get; set; } = new List<SaveChar>(); // list of all characters
public string SessionName { get; set; }
-
+
public static Session Load(string path)
{
try
{
- return JsonConvert.DeserializeObject<Session>(File.ReadAllText(path)); // Deserialize Data and create Session Object
+ return
+ JsonConvert.DeserializeObject<Session>(
+ File.ReadAllText(path)); // Deserialize Data and create Session Object
}
catch (Exception e)
{
// ignored
- Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen."+ e);
+ Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen." + e);
return null;
}
}
@@ -35,13 +38,15 @@ namespace DSACore.DSA_Game.Save
{
try
{
- File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
+ File.WriteAllText(path,
+ JsonConvert.SerializeObject(this,
+ Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
catch (Exception e)
{
- Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen.\n"+ e);
+ Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen.\n" + e);
// ignored
}
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/FireBase/Database.cs b/DSACore/FireBase/Database.cs
index 15b76f0..abe2b92 100644
--- a/DSACore/FireBase/Database.cs
+++ b/DSACore/FireBase/Database.cs
@@ -18,7 +18,8 @@ namespace DSACore.FireBase
static Database()
{
- var auth = File.ReadAllText(DSACore.DSA_Game.Dsa.rootPath + "Token"); ; // your app secret
+ var auth = File.ReadAllText(DSA_Game.Dsa.rootPath + "Token");
+ ; // your app secret
firebase = new FirebaseClient(
"https://heldenonline-4d828.firebaseio.com/",
new FirebaseOptions
@@ -45,13 +46,10 @@ namespace DSACore.FireBase
.OrderByKey()
.OnceAsync<T>();
- foreach (var firebaseObject in temp)
- {
- list.Add(firebaseObject.Key, firebaseObject.Object);
- }
+ foreach (var firebaseObject in temp) list.Add(firebaseObject.Key, firebaseObject.Object);
}
- public static Dictionary<string,DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
+ public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
@@ -63,14 +61,14 @@ namespace DSACore.FireBase
public static async Task<int> AddChar(Character file, Models.Network.Group group)
{
- DatabaseChar.LoadChar(file, out GroupChar groupChar, out DatabaseChar data);
+ DatabaseChar.LoadChar(file, out var groupChar, out var data);
var lastChar = await firebase
.Child("Chars")
.OrderByKey()
.LimitToLast(1)
.OnceAsync<DatabaseChar>();
- int id = groupChar.Id = data.Id = lastChar.First().Object.Id + 1;
+ var id = groupChar.Id = data.Id = lastChar.First().Object.Id + 1;
await firebase //TODO Reomve await Operators
.Child("Groups")
@@ -94,7 +92,6 @@ namespace DSACore.FireBase
public static async Task RemoveChar(int id)
{
-
await firebase
.Child("Groups")
.Child("Char" + id)
@@ -111,7 +108,6 @@ namespace DSACore.FireBase
.Child("Inventories")
.Child("Inventory" + id)
.DeleteAsync();
-
}
public static async Task<DatabaseChar> GetChar(int id)
@@ -158,11 +154,12 @@ namespace DSACore.FireBase
}
public static async Task<Talent> GetTalent(string talent)
- {/*
- return await firebase
- .Child("Talents")
- .Child(talent)
- .OnceSingleAsync<Talent>();*/
+ {
+ /*
+ return await firebase
+ .Child("Talents")
+ .Child(talent)
+ .OnceSingleAsync<Talent>();*/
return Talents[talent];
}
@@ -194,7 +191,7 @@ namespace DSACore.FireBase
public static async Task AddWeapon(Weapon wep)
{
- string collection = wep.GetType() == typeof(MeleeWeapon) ? "MeleeWeapons" : "RangedWeapons";
+ var collection = wep.GetType() == typeof(MeleeWeapon) ? "MeleeWeapons" : "RangedWeapons";
await firebase
.Child(collection)
.Child(wep.Name)
@@ -203,7 +200,7 @@ namespace DSACore.FireBase
public static async Task RemoveWeapon(string weapon, bool ranged = false)
{
- string collection = ranged ? "RangedWeapons" : "MeleeWeapons";
+ var collection = ranged ? "RangedWeapons" : "MeleeWeapons";
await firebase
.Child(collection)
.Child(weapon)
@@ -212,7 +209,7 @@ namespace DSACore.FireBase
public static async Task<Weapon> GetWeapon(string weapon, bool ranged = false)
{
- string collection = ranged ? "RangedWeapons" : "MeleeWeapons";
+ var collection = ranged ? "RangedWeapons" : "MeleeWeapons";
return await firebase
.Child(collection)
.Child(weapon)
@@ -228,9 +225,7 @@ namespace DSACore.FireBase
var ret = new List<Models.Network.Group>();
foreach (var firebaseObject in groups)
- {
ret.Add(new Models.Network.Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
- }
return ret;
}
@@ -251,7 +246,7 @@ namespace DSACore.FireBase
.OrderByKey()
.LimitToLast(1)
.OnceAsync<Group>();
- int id = group.Id = lastChar.First().Object.Id + 1;
+ var id = group.Id = lastChar.First().Object.Id + 1;
await firebase
.Child("Groups")
@@ -275,4 +270,4 @@ namespace DSACore.FireBase
.DeleteAsync();
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Hubs/Login.cs b/DSACore/Hubs/Login.cs
index 5f984e2..f589e49 100644
--- a/DSACore/Hubs/Login.cs
+++ b/DSACore/Hubs/Login.cs
@@ -15,11 +15,11 @@ namespace DSACore.Hubs
public class Users : Hub
{
//private static Dictionary<string, User> UserGroup = new Dictionary<string, User>();
-
- private const string ReceiveMethod = "ReceiveMessage";//receiveMethod;
- private static List<Group> DsaGroups {get; set; }
- public static List<Token> Tokens { get;} = new List<Token>();
+ private const string ReceiveMethod = "ReceiveMessage"; //receiveMethod;
+
+ private static List<Group> DsaGroups { get; set; }
+ public static List<Token> Tokens { get; } = new List<Token>();
static Users()
{
@@ -29,39 +29,36 @@ namespace DSACore.Hubs
//AddGroups();
}
-
+
[Obsolete]
private static async void AddGroups()
{
- await Database.AddGroup(new Models.Database.Groups.Group { Name = "HalloWelt", Password = "valid" });
- await Database.AddGroup(new Models.Database.Groups.Group { Name = "Die Krassen Gamer", Password = "valid" });
- await Database.AddGroup(new Models.Database.Groups.Group { Name = "DSA", Password = "valid" });
- await Database.AddGroup(new Models.Database.Groups.Group { Name = "Die Überhelden", Password = "valid" });
+ await Database.AddGroup(new Models.Database.Groups.Group {Name = "HalloWelt", Password = "valid"});
+ await Database.AddGroup(new Models.Database.Groups.Group {Name = "Die Krassen Gamer", Password = "valid"});
+ await Database.AddGroup(new Models.Database.Groups.Group {Name = "DSA", Password = "valid"});
+ await Database.AddGroup(new Models.Database.Groups.Group {Name = "Die Überhelden", Password = "valid"});
}
public async Task SendMessage(string user, string message)
{
try
{
- string group = getGroup(Context.ConnectionId).Name;
+ var group = getGroup(Context.ConnectionId).Name;
}
catch (InvalidOperationException e)
{
//await Clients.Caller.SendCoreAsync(receiveMethod,
- // new object[] { "Nutzer ist in keiner Gruppe. Erst joinen!" });
+ // new object[] { "Nutzer ist in keiner Gruppe. Erst joinen!" });
}
if (message[0] == '/')
{
var args = message.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
- bool Timon = args.Any(x => x == "hallo");
+ var Timon = args.Any(x => x == "hallo");
var ident = args.First().Replace("/", "");
- if (args.Count > 0)
- {
- args.RemoveAt(0);
- }
+ if (args.Count > 0) args.RemoveAt(0);
var ret = Commands.CommandHandler.ExecuteCommand(new Command
{
@@ -81,63 +78,57 @@ namespace DSACore.Hubs
await SendToGroup(ret.message);
break;
}
-
-
}
else
{
await SendToGroup(message);
}
-
}
private Task SendToGroup(string message)
{
try
{
- string group = getGroup(Context.ConnectionId).Name;
+ var group = getGroup(Context.ConnectionId).Name;
return Clients.Group(group).SendCoreAsync(ReceiveMethod,
new object[] {getUser(Context.ConnectionId).Name, message});
}
catch (InvalidOperationException e)
{
return Clients.Caller.SendCoreAsync(ReceiveMethod,
- new object[] { "Nutzer ist in keiner Gruppe. Erst joinen!" });
+ new object[] {"Nutzer ist in keiner Gruppe. Erst joinen!"});
}
}
- private Models.Network.Group getGroup(string id)
+ private Group getGroup(string id)
{
return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id)));
}
private User getUser(string id)
{
- return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))).Users.First(z => z.ConnectionId.Equals(id));
+ return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))).Users
+ .First(z => z.ConnectionId.Equals(id));
}
public async Task GetGroups()
{
var test = await Database.GetGroups();
-
+
foreach (var group in test)
- {
- if (!DsaGroups.Exists(x => x.Name.Equals(group.Name)))
- {
- DsaGroups.Add(group);
- }
- }
+ if (!DsaGroups.Exists(x => x.Name.Equals(@group.Name)))
+ DsaGroups.Add(@group);
- await Clients.Caller.SendCoreAsync("ListGroups", new object[] { DsaGroups.Select(x => x.SendGroup()) });
+ await Clients.Caller.SendCoreAsync("ListGroups", new object[] {DsaGroups.Select(x => x.SendGroup())});
//throw new NotImplementedException("add database call to get groups");
}
public async Task AddGroup(string group, string password)
{
DsaGroups.Add(new Group(group, password));
- var Dgroup = new Models.Database.Groups.Group { Name = group, Id = DsaGroups.Count - 1 };
+ var Dgroup = new Models.Database.Groups.Group {Name = group, Id = DsaGroups.Count - 1};
//Database.AddGroup(Dgroup);
- await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] { $"group {@group} sucessfully added" });
+ await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] {$"group {@group} sucessfully added"});
//throw new NotImplementedException("add database call to add groups");
}
@@ -159,7 +150,7 @@ namespace DSACore.Hubs
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, "login");
await Groups.AddToGroupAsync(Context.ConnectionId, group);
- gGroup.Users.Add(new User { ConnectionId = Context.ConnectionId, Name = user });
+ gGroup.Users.Add(new User {ConnectionId = Context.ConnectionId, Name = user});
await SendToGroup("Ein neuer Nutzer hat die Gruppe betreten");
await Clients.Caller.SendAsync("LoginResponse", 0);
await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user, "online"});
@@ -202,7 +193,6 @@ namespace DSACore.Hubs
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, "online");
if (DsaGroups.Exists(x => x.Users.Exists(y => y.ConnectionId == Context.ConnectionId)))
- {
try
{
var group = getGroup(Context.ConnectionId);
@@ -210,19 +200,16 @@ namespace DSACore.Hubs
var user = getUser(Context.ConnectionId);
- await Clients.Caller.SendAsync("PlayerStatusChanged", new[] { user.Name, "offline" });
+ await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user.Name, "offline"});
//await SendToGroup(user.Name + " disconnected from the Server");
- group.Users.Remove(user);
- await Groups.RemoveFromGroupAsync(Context.ConnectionId, group.Name);
+ @group.Users.Remove(user);
+ await Groups.RemoveFromGroupAsync(Context.ConnectionId, @group.Name);
}
catch (Exception e)
{
Console.WriteLine(e);
//throw;
}
- }
-
}
-
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/Advantage.cs b/DSACore/Models/Database/DSA/Advantage.cs
index 2f0b443..cc8f5cc 100644
--- a/DSACore/Models/Database/DSA/Advantage.cs
+++ b/DSACore/Models/Database/DSA/Advantage.cs
@@ -13,4 +13,4 @@ namespace DSACore.Models.Database.DSA
public string Name { get; set; }
public string Value { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/CharSpell.cs b/DSACore/Models/Database/DSA/CharSpell.cs
index 63d917a..fabd456 100644
--- a/DSACore/Models/Database/DSA/CharSpell.cs
+++ b/DSACore/Models/Database/DSA/CharSpell.cs
@@ -13,4 +13,4 @@ namespace DSACore.Models.Database.DSA
public string representation { get; set; }
public int value { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/DatabaseChar.cs b/DSACore/Models/Database/DSA/DatabaseChar.cs
index 8c51821..6a57629 100644
--- a/DSACore/Models/Database/DSA/DatabaseChar.cs
+++ b/DSACore/Models/Database/DSA/DatabaseChar.cs
@@ -10,7 +10,8 @@ namespace DSACore.Models.Database.DSA
{
}
- public DatabaseChar(int id, string name, string rasse, List<Field> skills, List<Field> talents, List<Advantage> advantages, List<CharSpell> spells, List<WeaponTalent> weaponTalents)
+ public DatabaseChar(int id, string name, string rasse, List<Field> skills, List<Field> talents,
+ List<Advantage> advantages, List<CharSpell> spells, List<WeaponTalent> weaponTalents)
{
Id = id;
Name = name ?? throw new ArgumentNullException(nameof(name));
@@ -58,4 +59,4 @@ namespace DSACore.Models.Database.DSA
data.WeaponTalents = file.Kampftalente.Select(x => new WeaponTalent(x.Name, x.At, x.Pa)).ToList();
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/Field.cs b/DSACore/Models/Database/DSA/Field.cs
index 5022768..e63aeb4 100644
--- a/DSACore/Models/Database/DSA/Field.cs
+++ b/DSACore/Models/Database/DSA/Field.cs
@@ -7,10 +7,10 @@ namespace DSACore.Models.Database.DSA
public Field(string name, int value = 0)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
- this.Value = value;
+ Value = value;
}
public string Name { get; set; }
public int Value { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/GeneralSpell.cs b/DSACore/Models/Database/DSA/GeneralSpell.cs
index 74b95d7..b4dbc0b 100644
--- a/DSACore/Models/Database/DSA/GeneralSpell.cs
+++ b/DSACore/Models/Database/DSA/GeneralSpell.cs
@@ -4,7 +4,7 @@
{
public char Comlexity = 'A';
- public GeneralSpell(string name, string roll, char comlexity = 'A') :base(name, roll)
+ public GeneralSpell(string name, string roll, char comlexity = 'A') : base(name, roll)
{
Comlexity = comlexity;
}
@@ -17,4 +17,4 @@
{
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/GroupChar.cs b/DSACore/Models/Database/DSA/GroupChar.cs
index 70b8fc1..31fc583 100644
--- a/DSACore/Models/Database/DSA/GroupChar.cs
+++ b/DSACore/Models/Database/DSA/GroupChar.cs
@@ -10,4 +10,4 @@
public int AsMax { get; set; }
public Weapon Weapon { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/Inventory.cs b/DSACore/Models/Database/DSA/Inventory.cs
index 69c7b08..9a025d4 100644
--- a/DSACore/Models/Database/DSA/Inventory.cs
+++ b/DSACore/Models/Database/DSA/Inventory.cs
@@ -9,4 +9,4 @@ namespace DSACore.Models.Database.DSA
public Dictionary<string, bool> Food { get; set; } = new Dictionary<string, bool>();
public List<Weapon> Weapons { get; set; } = new List<Weapon>();
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/Talent.cs b/DSACore/Models/Database/DSA/Talent.cs
index a6de395..59ff4bc 100644
--- a/DSACore/Models/Database/DSA/Talent.cs
+++ b/DSACore/Models/Database/DSA/Talent.cs
@@ -13,7 +13,7 @@ namespace DSACore.Models.Database.DSA
Name = name ?? throw new ArgumentNullException(nameof(name));
}
- public Talent(string name, String roll)
+ public Talent(string name, string roll)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
Roll = roll.Split('/');
@@ -23,4 +23,4 @@ namespace DSACore.Models.Database.DSA
public string[] Roll { get; set; } = new string[3];
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/Weapon.cs b/DSACore/Models/Database/DSA/Weapon.cs
index 24b334a..d6d7999 100644
--- a/DSACore/Models/Database/DSA/Weapon.cs
+++ b/DSACore/Models/Database/DSA/Weapon.cs
@@ -30,7 +30,8 @@ namespace DSACore.Models.Database.DSA
public int INI { get; set; }
public string MW { get; set; }
- public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price)
+ public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
+ damage, weight, weaponTalent, price)
{
}
}
@@ -43,8 +44,9 @@ namespace DSACore.Models.Database.DSA
public string TpReach { get; set; }
public int LoadTime { get; set; }
- public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price)
+ public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
+ damage, weight, weaponTalent, price)
{
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Database/DSA/WeaponTalent.cs b/DSACore/Models/Database/DSA/WeaponTalent.cs
index 869cb35..98eb38d 100644
--- a/DSACore/Models/Database/DSA/WeaponTalent.cs
+++ b/DSACore/Models/Database/DSA/WeaponTalent.cs
@@ -2,7 +2,7 @@
namespace DSACore.Models.Database.DSA
{
- public class WeaponTalent
+ public class WeaponTalent
{
public WeaponTalent(string name, int at, int pa)
{
diff --git a/DSACore/Models/Database/Groups/DSAGroup.cs b/DSACore/Models/Database/Groups/DSAGroup.cs
index 8f20278..89fac2f 100644
--- a/DSACore/Models/Database/Groups/DSAGroup.cs
+++ b/DSACore/Models/Database/Groups/DSAGroup.cs
@@ -5,6 +5,6 @@ namespace DSACore.Models.Database.Groups
{
public class DSAGroup : Group
{
- public List<GroupChar> Chars { get; set; }= new List<GroupChar>();
+ public List<GroupChar> Chars { get; set; } = new List<GroupChar>();
}
} \ No newline at end of file
diff --git a/DSACore/Models/Database/Groups/Group.cs b/DSACore/Models/Database/Groups/Group.cs
index 23e5f68..77d3a64 100644
--- a/DSACore/Models/Database/Groups/Group.cs
+++ b/DSACore/Models/Database/Groups/Group.cs
@@ -6,8 +6,5 @@
public string Discord { get; set; }
public string Password { get; set; }
public int Id { get; set; }
-
}
-
-
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Network/Command.cs b/DSACore/Models/Network/Command.cs
index 456a896..316461e 100644
--- a/DSACore/Models/Network/Command.cs
+++ b/DSACore/Models/Network/Command.cs
@@ -14,7 +14,7 @@ namespace DSACore.Models.Network
public List<string> CmdTexts { get; set; }
public string CmdText => CmdTexts.Count != 0 ? CmdTexts.First() : "";
- public int Cmdmodifier => CmdTexts.Count != 0 && int.TryParse(CmdTexts.Last(), out int mod) ? mod : 0;
+ public int Cmdmodifier => CmdTexts.Count != 0 && int.TryParse(CmdTexts.Last(), out var mod) ? mod : 0;
public bool IsDm { get; set; } = false;
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Network/CommandResponse.cs b/DSACore/Models/Network/CommandResponse.cs
index ed4b7d0..7478397 100644
--- a/DSACore/Models/Network/CommandResponse.cs
+++ b/DSACore/Models/Network/CommandResponse.cs
@@ -7,14 +7,14 @@ namespace DSACore.Models.Network
{
public class CommandResponse
{
- public CommandResponse(string message, ResponseType responseType= ResponseType.Broadcast)
+ public CommandResponse(string message, ResponseType responseType = ResponseType.Broadcast)
{
this.message = message ?? throw new ArgumentNullException(nameof(message));
ResponseType = responseType;
}
public string message { get; private set; }
- public ResponseType ResponseType { get; private set;}
+ public ResponseType ResponseType { get; private set; }
public override string ToString()
{
@@ -28,4 +28,4 @@ namespace DSACore.Models.Network
Caller,
Error
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs
index 76c3efb..3a8ce77 100644
--- a/DSACore/Models/Network/Group.cs
+++ b/DSACore/Models/Network/Group.cs
@@ -22,14 +22,11 @@ namespace DSACore.Models.Network
public string Password { get; set; }
public List<User> Users { get; set; } = new List<User>();
- public int UserCount
- {
- get { return Users.Count; }
- }
+ public int UserCount => Users.Count;
public SendGroup SendGroup()
{
- return new SendGroup( Name, UserCount);
+ return new SendGroup(Name, UserCount);
}
}
@@ -44,6 +41,5 @@ namespace DSACore.Models.Network
public string Name { get; set; }
public int UserCount { get; set; }
-
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Models/Network/User.cs b/DSACore/Models/Network/User.cs
index 04ef0a9..97a9224 100644
--- a/DSACore/Models/Network/User.cs
+++ b/DSACore/Models/Network/User.cs
@@ -11,4 +11,4 @@ namespace DSACore.Models.Network
public string ConnectionId { get; set; }
public int Char { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Program.cs b/DSACore/Program.cs
index d8cb67c..357f919 100644
--- a/DSACore/Program.cs
+++ b/DSACore/Program.cs
@@ -20,10 +20,11 @@ namespace DSACore
CreateWebHostBuilder(args).Build().Run();
}
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
+ public static IWebHostBuilder CreateWebHostBuilder(string[] args)
+ {
+ return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:5000");
-
+ }
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs
index 1dcc690..6f3ec79 100644
--- a/DSACore/Startup.cs
+++ b/DSACore/Startup.cs
@@ -52,23 +52,19 @@ namespace DSACore
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
- {
app.UseDeveloperExceptionPage();
- }
else
- {
app.UseHsts();
- }
app.UseCors("CorsPolicy");
app.UseSignalR(routes => { routes.MapHub<Users>("/login"); });
app.UseWebSockets();
-
- //app.UseCors("AllowSpecificOrigin");
+
+ //app.UseCors("AllowSpecificOrigin");
app.UseHttpsRedirection();
app.UseMvc();
}
}
-}
+} \ No newline at end of file