summaryrefslogtreecommitdiff
path: root/dsa/DSALib
diff options
context:
space:
mode:
Diffstat (limited to 'dsa/DSALib')
-rw-r--r--dsa/DSALib/Auxiliary/Calculator/Argument.cs15
-rw-r--r--dsa/DSALib/Auxiliary/Calculator/ISolvable.cs6
-rw-r--r--dsa/DSALib/Auxiliary/Calculator/Operator.cs18
-rw-r--r--dsa/DSALib/Auxiliary/Calculator/Ops.cs6
-rw-r--r--dsa/DSALib/Auxiliary/Calculator/StringSolver.cs60
-rw-r--r--dsa/DSALib/Auxiliary/CommandInfo.cs12
-rw-r--r--dsa/DSALib/Auxiliary/Dice.cs20
-rw-r--r--dsa/DSALib/Auxiliary/Extensions.cs12
-rw-r--r--dsa/DSALib/Auxiliary/IDataObjectEnumerableExtension.cs22
-rw-r--r--dsa/DSALib/Auxiliary/RandomMisc.cs21
-rw-r--r--dsa/DSALib/Auxiliary/SpellCorrect.cs48
-rw-r--r--dsa/DSALib/Auxiliary/TalentEnumerableExtension.cs22
-rw-r--r--dsa/DSALib/Auxiliary/WeaponImporter.cs48
-rw-r--r--dsa/DSALib/Characters/Being.cs6
-rw-r--r--dsa/DSALib/Characters/Critter.cs36
-rw-r--r--dsa/DSALib/Characters/Entity.cs9
-rw-r--r--dsa/DSALib/Characters/ICharacter.cs6
-rw-r--r--dsa/DSALib/Characters/ICombatant.cs6
-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
-rw-r--r--dsa/DSALib/DSA_Game/Characters/Character.cs58
-rw-r--r--dsa/DSALib/DSA_Game/Characters/NPC.cs31
-rw-r--r--dsa/DSALib/DSA_Game/Characters/SaveChar.cs18
-rw-r--r--dsa/DSALib/DSA_Game/Dsa.cs30
-rw-r--r--dsa/DSALib/DSA_Game/Save/Properties.cs33
-rw-r--r--dsa/DSALib/DSA_Game/Save/SaveCommand.cs27
-rw-r--r--dsa/DSALib/DSA_Game/Save/Session.cs24
-rw-r--r--dsa/DSALib/FireBase/Database.cs98
-rw-r--r--dsa/DSALib/Models/Database/DataObject.cs14
-rw-r--r--dsa/DSALib/Models/Database/Dsa/Advantage.cs9
-rw-r--r--dsa/DSALib/Models/Database/Dsa/CharSpell.cs9
-rw-r--r--dsa/DSALib/Models/Database/Dsa/DatabaseChar.cs15
-rw-r--r--dsa/DSALib/Models/Database/Dsa/Field.cs9
-rw-r--r--dsa/DSALib/Models/Database/Dsa/GeneralSpell.cs15
-rw-r--r--dsa/DSALib/Models/Database/Dsa/GroupChar.cs6
-rw-r--r--dsa/DSALib/Models/Database/Dsa/Inventory.cs6
-rw-r--r--dsa/DSALib/Models/Database/Dsa/Talent.cs15
-rw-r--r--dsa/DSALib/Models/Database/Dsa/Weapon.cs24
-rw-r--r--dsa/DSALib/Models/Database/Dsa/WeaponTalent.cs9
-rw-r--r--dsa/DSALib/Models/Database/Groups/DSAGroup.cs6
-rw-r--r--dsa/DSALib/Models/Database/Groups/Group.cs6
-rw-r--r--dsa/DSALib/Models/Database/IDataObject.cs6
-rw-r--r--dsa/DSALib/Models/Dsa/CritterAttack.cs11
-rw-r--r--dsa/DSALib/Models/Dsa/KampfTalent.cs11
-rw-r--r--dsa/DSALib/Models/Dsa/Talent.cs16
-rw-r--r--dsa/DSALib/Models/Dsa/Vorteil.cs10
-rw-r--r--dsa/DSALib/Models/Dsa/Zauber.cs9
-rw-r--r--dsa/DSALib/Models/Network/Command.cs6
-rw-r--r--dsa/DSALib/Models/Network/CommandResponse.cs15
58 files changed, 394 insertions, 735 deletions
diff --git a/dsa/DSALib/Auxiliary/Calculator/Argument.cs b/dsa/DSALib/Auxiliary/Calculator/Argument.cs
index e681377..d6be0c8 100644
--- a/dsa/DSALib/Auxiliary/Calculator/Argument.cs
+++ b/dsa/DSALib/Auxiliary/Calculator/Argument.cs
@@ -1,16 +1,13 @@
using System;
-namespace DSALib.Auxiliary.Calculator
-{
+namespace DSALib.Auxiliary.Calculator {
/// <summary>
/// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
/// </summary>
- public class Argument : ISolvable
- {
+ public class Argument : ISolvable {
private readonly int value;
- public Argument(string value)
- {
+ 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. ",
@@ -22,13 +19,11 @@ namespace DSALib.Auxiliary.Calculator
this.value = result;
}
- public int Solve()
- {
+ public int Solve() {
return value;
}
- public override string ToString()
- {
+ public override string ToString() {
return value.ToString();
}
}
diff --git a/dsa/DSALib/Auxiliary/Calculator/ISolvable.cs b/dsa/DSALib/Auxiliary/Calculator/ISolvable.cs
index 844e9b3..b2ea779 100644
--- a/dsa/DSALib/Auxiliary/Calculator/ISolvable.cs
+++ b/dsa/DSALib/Auxiliary/Calculator/ISolvable.cs
@@ -1,10 +1,8 @@
-namespace DSALib.Auxiliary.Calculator
-{
+namespace DSALib.Auxiliary.Calculator {
/// <summary>
/// Object has to be able to return an integer as it's value
/// </summary>
- public interface ISolvable
- {
+ public interface ISolvable {
int Solve();
}
} \ No newline at end of file
diff --git a/dsa/DSALib/Auxiliary/Calculator/Operator.cs b/dsa/DSALib/Auxiliary/Calculator/Operator.cs
index e6aeec6..f3d5c9f 100644
--- a/dsa/DSALib/Auxiliary/Calculator/Operator.cs
+++ b/dsa/DSALib/Auxiliary/Calculator/Operator.cs
@@ -1,17 +1,14 @@
using System;
using DSALibv.Auxiliary.Calculator;
-namespace DSALib.Auxiliary.Calculator
-{
+namespace DSALib.Auxiliary.Calculator {
/// <summary>
/// The Operator Class represents a binary operator with tow Arguments and an Operation type
/// </summary>
- public class Operator : ISolvable
- {
+ public class Operator : ISolvable {
private readonly ISolvable arg1, arg2;
- public Operator(ISolvable arg1, ISolvable arg2, Ops operatorType)
- {
+ public Operator(ISolvable arg1, ISolvable arg2, Ops operatorType) {
this.arg1 = arg1;
this.arg2 = arg2;
OperatorType = operatorType;
@@ -19,11 +16,9 @@ namespace DSALib.Auxiliary.Calculator
public Ops OperatorType { get; set; }
- public int Solve()
- {
+ public int Solve() {
int result;
- switch (OperatorType)
- {
+ switch (OperatorType) {
case Ops.Dice:
result = Dice.Roll(arg1.Solve(), arg2.Solve());
break;
@@ -43,8 +38,7 @@ namespace DSALib.Auxiliary.Calculator
return result;
}
- public override string ToString()
- {
+ public override string ToString() {
return $"({arg1} {OperatorType} {arg2})";
}
}
diff --git a/dsa/DSALib/Auxiliary/Calculator/Ops.cs b/dsa/DSALib/Auxiliary/Calculator/Ops.cs
index 93046d0..cf1a8e7 100644
--- a/dsa/DSALib/Auxiliary/Calculator/Ops.cs
+++ b/dsa/DSALib/Auxiliary/Calculator/Ops.cs
@@ -1,10 +1,8 @@
-namespace DSALibv.Auxiliary.Calculator
-{
+namespace DSALibv.Auxiliary.Calculator {
/// <summary>
/// The Different Operations, witch can be performed in execution-order
/// </summary>
- public enum Ops
- {
+ public enum Ops {
Dice,
Multiply,
Subtract,
diff --git a/dsa/DSALib/Auxiliary/Calculator/StringSolver.cs b/dsa/DSALib/Auxiliary/Calculator/StringSolver.cs
index 45d6a54..d46f8bc 100644
--- a/dsa/DSALib/Auxiliary/Calculator/StringSolver.cs
+++ b/dsa/DSALib/Auxiliary/Calculator/StringSolver.cs
@@ -3,24 +3,20 @@ using System.Collections.Generic;
using System.Linq;
using DSALibv.Auxiliary.Calculator;
-namespace DSALib.Auxiliary.Calculator
-{
+namespace DSALib.Auxiliary.Calculator {
/// <summary>
/// The StringSolver divides the calculation string into operations and SubStringSolvers if the string contains
/// parentheses
/// </summary>
- public class StringSolver : ISolvable
- {
+ public class StringSolver : ISolvable {
private readonly List<object> arguments = new List<object>();
private readonly string input;
- public StringSolver(string input)
- {
+ public StringSolver(string input) {
this.input = input;
}
- public int Solve()
- {
+ public int Solve() {
var workInput = "0+" + input.Replace(" ", string.Empty).ToLower();
workInput = ExpandParentheses(workInput);
@@ -34,8 +30,7 @@ namespace DSALib.Auxiliary.Calculator
return ((ISolvable) arguments.First()).Solve();
}
- public override string ToString()
- {
+ public override string ToString() {
return "(0+" + input.Replace(" ", string.Empty).ToLower() + ")";
}
@@ -43,23 +38,19 @@ namespace DSALib.Auxiliary.Calculator
GetInner(ref string input) // extract the inner bracket an remove the section from the input string
{
var depth = 0;
- for (var index = 1; index < input.Length; index++)
- {
+ for (var index = 1; index < input.Length; index++) {
var c = input[index];
- switch (c)
- {
+ switch (c) {
case '(':
depth++;
break;
case ')':
- if (depth == 0)
- {
+ if (depth == 0) {
var split = input.Substring(1, index - 1);
input = input.Substring(index + 1);
return split.Equals(string.Empty) ? "0" : split;
}
- else
- {
+ else {
depth--;
}
@@ -70,10 +61,8 @@ namespace DSALib.Auxiliary.Calculator
throw new ArgumentException("Invalid brace sequence");
}
- private static Ops GetOps(char c)
- {
- switch (c)
- {
+ private static Ops GetOps(char c) {
+ switch (c) {
case 'd':
case 'w':
return Ops.Dice;
@@ -101,14 +90,11 @@ namespace DSALib.Auxiliary.Calculator
return input;
}
- private void AtomizeOperations(string workInput)
- {
- for (var index = 0; index < workInput.Length; index++)
- {
+ private void AtomizeOperations(string workInput) {
+ for (var index = 0; index < workInput.Length; index++) {
var c = workInput[index];
- if (char.IsNumber(c))
- {
+ 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
@@ -117,8 +103,7 @@ namespace DSALib.Auxiliary.Calculator
continue;
}
- switch (c)
- {
+ switch (c) {
case ')':
throw new ArgumentException("Invalid brace sequence");
case '(':
@@ -136,12 +121,10 @@ namespace DSALib.Auxiliary.Calculator
}
}
- private void NestOperations()
- {
+ private void NestOperations() {
foreach (Ops currentOp in Enum.GetValues(typeof(Ops)))
// cycle through operators in operational order
- for (var index = 0; index < arguments.Count; index++)
- {
+ for (var index = 0; index < arguments.Count; index++) {
var arg = arguments[index];
if (arg.GetType() != typeof(Ops)) continue;
@@ -162,19 +145,16 @@ namespace DSALib.Auxiliary.Calculator
}
}
- private void HandleSpecialFormatting(ref int index, Ops op)
- {
+ private void HandleSpecialFormatting(ref int index, Ops op) {
var arg1 = arguments[index - 1];
- if (arg1.GetType() == typeof(Ops))
- {
+ if (arg1.GetType() == typeof(Ops)) {
if (op == Ops.Dice) arguments.Insert(index++, new Argument("1")); // w6 -> 1w6
if (op == Ops.Subtract) arguments.Insert(index++, new Argument("0")); // +-3 -> +0-3
}
var arg2 = arguments[index + 1]; // 3+-5 -> 3+(0-5)
- if (arg2.GetType() == typeof(Ops))
- {
+ if (arg2.GetType() == typeof(Ops)) {
arguments[index + 1] = new Operator(new Argument("0"), (ISolvable) arguments[index + 2], (Ops) arg2);
arguments.RemoveAt(index + 2);
}
diff --git a/dsa/DSALib/Auxiliary/CommandInfo.cs b/dsa/DSALib/Auxiliary/CommandInfo.cs
index d8e2188..80cc854 100644
--- a/dsa/DSALib/Auxiliary/CommandInfo.cs
+++ b/dsa/DSALib/Auxiliary/CommandInfo.cs
@@ -1,11 +1,8 @@
using System.Linq;
-namespace DSALib.Auxiliary
-{
- public struct CommandInfo
- {
- public CommandInfo(string name, string brief, string[] description, string scope)
- {
+namespace DSALib.Auxiliary {
+ public struct CommandInfo {
+ public CommandInfo(string name, string brief, string[] description, string scope) {
Name = name;
Scope = scope;
Brief = brief;
@@ -20,8 +17,7 @@ namespace DSALib.Auxiliary
public string[] Description { get; }
- public string GetDescription()
- {
+ public string GetDescription() {
return Description.Aggregate((s, c) => s + c);
}
}
diff --git a/dsa/DSALib/Auxiliary/Dice.cs b/dsa/DSALib/Auxiliary/Dice.cs
index 0bfabeb..36a4748 100644
--- a/dsa/DSALib/Auxiliary/Dice.cs
+++ b/dsa/DSALib/Auxiliary/Dice.cs
@@ -1,24 +1,22 @@
using System;
using System.Linq;
-namespace DSALib.Auxiliary
-{
+namespace DSALib.Auxiliary {
public static class Dice // roll it!
{
private static readonly Random Rnd = new Random();
- public static int Roll(int d = 20)
- {
+ public static int Roll(int d = 20) {
return Rnd.Next(d) + 1;
}
- public static int Roll(string input)
- {
+ public static int Roll(string input) {
var strings = input.ToLower().Split(new[] {'w', 'd'}, 2, StringSplitOptions.RemoveEmptyEntries).ToList();
-
+
if (strings.Count != 2)
- throw new ArgumentException($"{input}: does not satisfy the format requirements( dice count (d|w) die size)");
+ throw new ArgumentException(
+ $"{input}: does not satisfy the format requirements( dice count (d|w) die size)");
var count = Convert.ToInt32(strings[0]);
var d = Convert.ToInt32(strings[0]);
@@ -26,13 +24,11 @@ namespace DSALib.Auxiliary
return Roll(count, d);
}
- public static int Roll(int count, int d)
- {
+ public static int Roll(int count, int d) {
if (d <= 0 || count <= 0) return 0;
var sum = 0;
- for (var i = 0; i < Math.Abs(count); i++)
- {
+ for (var i = 0; i < Math.Abs(count); i++) {
var roll = Roll(d);
sum += roll;
}
diff --git a/dsa/DSALib/Auxiliary/Extensions.cs b/dsa/DSALib/Auxiliary/Extensions.cs
index 7d367a5..b4fde67 100644
--- a/dsa/DSALib/Auxiliary/Extensions.cs
+++ b/dsa/DSALib/Auxiliary/Extensions.cs
@@ -1,11 +1,8 @@
-namespace DSALib.Auxiliary
-{
- public static class StringExtension
- {
+namespace DSALib.Auxiliary {
+ public static class StringExtension {
//This mehod extends string. It adds spaces until a fixed length is reached.
//If the original string is already longer, it is returner unmodified.
- public static string AddSpaces(this string str, int length)
- {
+ public static string AddSpaces(this string str, int length) {
var temp = str;
for (var i = str.Length; i < length; i++) temp += " ";
return temp;
@@ -15,8 +12,7 @@
//This mehod extends string.
//It adds spaces at the HEAD of a string until a fixed length is reached.
//If the original string is already longer, it is returner unmodified.
- public static string AddSpacesAtHead(this string str, int length)
- {
+ public static string AddSpacesAtHead(this string str, int length) {
var temp = "";
for (var i = str.Length; i < length; i++) temp += " ";
return temp + str;
diff --git a/dsa/DSALib/Auxiliary/IDataObjectEnumerableExtension.cs b/dsa/DSALib/Auxiliary/IDataObjectEnumerableExtension.cs
index b8a6067..d695baf 100644
--- a/dsa/DSALib/Auxiliary/IDataObjectEnumerableExtension.cs
+++ b/dsa/DSALib/Auxiliary/IDataObjectEnumerableExtension.cs
@@ -1,25 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
using DSALib.Auxiliary;
using DSALib.Models.Database;
-namespace DSACore.Auxiliary
-{
- public static class DataObjectEnumerableExtension
- {
- public static IDataObject Match(this IEnumerable<IDataObject> dataObjects, string name)
- {
- return (dataObjects as IOrderedEnumerable<IDataObject> ?? throw new InvalidOperationException()).OrderBy(x => SpellCorrect.Compare(name,x.Name)).Last();
+namespace DSACore.Auxiliary {
+ public static class DataObjectEnumerableExtension {
+ public static IDataObject Match(this IEnumerable<IDataObject> dataObjects, string name) {
+ return (dataObjects as IOrderedEnumerable<IDataObject> ?? throw new InvalidOperationException())
+ .OrderBy(x => SpellCorrect.Compare(name, x.Name)).Last();
}
- public static bool TryMatch(this IEnumerable<IDataObject> dataObjects,out IDataObject data, string name)
- {
- data = (dataObjects as IOrderedEnumerable<IDataObject> ?? throw new InvalidOperationException()).OrderBy(x => SpellCorrect.Compare(name,x.Name)).Last();
+ public static bool TryMatch(this IEnumerable<IDataObject> dataObjects, out IDataObject data, string name) {
+ data = (dataObjects as IOrderedEnumerable<IDataObject> ?? throw new InvalidOperationException())
+ .OrderBy(x => SpellCorrect.Compare(name, x.Name)).Last();
return SpellCorrect.IsMatch(name, data.Name);
}
}
-}
+} \ No newline at end of file
diff --git a/dsa/DSALib/Auxiliary/RandomMisc.cs b/dsa/DSALib/Auxiliary/RandomMisc.cs
index 2723930..f78a25d 100644
--- a/dsa/DSALib/Auxiliary/RandomMisc.cs
+++ b/dsa/DSALib/Auxiliary/RandomMisc.cs
@@ -2,35 +2,29 @@
using System.Linq;
using System.Text;
-namespace DSALib.Auxiliary
-{
- public static class RandomMisc
- {
+namespace DSALib.Auxiliary {
+ public static class RandomMisc {
private static readonly Random Rand = new Random();
// use: 4w6 +4
- public static string Roll(string input)
- {
+ public static string Roll(string input) {
var output = new StringBuilder();
var strings = input.Split('w', 'd').ToList();
var count = Convert.ToInt32(strings[0]);
strings = strings[1].Split(' ').ToList();
var d = Convert.ToInt32(strings[0]);
- if (strings.Count > 0)
- {
+ if (strings.Count > 0) {
}
var sum = 0;
- for (var i = 0; i < count; i++)
- {
+ for (var i = 0; i < count; i++) {
var roll = Dice.Roll(d);
sum += roll;
output.Append("[" + roll + "] ");
}
- if (strings.Count > 1)
- {
+ if (strings.Count > 1) {
sum += Convert.ToInt32(strings[1]);
output.Append("sum: " + sum);
}
@@ -38,8 +32,7 @@ namespace DSALib.Auxiliary
return output.ToString();
}
- public static double Random(double stdDev = 1, double mean = 0)
- {
+ public static double Random(double stdDev = 1, double mean = 0) {
var u1 = Rand.NextDouble(); // uniform(0,1) random doubles
var u2 = Rand.NextDouble();
var randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
diff --git a/dsa/DSALib/Auxiliary/SpellCorrect.cs b/dsa/DSALib/Auxiliary/SpellCorrect.cs
index 79908c4..3b98942 100644
--- a/dsa/DSALib/Auxiliary/SpellCorrect.cs
+++ b/dsa/DSALib/Auxiliary/SpellCorrect.cs
@@ -1,21 +1,16 @@
-using System;
-
-namespace DSALib.Auxiliary
-{
- public class SpellCorrect
- {
- public const double ErrorThreshold = 1 / 3.0;
+namespace DSALib.Auxiliary {
+ public class SpellCorrect {
+ public const double ErrorThreshold = 1 / 3.0;
private const double Match = 3.0;
private const double Gap = -1.5;
private const double Mismatch = -2.0;
- public static double Compare(string s, string q)
- {
+ public static double Compare(string s, string q) {
s = s.ToLower();
q = q.ToLower();
int i, j;
-
+
var matrix = new double[s.Length + 1, q.Length + 1];
var max = 0.0;
matrix[0, 0] = 0.0;
@@ -27,33 +22,30 @@ namespace DSALib.Auxiliary
for (i = 1; i <= s.Length; i++)
- for (j = 1; j <= q.Length; j++)
- {
- double decay = j / (s.Length * 1000.0);
- var add = s[i - 1] == q[j - 1] ? Match - decay : Mismatch;
- var score = matrix[i - 1, j - 1] + add;
+ for (j = 1; j <= q.Length; j++) {
+ var decay = j / (s.Length * 1000.0);
+ 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 (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;
- }
+ if (i > 1 && 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;
+ }
- if (max < score && i == s.Length) max = score;
+ if (max < score && i == s.Length) max = score;
- matrix[i, j] = score;
- }
+ matrix[i, j] = score;
+ }
return max;
}
- public static bool IsMatch(string s1, string s2)
- {
+ public static bool IsMatch(string s1, string s2) {
var score = Compare(s1, s2);
return score > ErrorThreshold * s1.Length;
}
diff --git a/dsa/DSALib/Auxiliary/TalentEnumerableExtension.cs b/dsa/DSALib/Auxiliary/TalentEnumerableExtension.cs
index 6ec7fcc..fd2895b 100644
--- a/dsa/DSALib/Auxiliary/TalentEnumerableExtension.cs
+++ b/dsa/DSALib/Auxiliary/TalentEnumerableExtension.cs
@@ -5,12 +5,10 @@ using DSACore.Auxiliary;
using DSALib.DSA_Game.Characters;
using DSALib.Models.Dsa;
-namespace DSALib.Auxiliary
-{
- public static class TalentEnumerableExtension
- {
- public static string ProbenTest(this IEnumerable<Talent> List, Character c, string talentName, int erschwernis = 0)
- {
+namespace DSALib.Auxiliary {
+ public static class TalentEnumerableExtension {
+ public static string ProbenTest(this IEnumerable<Talent> List, Character c, string talentName,
+ int erschwernis = 0) {
var output = new StringBuilder();
var sc = new SpellCorrect();
@@ -34,11 +32,9 @@ namespace DSALib.Auxiliary
output.Append(" ");
tap -= erschwernis;
var gesamtErschwernis = tap;
- if (gesamtErschwernis < 0)
- {
+ if (gesamtErschwernis < 0) {
tap = 0;
- for (var i = 0; i <= 2; i++)
- {
+ for (var i = 0; i <= 2; i++) {
// foreach property, dice and tap
var temp = Dice.Roll();
var eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
@@ -50,10 +46,8 @@ namespace DSALib.Auxiliary
if (tap >= 0) tap = 1;
}
- else
- {
- for (var i = 0; i <= 2; i++)
- {
+ else {
+ for (var i = 0; i <= 2; i++) {
// foreach property, dice and tap
var temp = Dice.Roll();
var eigenschaft = c.Eigenschaften[c.PropTable[props[i]]];
diff --git a/dsa/DSALib/Auxiliary/WeaponImporter.cs b/dsa/DSALib/Auxiliary/WeaponImporter.cs
index 61eb33e..a3e7582 100644
--- a/dsa/DSALib/Auxiliary/WeaponImporter.cs
+++ b/dsa/DSALib/Auxiliary/WeaponImporter.cs
@@ -7,20 +7,16 @@ using System.Threading.Tasks;
using DSALib.FireBase;
using DSALib.Models.Database.Dsa;
-namespace DSALib.Auxiliary
-{
- public class WeaponImporter
- {
+namespace DSALib.Auxiliary {
+ public class WeaponImporter {
private readonly List<RangedWeapon> Range = new List<RangedWeapon>();
private readonly List<MeleeWeapon> Weapons = new List<MeleeWeapon>();
- public async Task DownloadWeapons()
- {
+ public async Task DownloadWeapons() {
var client = new HttpClient();
- for (var 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);
@@ -35,15 +31,13 @@ namespace DSALib.Auxiliary
var ids = new List<int>();
foreach (var matchGroup in talentMatch.ToList())
- if (matchGroup.Success)
- {
+ if (matchGroup.Success) {
lines.Add(matchGroup.Groups[3].Value);
ids.Add(int.Parse(matchGroup.Groups[1].Value));
}
- for (var 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 + "/" +
@@ -71,18 +65,15 @@ namespace DSALib.Auxiliary
Console.ReadLine();
}
- private async Task AddMelee(int i, string talent, List<string> matches)
- {
+ private async Task AddMelee(int i, string talent, List<string> matches) {
var name = talent.Replace(' ', '_').Replace(".", "");
- if (!matches[1].Equals(string.Empty))
- {
+ if (!matches[1].Equals(string.Empty)) {
var temp = new MeleeWeapon(
name,
matches[1],
int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
- matches[11])
- {
+ matches[11]) {
INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
@@ -111,15 +102,13 @@ namespace DSALib.Auxiliary
await Database.AddWeapon(range);
return;
}*/
- if (i > 18)
- {
+ if (i > 18) {
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
- matches[11])
- {
+ matches[11]) {
AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
@@ -131,18 +120,15 @@ namespace DSALib.Auxiliary
}
}
- private async Task AddRanged(int i, string talent, List<string> matches)
- {
+ private async Task AddRanged(int i, string talent, List<string> matches) {
var name = talent.Replace(' ', '_').Replace(".", "");
- if (!matches[1].Equals(string.Empty))
- {
+ if (!matches[1].Equals(string.Empty)) {
var temp = new MeleeWeapon(
name,
matches[1],
int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
- matches[11])
- {
+ matches[11]) {
INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
@@ -152,15 +138,13 @@ namespace DSALib.Auxiliary
await Database.AddWeapon(temp);
}
- if (i > 18)
- {
+ if (i > 18) {
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
- matches[11])
- {
+ matches[11]) {
AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
diff --git a/dsa/DSALib/Characters/Being.cs b/dsa/DSALib/Characters/Being.cs
index 27879a1..147bc54 100644
--- a/dsa/DSALib/Characters/Being.cs
+++ b/dsa/DSALib/Characters/Being.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Characters
-{
- public class Being : Entity
- {
+namespace DSALib.Characters {
+ public class Being : Entity {
public int Lebenspunkte_Basis { get; set; } = 30;
public int Lebenspunkte_Aktuell { get; set; } = 30;
diff --git a/dsa/DSALib/Characters/Critter.cs b/dsa/DSALib/Characters/Critter.cs
index dcedccb..e3a39a6 100644
--- a/dsa/DSALib/Characters/Critter.cs
+++ b/dsa/DSALib/Characters/Critter.cs
@@ -5,14 +5,11 @@ using DiscoBot.DSA_Game.Characters;
using DSALib.Models.Dsa;
using Newtonsoft.Json;
-namespace DSALib.Characters
-{
- public class Critter : Being, ICombatant
- {
+namespace DSALib.Characters {
+ public class Critter : Being, ICombatant {
public CritterAttack lastAttack;
- public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks)
- {
+ public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks) {
Gw = gw;
Gs = gs;
Rs = rs;
@@ -24,8 +21,7 @@ namespace DSALib.Characters
lastAttack = CritterAttacks[new Random().Next(critterAttacks.Count)];
}
- public Critter()
- {
+ public Critter() {
}
public int Rs { get; set; }
@@ -46,41 +42,33 @@ namespace DSALib.Characters
public List<CritterAttack> CritterAttacks { get; set; }
- public string Angriff(string talent, int erschwernis = 0)
- {
+ public string Angriff(string talent, int erschwernis = 0) {
throw new NotImplementedException();
}
- public string Parade(string talent, int erschwernis = 0)
- {
+ public string Parade(string talent, int erschwernis = 0) {
throw new NotImplementedException();
}
- public static Critter Load(string path)
- {
- try
- {
+ public static Critter Load(string path) {
+ try {
return
JsonConvert.DeserializeObject<Critter>(
File.ReadAllText(path)); // Deserialize Data and create Session Object
}
- catch (Exception e)
- {
+ catch (Exception e) {
Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen." + e);
return null;
}
}
- public void Save(string path = @"..\..\Critters\")
- {
- try
- {
+ public void Save(string path = @"..\..\Critters\") {
+ try {
File.WriteAllText(path + Name + ".json",
JsonConvert.SerializeObject(this,
Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
- catch (Exception e)
- {
+ catch (Exception e) {
Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen." + e);
}
}
diff --git a/dsa/DSALib/Characters/Entity.cs b/dsa/DSALib/Characters/Entity.cs
index a8a5e81..cd65b27 100644
--- a/dsa/DSALib/Characters/Entity.cs
+++ b/dsa/DSALib/Characters/Entity.cs
@@ -1,11 +1,8 @@
-namespace DSALib.Characters
-{
- public class Entity
- {
+namespace DSALib.Characters {
+ public class Entity {
public string Name { get; set; }
- public override string ToString()
- {
+ public override string ToString() {
return Name;
}
}
diff --git a/dsa/DSALib/Characters/ICharacter.cs b/dsa/DSALib/Characters/ICharacter.cs
index 256fecd..72a3b30 100644
--- a/dsa/DSALib/Characters/ICharacter.cs
+++ b/dsa/DSALib/Characters/ICharacter.cs
@@ -1,9 +1,7 @@
using DiscoBot.DSA_Game.Characters;
-namespace DSALib.Characters
-{
- public interface ICharacter : ICombatant
- {
+namespace DSALib.Characters {
+ public interface ICharacter : ICombatant {
string TestTalent(string talent, int erschwernis = 0);
string TestEigenschaft(string eigenschaft, int erschwernis = 0);
diff --git a/dsa/DSALib/Characters/ICombatant.cs b/dsa/DSALib/Characters/ICombatant.cs
index a4ce601..ec0b8b5 100644
--- a/dsa/DSALib/Characters/ICombatant.cs
+++ b/dsa/DSALib/Characters/ICombatant.cs
@@ -1,7 +1,5 @@
-namespace DiscoBot.DSA_Game.Characters
-{
- public interface ICombatant
- {
+namespace DiscoBot.DSA_Game.Characters {
+ public interface ICombatant {
string Name { get; set; }
int Lebenspunkte_Basis { get; set; }
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)
diff --git a/dsa/DSALib/DSA_Game/Characters/Character.cs b/dsa/DSALib/DSA_Game/Characters/Character.cs
index aea5671..3e4022e 100644
--- a/dsa/DSALib/DSA_Game/Characters/Character.cs
+++ b/dsa/DSALib/DSA_Game/Characters/Character.cs
@@ -9,12 +9,9 @@ using DSALib.Auxiliary;
using DSALib.Characters;
using DSALib.Models.Dsa;
-namespace DSALib.DSA_Game.Characters
-{
- public class Character : Being, ICharacter
- {
- public Character()
- {
+namespace DSALib.DSA_Game.Characters {
+ public class Character : Being, ICharacter {
+ public Character() {
PropTable.Add("MU", "Mut"); // routing
PropTable.Add("KL", "Klugheit");
PropTable.Add("IN", "Intuition");
@@ -25,20 +22,17 @@ namespace DSALib.DSA_Game.Characters
PropTable.Add("KK", "Körperkraft");
}
- public Character(string path) : this()
- {
+ public Character(string path) : this() {
Load(new MemoryStream(File.ReadAllBytes(path))); // load
Post_process(); // calculate derived values
}
- public Character(MemoryStream stream) : this()
- {
+ public Character(MemoryStream stream) : this() {
Load(stream); // load
Post_process(); // calculate derived values
}
- public Character(Character c, string name, int stDv = 2) : this()
- {
+ public Character(Character c, string name, int stDv = 2) : this() {
Name = name;
foreach (var i in c.Eigenschaften)
Eigenschaften.Add(i.Key, i.Value + (int) Math.Round(RandomMisc.Random(stDv)));
@@ -82,8 +76,7 @@ namespace DSALib.DSA_Game.Characters
return Zauber.ProbenTest(this, zauber, erschwernis);
}
- public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
- {
+ public string TestEigenschaft(string eigenschaft, int erschwernis = 0) {
var output = new StringBuilder();
var prop = PropTable[eigenschaft.ToUpper()];
var tap = Eigenschaften[prop];
@@ -115,11 +108,10 @@ namespace DSALib.DSA_Game.Characters
return output.ToString();
}
- public string Parade(string talent, int erschwernis = 0)
- {
+ public string Parade(string talent, int erschwernis = 0) {
var output = new StringBuilder();
- if (Kampftalente.TryMatch(out var iAttack , talent))
+ if (Kampftalente.TryMatch(out var iAttack, talent))
return $"{Name} kann nicht mit der Waffenart {talent} umgehen...";
@@ -136,11 +128,10 @@ namespace DSALib.DSA_Game.Characters
return output.ToString();
}
- public string Fernkampf(string talent, int erschwernis = 0)
- {
+ public string Fernkampf(string talent, int erschwernis = 0) {
var output = new StringBuilder();
var fk = Eigenschaften["fk"];
- if (! Talente.TryMatch(out var iAttack, talent))
+ if (!Talente.TryMatch(out var iAttack, talent))
return $"{Name} kann nicht mit der Waffenart {talent} umgehen...";
var attack = (Talent) iAttack;
@@ -157,8 +148,7 @@ namespace DSALib.DSA_Game.Characters
return output.ToString();
}
- private void Post_process()
- {
+ private void Post_process() {
var LE_Wert = Eigenschaften["Lebensenergie"];
var AE_Wert = Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value;
@@ -184,16 +174,13 @@ namespace DSALib.DSA_Game.Characters
}
- private void Load(MemoryStream stream)
- {
+ private void Load(MemoryStream stream) {
var reader = new XmlTextReader(stream);
- while (reader.Read())
- {
+ while (reader.Read()) {
// read until he hits keywords
if (reader.NodeType != XmlNodeType.Element) continue;
- switch (reader.Name)
- {
+ switch (reader.Name) {
case "Wesen":
reader.Skip();
break;
@@ -208,17 +195,14 @@ namespace DSALib.DSA_Game.Characters
break;
case "vt":
reader.Read();
- while (reader.Name.Equals("vorteil"))
- {
- try
- {
+ while (reader.Name.Equals("vorteil")) {
+ try {
Vorteile.Add(new Vorteil(
reader.GetAttribute("name"),
// Convert.ToInt32(reader.GetAttribute("value"))));
reader.GetAttribute("value")));
}
- catch
- {
+ catch {
Vorteile.Add(new Vorteil(reader.GetAttribute("name")));
}
@@ -228,8 +212,7 @@ namespace DSALib.DSA_Game.Characters
break;
case "talentliste":
reader.Read();
- while (reader.Name.Equals("talent"))
- {
+ while (reader.Name.Equals("talent")) {
Talente.Add(
new Talent(
reader.GetAttribute("name"),
@@ -241,8 +224,7 @@ namespace DSALib.DSA_Game.Characters
break;
case "zauberliste":
reader.Read();
- while (reader.Name.Equals("zauber"))
- {
+ while (reader.Name.Equals("zauber")) {
Zauber.Add(
new Zauber(
reader.GetAttribute("name"),
diff --git a/dsa/DSALib/DSA_Game/Characters/NPC.cs b/dsa/DSALib/DSA_Game/Characters/NPC.cs
index 105adda..6bcde0c 100644
--- a/dsa/DSALib/DSA_Game/Characters/NPC.cs
+++ b/dsa/DSALib/DSA_Game/Characters/NPC.cs
@@ -1,24 +1,18 @@
using System;
using DSALib.Auxiliary;
-using DSALib.Characters;
-namespace DSALib.Characters
-{
- public class Npc : Being, ICharacter
- {
+namespace DSALib.Characters {
+ public class Npc : Being, ICharacter {
private readonly int mean, stDv;
- public Npc(string name, int mean, int stDv)
- {
+ public Npc(string name, int mean, int stDv) {
this.mean = mean;
this.stDv = stDv;
Name = name;
}
- public string TestTalent(string talent, int tap = 3)
- {
- for (var i = 0; i <= 2; i++)
- {
+ public string TestTalent(string talent, int tap = 3) {
+ for (var i = 0; i <= 2; i++) {
// foreach property, dice and tap
var temp = Dice.Roll();
var eigenschaft = (int) Math.Round(RandomMisc.Random(stDv, mean));
@@ -32,8 +26,7 @@ namespace DSALib.Characters
return $"{Name} scheitert an {talent}";
}
- public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
- {
+ public string TestEigenschaft(string eigenschaft, int erschwernis = 0) {
var temp = Dice.Roll();
var prop = (int) Math.Round(RandomMisc.Random(stDv, stDv));
@@ -42,8 +35,7 @@ namespace DSALib.Characters
return $"{Name} scheitert an {eigenschaft}";
}
- public string Angriff(string waffe, int erschwernis = 0)
- {
+ public string Angriff(string waffe, int erschwernis = 0) {
var temp = Dice.Roll();
if (temp == 1) return $"{Name} greift kritisch mit {waffe} an";
@@ -53,8 +45,7 @@ namespace DSALib.Characters
return $"{Name} haut mit {waffe} daneben";
}
- public string Parade(string waffe, int erschwernis = 0)
- {
+ public string Parade(string waffe, int erschwernis = 0) {
var temp = Dice.Roll();
if (temp == 1) return $"{Name} pariert mit {waffe} meisterlich";
@@ -64,8 +55,7 @@ namespace DSALib.Characters
return $"{Name} schafft es nicht mit {waffe} zu parieren";
}
- public string Fernkampf(string waffe, int erschwernis = 0)
- {
+ public string Fernkampf(string waffe, int erschwernis = 0) {
var temp = Dice.Roll();
if (temp == 1) return $"{Name} trifft kritisch mit {waffe}";
@@ -75,8 +65,7 @@ namespace DSALib.Characters
return $"{Name} schießt mit {waffe} daneben";
}
- public string TestZauber(string zauber, int erschwernis)
- {
+ public string TestZauber(string zauber, int erschwernis) {
return TestTalent(zauber, erschwernis);
}
}
diff --git a/dsa/DSALib/DSA_Game/Characters/SaveChar.cs b/dsa/DSALib/DSA_Game/Characters/SaveChar.cs
index 00e2f86..b3c4fcd 100644
--- a/dsa/DSALib/DSA_Game/Characters/SaveChar.cs
+++ b/dsa/DSALib/DSA_Game/Characters/SaveChar.cs
@@ -1,9 +1,7 @@
using DSALib.Characters;
-namespace DSALib.DSA_Game.Characters
-{
- public class SaveChar
- {
+namespace DSALib.DSA_Game.Characters {
+ public class SaveChar {
public string Name { get; set; }
public int Lebenspunkte_Aktuell { get; set; }
@@ -12,10 +10,8 @@ namespace DSALib.DSA_Game.Characters
public int Astralpunkte_Aktuell { get; set; }
- public static SaveChar FromICharacter(ICharacter c)
- {
- return new SaveChar
- {
+ public static SaveChar FromICharacter(ICharacter c) {
+ return new SaveChar {
Astralpunkte_Aktuell = c.Astralpunkte_Aktuell,
Ausdauer_Aktuell = c.Ausdauer_Aktuell,
Lebenspunkte_Aktuell = c.Lebenspunkte_Aktuell,
@@ -25,10 +21,8 @@ namespace DSALib.DSA_Game.Characters
}
- public static class ICharExtension
- {
- public static void Update(this ICharacter c, SaveChar s)
- {
+ public static class ICharExtension {
+ public static void Update(this ICharacter c, SaveChar s) {
c.Astralpunkte_Aktuell = s.Astralpunkte_Aktuell;
c.Ausdauer_Aktuell = s.Ausdauer_Aktuell;
c.Lebenspunkte_Aktuell = s.Lebenspunkte_Aktuell;
diff --git a/dsa/DSALib/DSA_Game/Dsa.cs b/dsa/DSALib/DSA_Game/Dsa.cs
index bcd8951..42be212 100644
--- a/dsa/DSALib/DSA_Game/Dsa.cs
+++ b/dsa/DSALib/DSA_Game/Dsa.cs
@@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using DSALib.Characters;
using DSALib.DSA_Game.Characters;
using DSALib.DSA_Game.Save;
-using DSALib;
-using DSALib.Characters;
using DSALib.Models.Dsa;
-namespace DSALib.DSA_Game
-{
- public static class Dsa
- {
+namespace DSALib.DSA_Game {
+ public static class Dsa {
#if DEBUG
public const string
rootPath = ""; //"C:\\Users\\Dennis\\Source\\Repos\\DiscoBot\\DSALib\\";//"DiscoBot\\DSALib\\";
@@ -25,23 +22,19 @@ namespace DSALib.DSA_Game
public static List<Zauber> Zauber { get; set; } = new List<Zauber>();
- public static Session Session
- {
- get
- {
+ public static Session Session {
+ get {
s_session.Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList();
return s_session;
}
- set
- {
+ set {
s_session = value;
foreach (var x in value.Chars) Chars.Find(c => c.Name.Equals(x.Name)).Update(x);
}
}
- public static void Startup()
- {
+ public static void Startup() {
//new .Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
/*Session = new Session();*/
// relation.Add("Papo", "Pump aus der Gosse");
@@ -75,20 +68,17 @@ namespace DSALib.DSA_Game
//new WeaponImporter().DownloadWeapons().Wait();
- Session = new Session
- {
+ Session = new Session {
Chars = Chars.Select(SaveChar.FromICharacter).ToList()
};
//Session.Save();
}
- public static ICharacter GetCharacter(ulong id)
- {
+ public static ICharacter GetCharacter(ulong id) {
throw new NotImplementedException();
}
- public static ICharacter GetCharacter(string name, ulong groupId)
- {
+ public static ICharacter GetCharacter(string name, ulong groupId) {
throw new NotImplementedException();
}
}
diff --git a/dsa/DSALib/DSA_Game/Save/Properties.cs b/dsa/DSALib/DSA_Game/Save/Properties.cs
index 2312af0..06628ed 100644
--- a/dsa/DSALib/DSA_Game/Save/Properties.cs
+++ b/dsa/DSALib/DSA_Game/Save/Properties.cs
@@ -6,33 +6,27 @@ using System.Linq;
using DSALib.Auxiliary;
using Newtonsoft.Json;
-namespace DSALib.DSA_Game.Save
-{
- public static class Properties
- {
+namespace DSALib.DSA_Game.Save {
+ public static class Properties {
public static Dictionary<string, object> objects;
- static Properties()
- {
+ static Properties() {
objects = new Dictionary<string, object>();
/*this.objects.Add("Sounds", new List<Sound>());
this.objects.Add("CommandInfos", new List<CommandInfo>());*/
}
- public static List<CommandInfo> CommandInfos
- {
+ public static List<CommandInfo> CommandInfos {
get => objects["CommandInfo"] as List<CommandInfo>;
set => objects["CommandInfo"] = value;
} // use Properties.Commandinfos to access the abstract Object array
- public static void Deserialize(string path = @"Properties")
- {
+ public static void Deserialize(string path = @"Properties") {
var files = Directory.GetFiles(path, "*.json");
foreach (var file in files)
- try
- {
+ try {
var name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
var data = File.ReadAllText(file);
var type = Type.GetType(name);
@@ -41,19 +35,15 @@ namespace DSALib.DSA_Game.Save
var o = JsonConvert.DeserializeObject(data, type);
objects.Add(name.Split('.').Last(), o);
}
- catch (Exception e)
- {
+ catch (Exception e) {
// ignored
Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e);
}
}
- public static void Serialize(string path = @"..\..\Properties\")
- {
- try
- {
- foreach (var o in objects)
- {
+ public static void Serialize(string path = @"..\..\Properties\") {
+ try {
+ foreach (var o in objects) {
var assembly = o.Value is IList list
? list[0]?.GetType().FullName
: o.Value.GetType().FullName;
@@ -64,8 +54,7 @@ namespace DSALib.DSA_Game.Save
Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
// ignored
Console.WriteLine("Speichern von Save-File fehlgeschlagen." + e);
}
diff --git a/dsa/DSALib/DSA_Game/Save/SaveCommand.cs b/dsa/DSALib/DSA_Game/Save/SaveCommand.cs
index c5a1bb4..0153779 100644
--- a/dsa/DSALib/DSA_Game/Save/SaveCommand.cs
+++ b/dsa/DSALib/DSA_Game/Save/SaveCommand.cs
@@ -2,14 +2,10 @@
using System.IO;
using System.Linq;
-namespace DSALib.DSA_Game.Save
-{
- public class SaveCommand
- {
- public void LoadSession(string name = "")
- {
- if (name.Equals("?") || name.Equals(string.Empty))
- {
+namespace DSALib.DSA_Game.Save {
+ public class SaveCommand {
+ public void LoadSession(string name = "") {
+ if (name.Equals("?") || name.Equals(string.Empty)) {
Console.WriteLine("Gespeicherte Sessions:");
Console.WriteLine(ListSessions());
return;
@@ -24,27 +20,23 @@ namespace DSALib.DSA_Game.Save
Console.WriteLine($"{name} wurde geladen");
}
- public void SessionSave(string name = "")
- {
+ public void SessionSave(string name = "") {
//var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif");
- if (name.Equals("?") || name.Equals(string.Empty))
- {
+ if (name.Equals("?") || name.Equals(string.Empty)) {
Console.WriteLine("Gespeicherte Sessions:");
Console.WriteLine(ListSessions());
return;
}
var path = Session.DirectoryPath + @"\" + name;
- if (Directory.Exists(path))
- {
+ if (Directory.Exists(path)) {
var files = Directory.GetFiles(path);
var current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First()));
Dsa.Session.SessionName = name;
Dsa.Session.Save(path + "\\" + name + $"-{++current}.json");
}
- else
- {
+ else {
Directory.CreateDirectory(path);
Dsa.Session.SessionName = name;
Dsa.Session.Save(path + "\\" + name + "-0.json");
@@ -54,8 +46,7 @@ namespace DSALib.DSA_Game.Save
//await sendFile;
}
- private string[] ListSessions()
- {
+ private string[] ListSessions() {
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;
diff --git a/dsa/DSALib/DSA_Game/Save/Session.cs b/dsa/DSALib/DSA_Game/Save/Session.cs
index 62aa8f6..bd36bf8 100644
--- a/dsa/DSALib/DSA_Game/Save/Session.cs
+++ b/dsa/DSALib/DSA_Game/Save/Session.cs
@@ -4,10 +4,8 @@ using System.IO;
using DSALib.DSA_Game.Characters;
using Newtonsoft.Json;
-namespace DSALib.DSA_Game.Save
-{
- public class Session
- {
+namespace DSALib.DSA_Game.Save {
+ public class Session {
public static string DirectoryPath { get; set; } = Dsa.rootPath + @"sessions";
public Dictionary<string, string> Relation { get; set; } =
@@ -17,32 +15,26 @@ namespace DSALib.DSA_Game.Save
public string SessionName { get; set; }
- public static Session Load(string path)
- {
- try
- {
+ public static Session Load(string path) {
+ try {
return
JsonConvert.DeserializeObject<Session>(
File.ReadAllText(path)); // Deserialize Data and create Session Object
}
- catch (Exception e)
- {
+ catch (Exception e) {
// ignored
Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen." + e);
return null;
}
}
- public void Save(string path)
- {
- try
- {
+ public void Save(string path) {
+ try {
File.WriteAllText(path,
JsonConvert.SerializeObject(this,
Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
- catch (Exception e)
- {
+ catch (Exception e) {
Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen.\n" + e);
// ignored
}
diff --git a/dsa/DSALib/FireBase/Database.cs b/dsa/DSALib/FireBase/Database.cs
index 1edd699..585b6d0 100644
--- a/dsa/DSALib/FireBase/Database.cs
+++ b/dsa/DSALib/FireBase/Database.cs
@@ -2,56 +2,51 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSALib.DSA_Game;
using DSALib.DSA_Game.Characters;
using DSALib.Models.Database.Dsa;
+using DSALib.Models.Database.Groups;
using Firebase.Database;
using Firebase.Database.Query;
-namespace DSALib.FireBase
-{
- public static class Database
- {
- public static FirebaseClient Firebase;
+namespace DSALib.FireBase {
+ public static class Database {
+ private static readonly FirebaseClient Firebase;
- public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
+ private static readonly Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
- public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
+ private static readonly Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
- public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
+ private static readonly Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
- public static Dictionary<string, DSALib.Models.Database.Dsa.Talent> Talents = new Dictionary<string, DSALib.Models.Database.Dsa.Talent>();
+ private static readonly Dictionary<string, Talent> Talents = new Dictionary<string, Talent>();
- public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
+ private static readonly Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
- static Database()
- {
+ static Database() {
var auth = File.ReadAllText(Dsa.rootPath + "Token"); // your app secret
Firebase = new FirebaseClient(
"https://heldenonline-4d828.firebaseio.com/",
- new FirebaseOptions
- {
+ new FirebaseOptions {
AuthTokenAsyncFactory = () => Task.FromResult(auth)
});
- Task.Run(Initialize);
+ Task.Run((Action) Initialize);
}
- private static void Initialize() {
+ private static void Initialize() {
var waiting = new[] {
// ToDo IntializeCollection("Chars", Chars),
IntializeCollection("MeleeWeapons", MeleeList),
IntializeCollection("RangedWeapons", RangedWeapons),
IntializeCollection("Talents", Talents),
- IntializeCollection("Spells", Spells),
+ IntializeCollection("Spells", Spells)
};
Task.WaitAll(waiting);
}
- private static async Task IntializeCollection<T>(string path, Dictionary<string, T> list)
- {
+ private static async Task IntializeCollection<T>(string path, Dictionary<string, T> list) {
var temp = await Firebase
.Child(path)
.OrderByKey()
@@ -60,8 +55,7 @@ namespace DSALib.FireBase
foreach (var firebaseObject in temp) list.Add(firebaseObject.Key, firebaseObject.Object);
}
- public static async Task<int> AddChar(Character file, string group)
- {
+ public static async Task<int> AddChar(Character file, string group) {
DatabaseChar.LoadChar(file, out var groupChar, out var data);
var lastChar = await Firebase
@@ -91,8 +85,7 @@ namespace DSALib.FireBase
return id + 1;
}
- public static async Task RemoveChar(int id)
- {
+ public static async Task RemoveChar(int id) {
await Firebase
.Child("Groups")
.Child("Char" + id)
@@ -111,8 +104,7 @@ namespace DSALib.FireBase
.DeleteAsync();
}
- public static DatabaseChar GetChar(int id)
- {
+ public static DatabaseChar GetChar(int id) {
/*var chr = await firebase
.Child("Chars")
.Child("Char" + id)
@@ -121,8 +113,7 @@ namespace DSALib.FireBase
return Chars["Char" + id];
}
- public static async Task<Inventory> GetInventory(int id)
- {
+ public static async Task<Inventory> GetInventory(int id) {
var inv = await Firebase
.Child("Inventories")
.Child("Inventory" + id)
@@ -130,32 +121,28 @@ namespace DSALib.FireBase
return inv;
}
- public static async Task SetInventory(int id, Inventory inv)
- {
+ public static async Task SetInventory(int id, Inventory inv) {
await Firebase
.Child("Inventories")
.Child("Inventory" + id)
.PutAsync(inv);
}
- public static async Task AddTalent(DSALib.Models.Database.Dsa.Talent tal)
- {
+ public static async Task AddTalent(Talent tal) {
await Firebase
.Child("Talents")
.Child(tal.Name)
.PutAsync(tal);
}
- public static async Task RemoveTalent(string talent)
- {
+ public static async Task RemoveTalent(string talent) {
await Firebase
.Child("Talents")
.Child(talent)
.DeleteAsync();
}
- public static DSALib.Models.Database.Dsa.Talent GetTalent(string talent)
- {
+ public static Talent GetTalent(string talent) {
/*
return await firebase
.Child("Talents")
@@ -164,30 +151,26 @@ namespace DSALib.FireBase
return Talents[talent];
}
- public static async Task AddSpell(GeneralSpell tal)
- {
+ public static async Task AddSpell(GeneralSpell tal) {
await Firebase
.Child("Spells")
.Child(tal.Name)
.PutAsync(tal);
}
- public static async Task RemoveSpell(string spell)
- {
+ public static async Task RemoveSpell(string spell) {
await Firebase
.Child("Spells")
.Child(spell)
.DeleteAsync();
}
- public static GeneralSpell GetSpell(string spell)
- {
+ public static GeneralSpell GetSpell(string spell) {
return Spells[spell];
}
- public static async Task AddWeapon(Weapon wep)
- {
+ public static async Task AddWeapon(Weapon wep) {
var collection = wep.GetType() == typeof(MeleeWeapon) ? "MeleeWeapons" : "RangedWeapons";
await Firebase
.Child(collection)
@@ -195,8 +178,7 @@ namespace DSALib.FireBase
.PutAsync(wep);
}
- public static async Task RemoveWeapon(string weapon, bool ranged = false)
- {
+ public static async Task RemoveWeapon(string weapon, bool ranged = false) {
var collection = ranged ? "RangedWeapons" : "MeleeWeapons";
await Firebase
.Child(collection)
@@ -204,8 +186,7 @@ namespace DSALib.FireBase
.DeleteAsync();
}
- public static async Task<Weapon> GetWeapon(string weapon, bool ranged = false)
- {
+ public static async Task<Weapon> GetWeapon(string weapon, bool ranged = false) {
var collection = ranged ? "RangedWeapons" : "MeleeWeapons";
return await Firebase
.Child(collection)
@@ -213,12 +194,11 @@ namespace DSALib.FireBase
.OnceSingleAsync<Weapon>();
}
- public static async Task<List<Tuple<string, string>>> GetGroups()
- {
+ public static async Task<List<Tuple<string, string>>> GetGroups() {
var groups = await Firebase
.Child("Groups")
.OrderByKey()
- .OnceAsync<DSALib.Models.Database.Groups.Group>();
+ .OnceAsync<Group>();
var ret = new List<Tuple<string, string>>();
foreach (var firebaseObject in groups)
@@ -227,22 +207,20 @@ namespace DSALib.FireBase
return ret;
}
- public static async Task<DSALib.Models.Database.Groups.Group> GetGroup(int id)
- {
+ public static async Task<Group> GetGroup(int id) {
var group = await Firebase
.Child("Groups")
.Child("Group" + id)
- .OnceSingleAsync<DSALib.Models.Database.Groups.Group>();
+ .OnceSingleAsync<Group>();
return group;
}
- public static async Task AddGroup(DSALib.Models.Database.Groups.Group group)
- {
+ public static async Task AddGroup(Group group) {
var lastChar = await Firebase
.Child("Groups")
.OrderByKey()
.LimitToLast(1)
- .OnceAsync<DSALib.Models.Database.Groups.Group>();
+ .OnceAsync<Group>();
var id = group.Id = lastChar.First().Object.Id + 1;
await Firebase
@@ -251,16 +229,14 @@ namespace DSALib.FireBase
.PutAsync(group);
}
- public static async void SetGroup(DSALib.Models.Database.Groups.Group group)
- {
+ public static async void SetGroup(Group group) {
await Firebase
.Child("Groups")
.Child("Group" + group.Id)
.PutAsync(group);
}
- public static async void DeleteGroup(int id)
- {
+ public static async void DeleteGroup(int id) {
await Firebase
.Child("Groups")
.Child("Group" + id)
diff --git a/dsa/DSALib/Models/Database/DataObject.cs b/dsa/DSALib/Models/Database/DataObject.cs
index 59cfdf2..ca6d6b2 100644
--- a/dsa/DSALib/Models/Database/DataObject.cs
+++ b/dsa/DSALib/Models/Database/DataObject.cs
@@ -1,13 +1,9 @@
-namespace DSALib.Models.Database
-{
- public class DataObject : IDataObject
- {
+namespace DSALib.Models.Database {
+ public class DataObject : IDataObject {
+ public string Name { get; set; }
- public override string ToString()
- {
+ public override string ToString() {
return Name;
}
-
- public string Name { get; set; }
}
-}
+} \ No newline at end of file
diff --git a/dsa/DSALib/Models/Database/Dsa/Advantage.cs b/dsa/DSALib/Models/Database/Dsa/Advantage.cs
index 2ed0bf9..1a3d40b 100644
--- a/dsa/DSALib/Models/Database/Dsa/Advantage.cs
+++ b/dsa/DSALib/Models/Database/Dsa/Advantage.cs
@@ -1,11 +1,8 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class Advantage
- {
- public Advantage(string name, string value = "")
- {
+namespace DSALib.Models.Database.Dsa {
+ public class Advantage {
+ public Advantage(string name, string value = "") {
Name = name ?? throw new ArgumentNullException(nameof(name));
Value = value ?? throw new ArgumentNullException(nameof(value));
}
diff --git a/dsa/DSALib/Models/Database/Dsa/CharSpell.cs b/dsa/DSALib/Models/Database/Dsa/CharSpell.cs
index d08bc74..4486004 100644
--- a/dsa/DSALib/Models/Database/Dsa/CharSpell.cs
+++ b/dsa/DSALib/Models/Database/Dsa/CharSpell.cs
@@ -1,11 +1,8 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class CharSpell
- {
- public CharSpell(string representation, int value)
- {
+namespace DSALib.Models.Database.Dsa {
+ public class CharSpell {
+ public CharSpell(string representation, int value) {
this.representation = representation ?? throw new ArgumentNullException(nameof(representation));
this.value = value;
}
diff --git a/dsa/DSALib/Models/Database/Dsa/DatabaseChar.cs b/dsa/DSALib/Models/Database/Dsa/DatabaseChar.cs
index 1312f95..2b163a4 100644
--- a/dsa/DSALib/Models/Database/Dsa/DatabaseChar.cs
+++ b/dsa/DSALib/Models/Database/Dsa/DatabaseChar.cs
@@ -3,17 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using DSALib.DSA_Game.Characters;
-namespace DSALib.Models.Database.Dsa
-{
- public class DatabaseChar
- {
- public DatabaseChar()
- {
+namespace DSALib.Models.Database.Dsa {
+ public class DatabaseChar {
+ public DatabaseChar() {
}
public DatabaseChar(int id, string name, string rasse, List<Field> skills, List<Field> talents,
- List<Advantage> advantages, List<CharSpell> spells, List<WeaponTalent> weaponTalents)
- {
+ List<Advantage> advantages, List<CharSpell> spells, List<WeaponTalent> weaponTalents) {
Id = id;
Name = name ?? throw new ArgumentNullException(nameof(name));
Race = rasse ?? throw new ArgumentNullException(nameof(rasse));
@@ -41,8 +37,7 @@ namespace DSALib.Models.Database.Dsa
public List<WeaponTalent> WeaponTalents { get; set; } = new List<WeaponTalent>();
- public static void LoadChar(Character file, out GroupChar group, out DatabaseChar data)
- {
+ public static void LoadChar(Character file, out GroupChar group, out DatabaseChar data) {
group = new GroupChar();
data = new DatabaseChar();
diff --git a/dsa/DSALib/Models/Database/Dsa/Field.cs b/dsa/DSALib/Models/Database/Dsa/Field.cs
index 6d1b82e..f720318 100644
--- a/dsa/DSALib/Models/Database/Dsa/Field.cs
+++ b/dsa/DSALib/Models/Database/Dsa/Field.cs
@@ -1,11 +1,8 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class Field
- {
- public Field(string name, int value = 0)
- {
+namespace DSALib.Models.Database.Dsa {
+ public class Field {
+ public Field(string name, int value = 0) {
Name = name ?? throw new ArgumentNullException(nameof(name));
Value = value;
}
diff --git a/dsa/DSALib/Models/Database/Dsa/GeneralSpell.cs b/dsa/DSALib/Models/Database/Dsa/GeneralSpell.cs
index 964c38e..6e1ecf1 100644
--- a/dsa/DSALib/Models/Database/Dsa/GeneralSpell.cs
+++ b/dsa/DSALib/Models/Database/Dsa/GeneralSpell.cs
@@ -1,20 +1,15 @@
-namespace DSALib.Models.Database.Dsa
-{
- public class GeneralSpell : Talent
- {
+namespace DSALib.Models.Database.Dsa {
+ public class GeneralSpell : Talent {
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;
}
- public GeneralSpell(string name, string roll) : base(name, roll)
- {
+ public GeneralSpell(string name, string roll) : base(name, roll) {
}
- public GeneralSpell()
- {
+ public GeneralSpell() {
}
}
} \ No newline at end of file
diff --git a/dsa/DSALib/Models/Database/Dsa/GroupChar.cs b/dsa/DSALib/Models/Database/Dsa/GroupChar.cs
index a0115cd..446bfcc 100644
--- a/dsa/DSALib/Models/Database/Dsa/GroupChar.cs
+++ b/dsa/DSALib/Models/Database/Dsa/GroupChar.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Models.Database.Dsa
-{
- public class GroupChar
- {
+namespace DSALib.Models.Database.Dsa {
+ public class GroupChar {
public string Name { get; set; }
public int Id { get; set; }
public int Lp { get; set; }
diff --git a/dsa/DSALib/Models/Database/Dsa/Inventory.cs b/dsa/DSALib/Models/Database/Dsa/Inventory.cs
index f3f5d7a..5dc5c62 100644
--- a/dsa/DSALib/Models/Database/Dsa/Inventory.cs
+++ b/dsa/DSALib/Models/Database/Dsa/Inventory.cs
@@ -1,9 +1,7 @@
using System.Collections.Generic;
-namespace DSALib.Models.Database.Dsa
-{
- public class Inventory
- {
+namespace DSALib.Models.Database.Dsa {
+ public class Inventory {
public int Id { get; set; }
public Dictionary<string, bool> Items { get; set; } = new Dictionary<string, bool>();
public Dictionary<string, bool> Food { get; set; } = new Dictionary<string, bool>();
diff --git a/dsa/DSALib/Models/Database/Dsa/Talent.cs b/dsa/DSALib/Models/Database/Dsa/Talent.cs
index 214aecc..18f18ff 100644
--- a/dsa/DSALib/Models/Database/Dsa/Talent.cs
+++ b/dsa/DSALib/Models/Database/Dsa/Talent.cs
@@ -1,20 +1,15 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class Talent : DSALib.Models.Database.DataObject
- {
- public Talent()
- {
+namespace DSALib.Models.Database.Dsa {
+ public class Talent : DataObject {
+ public Talent() {
}
- public Talent(string name)
- {
+ public Talent(string name) {
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('/');
}
diff --git a/dsa/DSALib/Models/Database/Dsa/Weapon.cs b/dsa/DSALib/Models/Database/Dsa/Weapon.cs
index 308c6c5..7f9b36e 100644
--- a/dsa/DSALib/Models/Database/Dsa/Weapon.cs
+++ b/dsa/DSALib/Models/Database/Dsa/Weapon.cs
@@ -1,15 +1,11 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class Weapon
- {
- public Weapon()
- {
+namespace DSALib.Models.Database.Dsa {
+ public class Weapon {
+ public Weapon() {
}
- public Weapon(string name, string damage, int weight, string weaponTalent, string price)
- {
+ public Weapon(string name, string damage, int weight, string weaponTalent, string price) {
Name = name ?? throw new ArgumentNullException(nameof(name));
Damage = damage ?? throw new ArgumentNullException(nameof(damage));
Weight = weight;
@@ -24,11 +20,9 @@ namespace DSALib.Models.Database.Dsa
public string Price { get; set; }
}
- public class MeleeWeapon : Weapon
- {
+ public class MeleeWeapon : Weapon {
public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
- damage, weight, weaponTalent, price)
- {
+ damage, weight, weaponTalent, price) {
}
public string TpKK { get; set; }
@@ -36,11 +30,9 @@ namespace DSALib.Models.Database.Dsa
public string MW { get; set; }
}
- public class RangedWeapon : Weapon
- {
+ public class RangedWeapon : Weapon {
public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
- damage, weight, weaponTalent, price)
- {
+ damage, weight, weaponTalent, price) {
}
public int AtMod { get; set; }
diff --git a/dsa/DSALib/Models/Database/Dsa/WeaponTalent.cs b/dsa/DSALib/Models/Database/Dsa/WeaponTalent.cs
index 2ab921b..2deecce 100644
--- a/dsa/DSALib/Models/Database/Dsa/WeaponTalent.cs
+++ b/dsa/DSALib/Models/Database/Dsa/WeaponTalent.cs
@@ -1,11 +1,8 @@
using System;
-namespace DSALib.Models.Database.Dsa
-{
- public class WeaponTalent
- {
- public WeaponTalent(string name, int at, int pa)
- {
+namespace DSALib.Models.Database.Dsa {
+ public class WeaponTalent {
+ public WeaponTalent(string name, int at, int pa) {
Name = name ?? throw new ArgumentNullException(nameof(name));
At = at;
Pa = pa;
diff --git a/dsa/DSALib/Models/Database/Groups/DSAGroup.cs b/dsa/DSALib/Models/Database/Groups/DSAGroup.cs
index adbd0ac..574d6a5 100644
--- a/dsa/DSALib/Models/Database/Groups/DSAGroup.cs
+++ b/dsa/DSALib/Models/Database/Groups/DSAGroup.cs
@@ -1,10 +1,8 @@
using System.Collections.Generic;
using DSALib.Models.Database.Dsa;
-namespace DSALib.Models.Database.Groups
-{
- public class DsaGroup : Group
- {
+namespace DSALib.Models.Database.Groups {
+ public class DsaGroup : Group {
public List<GroupChar> Chars { get; set; } = new List<GroupChar>();
}
} \ No newline at end of file
diff --git a/dsa/DSALib/Models/Database/Groups/Group.cs b/dsa/DSALib/Models/Database/Groups/Group.cs
index 096f2be..eaf10c5 100644
--- a/dsa/DSALib/Models/Database/Groups/Group.cs
+++ b/dsa/DSALib/Models/Database/Groups/Group.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Models.Database.Groups
-{
- public class Group
- {
+namespace DSALib.Models.Database.Groups {
+ public class Group {
public string Name { get; set; }
public string Password { get; set; }
public int Id { get; set; }
diff --git a/dsa/DSALib/Models/Database/IDataObject.cs b/dsa/DSALib/Models/Database/IDataObject.cs
index bdc88b7..41a0882 100644
--- a/dsa/DSALib/Models/Database/IDataObject.cs
+++ b/dsa/DSALib/Models/Database/IDataObject.cs
@@ -1,7 +1,5 @@
-namespace DSALib.Models.Database
-{
- public interface IDataObject
- {
+namespace DSALib.Models.Database {
+ public interface IDataObject {
string Name { get; set; }
}
} \ No newline at end of file
diff --git a/dsa/DSALib/Models/Dsa/CritterAttack.cs b/dsa/DSALib/Models/Dsa/CritterAttack.cs
index 8cd8b09..bad3bda 100644
--- a/dsa/DSALib/Models/Dsa/CritterAttack.cs
+++ b/dsa/DSALib/Models/Dsa/CritterAttack.cs
@@ -1,9 +1,8 @@
-namespace DSALib.Models.Dsa
-{
- public class CritterAttack : Database.DataObject
- {
- public CritterAttack(string name, int at, string tp, string comment = "")
- {
+using DSALib.Models.Database;
+
+namespace DSALib.Models.Dsa {
+ public class CritterAttack : DataObject {
+ public CritterAttack(string name, int at, string tp, string comment = "") {
Name = name;
At = at;
Tp = tp;
diff --git a/dsa/DSALib/Models/Dsa/KampfTalent.cs b/dsa/DSALib/Models/Dsa/KampfTalent.cs
index 51ad255..2c82fbb 100644
--- a/dsa/DSALib/Models/Dsa/KampfTalent.cs
+++ b/dsa/DSALib/Models/Dsa/KampfTalent.cs
@@ -1,9 +1,8 @@
-namespace DSALib.Models.Dsa
-{
- public class KampfTalent : Database.DataObject
- {
- public KampfTalent(string name, int at, int pa)
- {
+using DSALib.Models.Database;
+
+namespace DSALib.Models.Dsa {
+ public class KampfTalent : DataObject {
+ public KampfTalent(string name, int at, int pa) {
Name = name;
At = at;
Pa = pa;
diff --git a/dsa/DSALib/Models/Dsa/Talent.cs b/dsa/DSALib/Models/Dsa/Talent.cs
index 5771a74..74fc844 100644
--- a/dsa/DSALib/Models/Dsa/Talent.cs
+++ b/dsa/DSALib/Models/Dsa/Talent.cs
@@ -1,9 +1,9 @@
-namespace DSALib.Models.Dsa
-{
- public class Talent : Database.DataObject // talent objekt
+using DSALib.Models.Database;
+
+namespace DSALib.Models.Dsa {
+ public class Talent : DataObject // talent objekt
{
- public Talent(string name, string probe, int value)
- {
+ public Talent(string name, string probe, int value) {
Name = name;
Probe = probe;
Value = value;
@@ -21,10 +21,8 @@
return temp;
}
- public bool IstFernkampftalent()
- {
- switch (Name)
- {
+ public bool IstFernkampftalent() {
+ switch (Name) {
case "Armbrust":
case "Belagerungswaffen":
case "Blasrohr":
diff --git a/dsa/DSALib/Models/Dsa/Vorteil.cs b/dsa/DSALib/Models/Dsa/Vorteil.cs
index e37af20..c07d6f8 100644
--- a/dsa/DSALib/Models/Dsa/Vorteil.cs
+++ b/dsa/DSALib/Models/Dsa/Vorteil.cs
@@ -1,9 +1,9 @@
-namespace DSALib.Models.Dsa
-{
- public class Vorteil : Database.DataObject // talent objekt
+using DSALib.Models.Database;
+
+namespace DSALib.Models.Dsa {
+ public class Vorteil : DataObject // talent objekt
{
- public Vorteil(string name, string value = "")
- {
+ public Vorteil(string name, string value = "") {
Name = name;
Value = value;
// this.Choice = choice;
diff --git a/dsa/DSALib/Models/Dsa/Zauber.cs b/dsa/DSALib/Models/Dsa/Zauber.cs
index e4387bf..b0a8feb 100644
--- a/dsa/DSALib/Models/Dsa/Zauber.cs
+++ b/dsa/DSALib/Models/Dsa/Zauber.cs
@@ -1,10 +1,7 @@
-namespace DSALib.Models.Dsa
-{
- public class Zauber : Talent
- {
+namespace DSALib.Models.Dsa {
+ public class Zauber : Talent {
public Zauber(string name, string probe, int value, char complexity = 'A', string representation = "Magier")
- : base(name, probe, value)
- {
+ : base(name, probe, value) {
Complexity = complexity;
Representation = Representation;
}
diff --git a/dsa/DSALib/Models/Network/Command.cs b/dsa/DSALib/Models/Network/Command.cs
index 5a97e88..1b54e84 100644
--- a/dsa/DSALib/Models/Network/Command.cs
+++ b/dsa/DSALib/Models/Network/Command.cs
@@ -1,10 +1,8 @@
using System.Collections.Generic;
using System.Linq;
-namespace DSALib.Models.Network
-{
- public class Command
- {
+namespace DSALib.Models.Network {
+ public class Command {
public ulong GroupId { get; set; } = 0;
public ulong CharId { get; set; }
public string Name { get; set; }
diff --git a/dsa/DSALib/Models/Network/CommandResponse.cs b/dsa/DSALib/Models/Network/CommandResponse.cs
index 0816e4a..02ae99b 100644
--- a/dsa/DSALib/Models/Network/CommandResponse.cs
+++ b/dsa/DSALib/Models/Network/CommandResponse.cs
@@ -1,11 +1,8 @@
using System;
-namespace DSALib.Models.Network
-{
- public class CommandResponse
- {
- public CommandResponse(string message, ResponseType responseType = ResponseType.Broadcast)
- {
+namespace DSALib.Models.Network {
+ public class CommandResponse {
+ public CommandResponse(string message, ResponseType responseType = ResponseType.Broadcast) {
this.message = message ?? throw new ArgumentNullException(nameof(message));
ResponseType = responseType;
}
@@ -13,14 +10,12 @@ namespace DSALib.Models.Network
public string message { get; }
public ResponseType ResponseType { get; }
- public override string ToString()
- {
+ public override string ToString() {
return message;
}
}
- public enum ResponseType
- {
+ public enum ResponseType {
Broadcast,
Caller,
Error