From f89f308c525e9deebc6d2cf6416e27dfe1a299dc Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 19 May 2019 16:03:38 +0200 Subject: Cleanup DiscoBot Project --- DSACore/Audio/Sound.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'DSACore/Audio/Sound.cs') 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 -- cgit v1.2.3-54-g00ecf From 2ab4051c6fe720dc47e99b0c305a0d779ee02d51 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 19 May 2019 17:58:42 +0200 Subject: Moved Gamelogic to DSALib --- DSACore/Audio/Sound.cs | 18 -- DSACore/Auxiliary/Calculator/Argument.cs | 35 --- DSACore/Auxiliary/Calculator/ISolvable.cs | 10 - DSACore/Auxiliary/Calculator/Operator.cs | 51 ---- DSACore/Auxiliary/Calculator/Ops.cs | 13 - DSACore/Auxiliary/Calculator/StringSolver.cs | 183 ------------- DSACore/Auxiliary/CommandInfo.cs | 28 -- DSACore/Auxiliary/Dice.cs | 43 --- DSACore/Auxiliary/Extensions.cs | 25 -- DSACore/Auxiliary/RandomMisc.cs | 52 ---- DSACore/Auxiliary/SpellCorrect.cs | 106 -------- DSACore/Auxiliary/TalentEnumerableExtension.cs | 73 ------ DSACore/Auxiliary/WeaponImporter.cs | 175 ------------- DSACore/Commands/CommandHandler.cs | 134 ---------- DSACore/Commands/CommandTypes.cs | 13 - DSACore/Commands/FileHandler.cs | 31 --- DSACore/Commands/Gm.cs | 176 ------------- DSACore/Commands/HeldList.cs | 174 ------------- DSACore/Commands/Help.cs | 54 ---- DSACore/Commands/LebenUndAstral.cs | 172 ------------ DSACore/Commands/List.cs | 46 ---- DSACore/Commands/MiscCommands.cs | 219 ---------------- DSACore/Commands/NpcCommands.cs | 35 --- DSACore/Commands/ProbenTest.cs | 85 ------ DSACore/DSA_Game/Characters/Character.cs | 271 ------------------- DSACore/DSA_Game/Characters/NPC.cs | 83 ------ DSACore/DSA_Game/Characters/SaveChar.cs | 38 --- DSACore/DSA_Game/Dsa.cs | 94 ------- DSACore/DSA_Game/Save/Properties.cs | 80 ------ DSACore/DSA_Game/Save/SaveCommand.cs | 66 ----- DSACore/DSA_Game/Save/Session.cs | 51 ---- DSACore/FireBase/Database.cs | 272 ------------------- DSACore/Models/Database/DSA/Advantage.cs | 16 -- DSACore/Models/Database/DSA/CharSpell.cs | 16 -- DSACore/Models/Database/DSA/DatabaseChar.cs | 63 ----- DSACore/Models/Database/DSA/Field.cs | 16 -- DSACore/Models/Database/DSA/GeneralSpell.cs | 20 -- DSACore/Models/Database/DSA/GroupChar.cs | 13 - DSACore/Models/Database/DSA/Inventory.cs | 12 - DSACore/Models/Database/DSA/Talent.cs | 26 -- DSACore/Models/Database/DSA/Weapon.cs | 52 ---- DSACore/Models/Database/DSA/WeaponTalent.cs | 18 -- DSACore/Models/Database/Groups/DSAGroup.cs | 10 - DSACore/Models/Database/Groups/Group.cs | 10 - DSACore/Models/Network/Command.cs | 18 -- DSACore/Models/Network/CommandResponse.cs | 28 -- DSACore/Models/Network/Group.cs | 43 --- DSACore/Models/Network/Token.cs | 21 -- DSACore/Models/Network/User.cs | 9 - DSACore/PropertiesDSACore-Audio-Sound.json | 7 - .../PropertiesDSACore-Auxiliary-CommandInfo.json | 101 ------- ...rtiesDSACore-DSA_Game-Characters-Character.json | 290 --------------------- .../PropertiesNewtonsoft-Json-Linq-JProperty.json | 30 --- DSACore/helden/Felis.xml | 4 - DSACore/helden/Gardist.xml | 4 - DSACore/helden/HartmutReiher.xml | 4 - .../helden/Helga_vom_Drachenei_Tausendsasserin.xml | 4 - DSACore/helden/Krenko.xml | 4 - DSACore/helden/Ledur Torfinson.xml | 4 - DSACore/helden/Morla.xml | 4 - DSACore/helden/Numeri.xml | 4 - DSACore/helden/Potus.xml | 4 - DSACore/helden/PumpausderGosse.xml | 4 - DSACore/helden/Rhoktar4.xml | 4 - DSACore/helden/Volant.xml | 4 - DSACore/sessions/TheCrew/TheCrew-0.json | 83 ------ DSACore/sessions/copy/copy-0.json | 79 ------ DSACore/sessions/test/test-0.json | 79 ------ DSACore/sessions/test/test-1.json | 79 ------ DSACore/sessions/test/test-2.json | 81 ------ DSACore/sessions/test/test-3.json | 81 ------ DSACore/sessions/test/test-4.json | 81 ------ DSALib/Audio/Sound.cs | 18 ++ DSALib/Auxiliary/Calculator/Argument.cs | 35 +++ DSALib/Auxiliary/Calculator/ISolvable.cs | 10 + DSALib/Auxiliary/Calculator/Operator.cs | 51 ++++ DSALib/Auxiliary/Calculator/Ops.cs | 13 + DSALib/Auxiliary/Calculator/StringSolver.cs | 183 +++++++++++++ DSALib/Auxiliary/CommandInfo.cs | 28 ++ DSALib/Auxiliary/Dice.cs | 43 +++ DSALib/Auxiliary/Extensions.cs | 25 ++ DSALib/Auxiliary/RandomMisc.cs | 52 ++++ DSALib/Auxiliary/SpellCorrect.cs | 106 ++++++++ DSALib/Auxiliary/TalentEnumerableExtension.cs | 73 ++++++ DSALib/Auxiliary/WeaponImporter.cs | 175 +++++++++++++ DSALib/Commands/CommandHandler.cs | 134 ++++++++++ DSALib/Commands/CommandTypes.cs | 13 + DSALib/Commands/FileHandler.cs | 31 +++ DSALib/Commands/Gm.cs | 176 +++++++++++++ DSALib/Commands/HeldList.cs | 174 +++++++++++++ DSALib/Commands/Help.cs | 54 ++++ DSALib/Commands/LebenUndAstral.cs | 172 ++++++++++++ DSALib/Commands/List.cs | 46 ++++ DSALib/Commands/MiscCommands.cs | 219 ++++++++++++++++ DSALib/Commands/NpcCommands.cs | 35 +++ DSALib/Commands/ProbenTest.cs | 85 ++++++ DSALib/DSA_Game/Characters/Character.cs | 271 +++++++++++++++++++ DSALib/DSA_Game/Characters/NPC.cs | 83 ++++++ DSALib/DSA_Game/Characters/SaveChar.cs | 38 +++ DSALib/DSA_Game/Dsa.cs | 94 +++++++ DSALib/DSA_Game/Save/Properties.cs | 80 ++++++ DSALib/DSA_Game/Save/SaveCommand.cs | 66 +++++ DSALib/DSA_Game/Save/Session.cs | 51 ++++ DSALib/FireBase/Database.cs | 272 +++++++++++++++++++ DSALib/Models/Database/DSA/Advantage.cs | 16 ++ DSALib/Models/Database/DSA/CharSpell.cs | 16 ++ DSALib/Models/Database/DSA/DatabaseChar.cs | 63 +++++ DSALib/Models/Database/DSA/Field.cs | 16 ++ DSALib/Models/Database/DSA/GeneralSpell.cs | 20 ++ DSALib/Models/Database/DSA/GroupChar.cs | 13 + DSALib/Models/Database/DSA/Inventory.cs | 12 + DSALib/Models/Database/DSA/Talent.cs | 26 ++ DSALib/Models/Database/DSA/Weapon.cs | 52 ++++ DSALib/Models/Database/DSA/WeaponTalent.cs | 18 ++ DSALib/Models/Database/Groups/DSAGroup.cs | 10 + DSALib/Models/Database/Groups/Group.cs | 10 + DSALib/Models/Network/Command.cs | 18 ++ DSALib/Models/Network/CommandResponse.cs | 28 ++ DSALib/Models/Network/Group.cs | 43 +++ DSALib/Models/Network/Token.cs | 21 ++ DSALib/Models/Network/User.cs | 9 + DSALib/PropertiesDSACore-Audio-Sound.json | 7 + .../PropertiesDSACore-Auxiliary-CommandInfo.json | 101 +++++++ ...rtiesDSACore-DSA_Game-Characters-Character.json | 290 +++++++++++++++++++++ .../PropertiesNewtonsoft-Json-Linq-JProperty.json | 30 +++ DSALib/helden/Felis.xml | 4 + DSALib/helden/Gardist.xml | 4 + DSALib/helden/HartmutReiher.xml | 4 + .../helden/Helga_vom_Drachenei_Tausendsasserin.xml | 4 + DSALib/helden/Krenko.xml | 4 + DSALib/helden/Ledur Torfinson.xml | 4 + DSALib/helden/Morla.xml | 4 + DSALib/helden/Numeri.xml | 4 + DSALib/helden/Potus.xml | 4 + DSALib/helden/PumpausderGosse.xml | 4 + DSALib/helden/Rhoktar4.xml | 4 + DSALib/helden/Volant.xml | 4 + 137 files changed, 3773 insertions(+), 4336 deletions(-) delete mode 100644 DSACore/Audio/Sound.cs delete mode 100644 DSACore/Auxiliary/Calculator/Argument.cs delete mode 100644 DSACore/Auxiliary/Calculator/ISolvable.cs delete mode 100644 DSACore/Auxiliary/Calculator/Operator.cs delete mode 100644 DSACore/Auxiliary/Calculator/Ops.cs delete mode 100644 DSACore/Auxiliary/Calculator/StringSolver.cs delete mode 100644 DSACore/Auxiliary/CommandInfo.cs delete mode 100644 DSACore/Auxiliary/Dice.cs delete mode 100644 DSACore/Auxiliary/Extensions.cs delete mode 100644 DSACore/Auxiliary/RandomMisc.cs delete mode 100644 DSACore/Auxiliary/SpellCorrect.cs delete mode 100644 DSACore/Auxiliary/TalentEnumerableExtension.cs delete mode 100644 DSACore/Auxiliary/WeaponImporter.cs delete mode 100644 DSACore/Commands/CommandHandler.cs delete mode 100644 DSACore/Commands/CommandTypes.cs delete mode 100644 DSACore/Commands/FileHandler.cs delete mode 100644 DSACore/Commands/Gm.cs delete mode 100644 DSACore/Commands/HeldList.cs delete mode 100644 DSACore/Commands/Help.cs delete mode 100644 DSACore/Commands/LebenUndAstral.cs delete mode 100644 DSACore/Commands/List.cs delete mode 100644 DSACore/Commands/MiscCommands.cs delete mode 100644 DSACore/Commands/NpcCommands.cs delete mode 100644 DSACore/Commands/ProbenTest.cs delete mode 100644 DSACore/DSA_Game/Characters/Character.cs delete mode 100644 DSACore/DSA_Game/Characters/NPC.cs delete mode 100644 DSACore/DSA_Game/Characters/SaveChar.cs delete mode 100644 DSACore/DSA_Game/Dsa.cs delete mode 100644 DSACore/DSA_Game/Save/Properties.cs delete mode 100644 DSACore/DSA_Game/Save/SaveCommand.cs delete mode 100644 DSACore/DSA_Game/Save/Session.cs delete mode 100644 DSACore/FireBase/Database.cs delete mode 100644 DSACore/Models/Database/DSA/Advantage.cs delete mode 100644 DSACore/Models/Database/DSA/CharSpell.cs delete mode 100644 DSACore/Models/Database/DSA/DatabaseChar.cs delete mode 100644 DSACore/Models/Database/DSA/Field.cs delete mode 100644 DSACore/Models/Database/DSA/GeneralSpell.cs delete mode 100644 DSACore/Models/Database/DSA/GroupChar.cs delete mode 100644 DSACore/Models/Database/DSA/Inventory.cs delete mode 100644 DSACore/Models/Database/DSA/Talent.cs delete mode 100644 DSACore/Models/Database/DSA/Weapon.cs delete mode 100644 DSACore/Models/Database/DSA/WeaponTalent.cs delete mode 100644 DSACore/Models/Database/Groups/DSAGroup.cs delete mode 100644 DSACore/Models/Database/Groups/Group.cs delete mode 100644 DSACore/Models/Network/Command.cs delete mode 100644 DSACore/Models/Network/CommandResponse.cs delete mode 100644 DSACore/Models/Network/Group.cs delete mode 100644 DSACore/Models/Network/Token.cs delete mode 100644 DSACore/Models/Network/User.cs delete mode 100644 DSACore/PropertiesDSACore-Audio-Sound.json delete mode 100644 DSACore/PropertiesDSACore-Auxiliary-CommandInfo.json delete mode 100644 DSACore/PropertiesDSACore-DSA_Game-Characters-Character.json delete mode 100644 DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json delete mode 100644 DSACore/helden/Felis.xml delete mode 100644 DSACore/helden/Gardist.xml delete mode 100644 DSACore/helden/HartmutReiher.xml delete mode 100644 DSACore/helden/Helga_vom_Drachenei_Tausendsasserin.xml delete mode 100644 DSACore/helden/Krenko.xml delete mode 100644 DSACore/helden/Ledur Torfinson.xml delete mode 100644 DSACore/helden/Morla.xml delete mode 100644 DSACore/helden/Numeri.xml delete mode 100644 DSACore/helden/Potus.xml delete mode 100644 DSACore/helden/PumpausderGosse.xml delete mode 100644 DSACore/helden/Rhoktar4.xml delete mode 100644 DSACore/helden/Volant.xml delete mode 100644 DSACore/sessions/TheCrew/TheCrew-0.json delete mode 100644 DSACore/sessions/copy/copy-0.json delete mode 100644 DSACore/sessions/test/test-0.json delete mode 100644 DSACore/sessions/test/test-1.json delete mode 100644 DSACore/sessions/test/test-2.json delete mode 100644 DSACore/sessions/test/test-3.json delete mode 100644 DSACore/sessions/test/test-4.json create mode 100644 DSALib/Audio/Sound.cs create mode 100644 DSALib/Auxiliary/Calculator/Argument.cs create mode 100644 DSALib/Auxiliary/Calculator/ISolvable.cs create mode 100644 DSALib/Auxiliary/Calculator/Operator.cs create mode 100644 DSALib/Auxiliary/Calculator/Ops.cs create mode 100644 DSALib/Auxiliary/Calculator/StringSolver.cs create mode 100644 DSALib/Auxiliary/CommandInfo.cs create mode 100644 DSALib/Auxiliary/Dice.cs create mode 100644 DSALib/Auxiliary/Extensions.cs create mode 100644 DSALib/Auxiliary/RandomMisc.cs create mode 100644 DSALib/Auxiliary/SpellCorrect.cs create mode 100644 DSALib/Auxiliary/TalentEnumerableExtension.cs create mode 100644 DSALib/Auxiliary/WeaponImporter.cs create mode 100644 DSALib/Commands/CommandHandler.cs create mode 100644 DSALib/Commands/CommandTypes.cs create mode 100644 DSALib/Commands/FileHandler.cs create mode 100644 DSALib/Commands/Gm.cs create mode 100644 DSALib/Commands/HeldList.cs create mode 100644 DSALib/Commands/Help.cs create mode 100644 DSALib/Commands/LebenUndAstral.cs create mode 100644 DSALib/Commands/List.cs create mode 100644 DSALib/Commands/MiscCommands.cs create mode 100644 DSALib/Commands/NpcCommands.cs create mode 100644 DSALib/Commands/ProbenTest.cs create mode 100644 DSALib/DSA_Game/Characters/Character.cs create mode 100644 DSALib/DSA_Game/Characters/NPC.cs create mode 100644 DSALib/DSA_Game/Characters/SaveChar.cs create mode 100644 DSALib/DSA_Game/Dsa.cs create mode 100644 DSALib/DSA_Game/Save/Properties.cs create mode 100644 DSALib/DSA_Game/Save/SaveCommand.cs create mode 100644 DSALib/DSA_Game/Save/Session.cs create mode 100644 DSALib/FireBase/Database.cs create mode 100644 DSALib/Models/Database/DSA/Advantage.cs create mode 100644 DSALib/Models/Database/DSA/CharSpell.cs create mode 100644 DSALib/Models/Database/DSA/DatabaseChar.cs create mode 100644 DSALib/Models/Database/DSA/Field.cs create mode 100644 DSALib/Models/Database/DSA/GeneralSpell.cs create mode 100644 DSALib/Models/Database/DSA/GroupChar.cs create mode 100644 DSALib/Models/Database/DSA/Inventory.cs create mode 100644 DSALib/Models/Database/DSA/Talent.cs create mode 100644 DSALib/Models/Database/DSA/Weapon.cs create mode 100644 DSALib/Models/Database/DSA/WeaponTalent.cs create mode 100644 DSALib/Models/Database/Groups/DSAGroup.cs create mode 100644 DSALib/Models/Database/Groups/Group.cs create mode 100644 DSALib/Models/Network/Command.cs create mode 100644 DSALib/Models/Network/CommandResponse.cs create mode 100644 DSALib/Models/Network/Group.cs create mode 100644 DSALib/Models/Network/Token.cs create mode 100644 DSALib/Models/Network/User.cs create mode 100644 DSALib/PropertiesDSACore-Audio-Sound.json create mode 100644 DSALib/PropertiesDSACore-Auxiliary-CommandInfo.json create mode 100644 DSALib/PropertiesDSACore-DSA_Game-Characters-Character.json create mode 100644 DSALib/PropertiesNewtonsoft-Json-Linq-JProperty.json create mode 100644 DSALib/helden/Felis.xml create mode 100644 DSALib/helden/Gardist.xml create mode 100644 DSALib/helden/HartmutReiher.xml create mode 100644 DSALib/helden/Helga_vom_Drachenei_Tausendsasserin.xml create mode 100644 DSALib/helden/Krenko.xml create mode 100644 DSALib/helden/Ledur Torfinson.xml create mode 100644 DSALib/helden/Morla.xml create mode 100644 DSALib/helden/Numeri.xml create mode 100644 DSALib/helden/Potus.xml create mode 100644 DSALib/helden/PumpausderGosse.xml create mode 100644 DSALib/helden/Rhoktar4.xml create mode 100644 DSALib/helden/Volant.xml (limited to 'DSACore/Audio/Sound.cs') diff --git a/DSACore/Audio/Sound.cs b/DSACore/Audio/Sound.cs deleted file mode 100644 index aee3060..0000000 --- a/DSACore/Audio/Sound.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace DSACore.Audio -{ - public class Sound - { - public Sound(string name, string url, int volume) - { - Name = name; - Url = url; - Volume = volume; - } - - public string Name { get; } - - public string Url { get; } - - public int Volume { get; } - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Calculator/Argument.cs b/DSACore/Auxiliary/Calculator/Argument.cs deleted file mode 100644 index 5ed9ee3..0000000 --- a/DSACore/Auxiliary/Calculator/Argument.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace DSACore.Auxiliary.Calculator -{ - /// - /// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int. - /// - public class Argument : ISolvable - { - private readonly int 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. ", - nameof(value)); - - if (!int.TryParse(value, out var result)) - throw new ArgumentException($"Kann {value} nicht in Integer konvertieren"); - - this.value = result; - } - - public int Solve() - { - return value; - } - - public override string ToString() - { - return value.ToString(); - } - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Calculator/ISolvable.cs b/DSACore/Auxiliary/Calculator/ISolvable.cs deleted file mode 100644 index 7be4d19..0000000 --- a/DSACore/Auxiliary/Calculator/ISolvable.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DSACore.Auxiliary.Calculator -{ - /// - /// Object has to be able to return an integer as it's value - /// - public interface ISolvable - { - int Solve(); - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Calculator/Operator.cs b/DSACore/Auxiliary/Calculator/Operator.cs deleted file mode 100644 index 31b2a9b..0000000 --- a/DSACore/Auxiliary/Calculator/Operator.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using DSACorev.Auxiliary.Calculator; - -namespace DSACore.Auxiliary.Calculator -{ - /// - /// The Operator Class represents a binary operator with tow Arguments and an Operation type - /// - public class Operator : ISolvable - { - private readonly ISolvable arg1, arg2; - - public Operator(ISolvable arg1, ISolvable arg2, Ops operatorType) - { - this.arg1 = arg1; - this.arg2 = arg2; - OperatorType = operatorType; - } - - public Ops OperatorType { get; set; } - - public int Solve() - { - int result; - switch (OperatorType) - { - case Ops.Dice: - result = Dice.Roll(arg1.Solve(), arg2.Solve()); - break; - case Ops.Multiply: - result = arg1.Solve() * arg2.Solve(); - break; - case Ops.Add: - result = arg1.Solve() + arg2.Solve(); - break; - case Ops.Subtract: - result = arg1.Solve() - arg2.Solve(); - break; - default: - throw new ArgumentOutOfRangeException(); - } - - return result; - } - - public override string ToString() - { - return $"({arg1} {OperatorType} {arg2})"; - } - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Calculator/Ops.cs b/DSACore/Auxiliary/Calculator/Ops.cs deleted file mode 100644 index a5c9a2d..0000000 --- a/DSACore/Auxiliary/Calculator/Ops.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace DSACorev.Auxiliary.Calculator -{ - /// - /// The Different Operations, witch can be performed in execution-order - /// - public enum Ops - { - Dice, - Multiply, - Subtract, - Add - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Calculator/StringSolver.cs b/DSACore/Auxiliary/Calculator/StringSolver.cs deleted file mode 100644 index b2a7d83..0000000 --- a/DSACore/Auxiliary/Calculator/StringSolver.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using DSACorev.Auxiliary.Calculator; - -namespace DSACore.Auxiliary.Calculator -{ - /// - /// The StringSolver divides the calculation string into operations and SubStringSolvers if the string contains - /// parentheses - /// - public class StringSolver : ISolvable - { - private readonly List arguments = new List(); - private readonly string input; - - public StringSolver(string input) - { - this.input = input; - } - - public int Solve() - { - 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"}. - AtomizeOperations(workInput); - - // traverse the List in order of Operation to Create the binary operation tree . - NestOperations(); - - // the List now contains only the top operation node, witch can be solved recursively, - return ((ISolvable) arguments.First()).Solve(); - } - - public override string ToString() - { - return "(0+" + input.Replace(" ", string.Empty).ToLower() + ")"; - } - - private static string - 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++) - { - var c = input[index]; - switch (c) - { - case '(': - depth++; - break; - case ')': - if (depth == 0) - { - var split = input.Substring(1, index - 1); - input = input.Substring(index + 1); - return split.Equals(string.Empty) ? "0" : split; - } - else - { - depth--; - } - - break; - } - } - - return string.Empty; - } - - private static Ops GetOps(char c) - { - switch (c) - { - case 'd': - case 'w': - return Ops.Dice; - case '+': - return Ops.Add; - case '-': - return Ops.Subtract; - case '*': - return Ops.Multiply; - default: - return Ops.Multiply; - } - } - - private static string ExpandParentheses(string input) // insert * between Parentheses and digits - { - for (var i = 0; i < input.Length - 1; i++) - if (input[i + 1] == '(' && char.IsNumber(input[i])) - input = input.Insert(i + 1, "*"); - - for (var i = 1; i < input.Length; i++) - if (input[i - 1] == ')' && char.IsNumber(input[i])) - input = input.Insert(i, "*"); - - return input; - } - - private void AtomizeOperations(string workInput) - { - for (var index = 0; index < workInput.Length; 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 - arguments.Add(new Argument(workInput.Substring(0, index + 1))); - - continue; - } - - switch (c) - { - case ')': - throw new ArgumentException("Unmögliche Anordnung von Klammern"); - case '(': - arguments.Add(new StringSolver(GetInner(ref workInput))); - index = -1; - break; - default: - if (index > 0) arguments.Add(new Argument(workInput.Substring(0, index))); - - arguments.Add(GetOps(c)); - workInput = workInput.Remove(0, index + 1); - index = -1; - break; - } - } - } - - 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++) - { - var arg = arguments[index]; - - if (arg.GetType() != typeof(Ops)) continue; - - // arg is of type Ops - var op = (Ops) arg; - - if (op != currentOp) continue; - - // arg describes the current operation - 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) 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 = arguments[index - 1]; - 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)) - { - arguments[index + 1] = new Operator(new Argument("0"), (ISolvable) arguments[index + 2], (Ops) arg2); - arguments.RemoveAt(index + 2); - } - } - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/CommandInfo.cs b/DSACore/Auxiliary/CommandInfo.cs deleted file mode 100644 index 1472587..0000000 --- a/DSACore/Auxiliary/CommandInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Linq; - -namespace DSACore.Auxiliary -{ - public struct CommandInfo - { - public CommandInfo(string name, string brief, string[] description, string scope) - { - Name = name; - Scope = scope; - Brief = brief; - Description = description; - } - - public string Name { get; } - - public string Scope { get; } - - public string Brief { get; } - - public string[] Description { get; } - - public string GetDescription() - { - 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 deleted file mode 100644 index 3dd6562..0000000 --- a/DSACore/Auxiliary/Dice.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Linq; - -namespace DSACore.Auxiliary -{ - public static class Dice // roll it! - { - private static readonly Random Rnd = new Random(); - - public static int Roll(int d = 20) - { - return Rnd.Next(d) + 1; - } - - public static int Roll(string input) - { - 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; - - var sum = 0; - for (var i = 0; i < Math.Abs(count); i++) - { - var roll = Roll(d); - sum += roll; - } - - sum *= Math.Abs(count) / count; - - return sum; - } - } -} \ No newline at end of file diff --git a/DSACore/Auxiliary/Extensions.cs b/DSACore/Auxiliary/Extensions.cs deleted file mode 100644 index f8e9d8e..0000000 --- a/DSACore/Auxiliary/Extensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace DSACore.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) - { - var temp = str; - for (var i = str.Length; i < length; i++) temp += " "; - return temp; - } - - - //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) - { - 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 deleted file mode 100644 index 72c2234..0000000 --- a/DSACore/Auxiliary/RandomMisc.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Linq; -using System.Text; - -namespace DSACore.Auxiliary -{ - public static class RandomMisc - { - private static readonly Random Rand = new Random(); - - // use: 4w6 +4 - 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) - { - } - - 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); - } - - return output.ToString(); - } - - 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)) * - 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 deleted file mode 100644 index 77d1cf3..0000000 --- a/DSACore/Auxiliary/SpellCorrect.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; - -namespace DSACore.Auxiliary -{ - public class SpellCorrect : StringComparer - { - public const int ErrorThreshold = 94100; - - public override int Compare(string x, string y) - { - return CompareEasy(x, y); - } - - public static int CompareEasy(string x, string y) - { - if (string.IsNullOrEmpty(x)) throw new ArgumentException("message", nameof(x)); - - if (string.IsNullOrEmpty(y)) throw new ArgumentException("message", nameof(y)); - - if (x.Equals(y)) return 0; - - x = x.ToLower(); - y = y.ToLower(); - if (x.Equals(y)) return 1; - - var subs = y.Split(' ', '/'); - var score = subs.Count(); - foreach (var s in subs) - if (s.Equals(x)) - score--; - - if (score < subs.Count()) return score + 1; - - return 100000 - (int) (CompareExact(x, y) * 1000.0); - /*if (y.Contains(x)) - return 6;*/ - } - - public override bool Equals(string x, string y) - { - Debug.Assert(x != null, nameof(x) + " != null"); - return x.Equals(y); - } - - public override int GetHashCode(string obj) - { - throw new NotImplementedException(); - } - - public static double CompareExact(string s, string q) - { - s = s.ToLower(); - q = q.ToLower(); - - int i, j; - const double Match = 3.0; - const double Gap = -2.0; - const double Mismatch = -2.0; - - double decay; - - 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] = i * Gap; - - 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++) - { - 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, 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 (score < 0) - // { - // score = 0; - // } - - if (max < score && i == s.Length) max = 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 deleted file mode 100644 index d83114c..0000000 --- a/DSACore/Auxiliary/TalentEnumerableExtension.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using DSACore.DSA_Game.Characters; -using DSALib; - -namespace DSACore.Auxiliary -{ - public static class TalentEnumerableExtension - { - public static string ProbenTest(this IEnumerable List, Character c, string talent, int erschwernis = 0) - { - var output = new StringBuilder(); - var sc = new SpellCorrect(); - 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 - var tap = tTalent.Value; // get taw - var werte = props.Select(p => c.Eigenschaften[c.PropTable[p]]).ToList(); - - output.AppendFormat( - "{0} würfelt: {1} \n{2} - {3} taw:{4} {5} \n", - c.Name, - tTalent.Name, - tTalent.Probe, - string.Join("/", werte), - tTalent.Value, - erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); - - output.Append(" "); - tap -= erschwernis; - var gesamtErschwernis = tap; - if (gesamtErschwernis < 0) - { - tap = 0; - for (var i = 0; i <= 2; i++) - { - // foreach property, dice and tap - var temp = Dice.Roll(); - var eigenschaft = c.Eigenschaften[c.PropTable[props[i]]]; - - if (eigenschaft + gesamtErschwernis < temp) tap -= temp - (eigenschaft + gesamtErschwernis); - - output.Append($"[{temp}]"); // add to string - } - - if (tap >= 0) tap = 1; - } - 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]]]; - - if (eigenschaft < temp) tap -= temp - eigenschaft; - - output.Append($"[{temp}]"); // add to string - } - } - - 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 deleted file mode 100644 index 3375236..0000000 --- a/DSACore/Auxiliary/WeaponImporter.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using DSACore.FireBase; -using DSACore.Models.Database.DSA; - -namespace DSACore.Auxiliary -{ - public class WeaponImporter - { - private readonly List Range = new List(); - private readonly List Weapons = new List(); - - public async Task DownloadWeapons() - { - var client = new HttpClient(); - - - for (var i = 1; i <= 25; i++) - { - var responseString = - await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/categoryChanged/" + i); - - var talentRegex = new Regex(@"(?<=