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 --- 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 +++++ 17 files changed, 391 insertions(+) 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 (limited to 'DSALib/Models') diff --git a/DSALib/Models/Database/DSA/Advantage.cs b/DSALib/Models/Database/DSA/Advantage.cs new file mode 100644 index 0000000..cc8f5cc --- /dev/null +++ b/DSALib/Models/Database/DSA/Advantage.cs @@ -0,0 +1,16 @@ +using System; + +namespace DSACore.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)); + } + + public string Name { get; set; } + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/CharSpell.cs b/DSALib/Models/Database/DSA/CharSpell.cs new file mode 100644 index 0000000..fabd456 --- /dev/null +++ b/DSALib/Models/Database/DSA/CharSpell.cs @@ -0,0 +1,16 @@ +using System; + +namespace DSACore.Models.Database.DSA +{ + public class CharSpell + { + public CharSpell(string representation, int value) + { + this.representation = representation ?? throw new ArgumentNullException(nameof(representation)); + this.value = value; + } + + public string representation { get; set; } + public int value { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/DatabaseChar.cs b/DSALib/Models/Database/DSA/DatabaseChar.cs new file mode 100644 index 0000000..872b82e --- /dev/null +++ b/DSALib/Models/Database/DSA/DatabaseChar.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DSACore.DSA_Game.Characters; + +namespace DSACore.Models.Database.DSA +{ + public class DatabaseChar + { + public DatabaseChar() + { + } + + public DatabaseChar(int id, string name, string rasse, List skills, List talents, + List advantages, List spells, List weaponTalents) + { + Id = id; + Name = name ?? throw new ArgumentNullException(nameof(name)); + Rasse = rasse ?? throw new ArgumentNullException(nameof(rasse)); + Skills = skills ?? throw new ArgumentNullException(nameof(skills)); + Talents = talents ?? throw new ArgumentNullException(nameof(talents)); + Advantages = advantages ?? throw new ArgumentNullException(nameof(advantages)); + Spells = spells ?? throw new ArgumentNullException(nameof(spells)); + WeaponTalents = weaponTalents ?? throw new ArgumentNullException(nameof(weaponTalents)); + } + + public int Id { get; set; } + + public string Name { get; set; } + + public string Rasse { get; set; } + + public List Skills { get; set; } = new List(); + + public List Talents { get; set; } = new List(); + + public List Advantages { get; set; } = new List(); + + public List Spells { get; set; } = new List(); + + public List WeaponTalents { get; set; } = new List(); + + + public static void LoadChar(Character file, out GroupChar group, out DatabaseChar data) + { + group = new GroupChar(); + data = new DatabaseChar(); + + group.Name = file.Name.Split(' ').First(); + group.Weapon = new Weapon(); + group.Lp = group.LpMax = file.Lebenspunkte_Basis; + group.As = group.AsMax = file.Astralpunkte_Basis; + group.Weapon = new Weapon(); + + data.Name = file.Name; + data.Advantages = file.Vorteile.Select(x => new Advantage(x.Name, x.Value)).ToList(); + data.Skills = file.Eigenschaften.Select(x => new Field(x.Key, x.Value)).ToList(); + data.Spells = file.Zauber.Select(x => new CharSpell(x.Representation, x.Value)).ToList(); + data.Talents = file.Talente.Select(x => new Field(x.Name, x.Value)).ToList(); + data.WeaponTalents = file.Kampftalente.Select(x => new WeaponTalent(x.Name, x.At, x.Pa)).ToList(); + } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/Field.cs b/DSALib/Models/Database/DSA/Field.cs new file mode 100644 index 0000000..e63aeb4 --- /dev/null +++ b/DSALib/Models/Database/DSA/Field.cs @@ -0,0 +1,16 @@ +using System; + +namespace DSACore.Models.Database.DSA +{ + public class Field + { + public Field(string name, int value = 0) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Value = value; + } + + public string Name { get; set; } + public int Value { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/GeneralSpell.cs b/DSALib/Models/Database/DSA/GeneralSpell.cs new file mode 100644 index 0000000..b4dbc0b --- /dev/null +++ b/DSALib/Models/Database/DSA/GeneralSpell.cs @@ -0,0 +1,20 @@ +namespace DSACore.Models.Database.DSA +{ + public class GeneralSpell : Talent + { + public char Comlexity = 'A'; + + 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() + { + } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/GroupChar.cs b/DSALib/Models/Database/DSA/GroupChar.cs new file mode 100644 index 0000000..31fc583 --- /dev/null +++ b/DSALib/Models/Database/DSA/GroupChar.cs @@ -0,0 +1,13 @@ +namespace DSACore.Models.Database.DSA +{ + public class GroupChar + { + public string Name { get; set; } + public int Id { get; set; } + public int Lp { get; set; } + public int LpMax { get; set; } + public int As { get; set; } + public int AsMax { get; set; } + public Weapon Weapon { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/Inventory.cs b/DSALib/Models/Database/DSA/Inventory.cs new file mode 100644 index 0000000..9a025d4 --- /dev/null +++ b/DSALib/Models/Database/DSA/Inventory.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace DSACore.Models.Database.DSA +{ + public class Inventory + { + public int Id { get; set; } + public Dictionary Items { get; set; } = new Dictionary(); + public Dictionary Food { get; set; } = new Dictionary(); + public List Weapons { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/Talent.cs b/DSALib/Models/Database/DSA/Talent.cs new file mode 100644 index 0000000..59ff4bc --- /dev/null +++ b/DSALib/Models/Database/DSA/Talent.cs @@ -0,0 +1,26 @@ +using System; + +namespace DSACore.Models.Database.DSA +{ + public class Talent + { + public Talent() + { + } + + public Talent(string name) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + } + + public Talent(string name, string roll) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Roll = roll.Split('/'); + } + + public string Name { get; set; } + + public string[] Roll { get; set; } = new string[3]; + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/Weapon.cs b/DSALib/Models/Database/DSA/Weapon.cs new file mode 100644 index 0000000..58a44cd --- /dev/null +++ b/DSALib/Models/Database/DSA/Weapon.cs @@ -0,0 +1,52 @@ +using System; + +namespace DSACore.Models.Database.DSA +{ + public class Weapon + { + public Weapon() + { + } + + 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; + WeaponTalent = weaponTalent ?? throw new ArgumentNullException(nameof(weaponTalent)); + Price = price; + } + + public string Name { get; set; } + public string Damage { get; set; } + public int Weight { get; set; } + public string WeaponTalent { get; set; } + public string Price { get; set; } + } + + public class MeleeWeapon : Weapon + { + public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, + damage, weight, weaponTalent, price) + { + } + + public string TpKK { get; set; } + public int INI { get; set; } + public string MW { get; set; } + } + + public class RangedWeapon : Weapon + { + public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, + damage, weight, weaponTalent, price) + { + } + + public int AtMod { get; set; } + public int KKMod { get; set; } + public string AtReach { get; set; } + public string TpReach { get; set; } + public int LoadTime { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/DSA/WeaponTalent.cs b/DSALib/Models/Database/DSA/WeaponTalent.cs new file mode 100644 index 0000000..98eb38d --- /dev/null +++ b/DSALib/Models/Database/DSA/WeaponTalent.cs @@ -0,0 +1,18 @@ +using System; + +namespace DSACore.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; + } + + public string Name { get; set; } + public int At { get; set; } + public int Pa { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/Groups/DSAGroup.cs b/DSALib/Models/Database/Groups/DSAGroup.cs new file mode 100644 index 0000000..89fac2f --- /dev/null +++ b/DSALib/Models/Database/Groups/DSAGroup.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using DSACore.Models.Database.DSA; + +namespace DSACore.Models.Database.Groups +{ + public class DSAGroup : Group + { + public List Chars { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/DSALib/Models/Database/Groups/Group.cs b/DSALib/Models/Database/Groups/Group.cs new file mode 100644 index 0000000..77d3a64 --- /dev/null +++ b/DSALib/Models/Database/Groups/Group.cs @@ -0,0 +1,10 @@ +namespace DSACore.Models.Database.Groups +{ + public class Group + { + public string Name { get; set; } + public string Discord { get; set; } + public string Password { get; set; } + public int Id { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Network/Command.cs b/DSALib/Models/Network/Command.cs new file mode 100644 index 0000000..00b00a6 --- /dev/null +++ b/DSALib/Models/Network/Command.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; + +namespace DSACore.Models.Network +{ + public class Command + { + public ulong GroupId { get; set; } = 0; + public ulong CharId { get; set; } + public string Name { get; set; } + public string CmdIdentifier { get; set; } + public List CmdTexts { get; set; } + public string CmdText => CmdTexts.Count != 0 ? CmdTexts.First() : ""; + + public int Cmdmodifier => CmdTexts.Count != 0 && int.TryParse(CmdTexts.Last(), out var mod) ? mod : 0; + public bool IsDm { get; set; } = false; + } +} \ No newline at end of file diff --git a/DSALib/Models/Network/CommandResponse.cs b/DSALib/Models/Network/CommandResponse.cs new file mode 100644 index 0000000..c7a410a --- /dev/null +++ b/DSALib/Models/Network/CommandResponse.cs @@ -0,0 +1,28 @@ +using System; + +namespace DSACore.Models.Network +{ + public class CommandResponse + { + public CommandResponse(string message, ResponseType responseType = ResponseType.Broadcast) + { + this.message = message ?? throw new ArgumentNullException(nameof(message)); + ResponseType = responseType; + } + + public string message { get; } + public ResponseType ResponseType { get; } + + public override string ToString() + { + return message; + } + } + + public enum ResponseType + { + Broadcast, + Caller, + Error + } +} \ No newline at end of file diff --git a/DSALib/Models/Network/Group.cs b/DSALib/Models/Network/Group.cs new file mode 100644 index 0000000..efe12ee --- /dev/null +++ b/DSALib/Models/Network/Group.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace DSACore.Models.Network +{ + public class Group + { + public Group(string name, string password) + { + Name = name; + Password = password; + } + + public Group(string name, int userOnline) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + } + + public string Name { get; set; } + public string Password { get; set; } + public List Users { get; set; } = new List(); + + public int UserCount => Users.Count; + + public SendGroup SendGroup() + { + return new SendGroup(Name, UserCount); + } + } + + public class SendGroup + { + public SendGroup(string name, int userCount) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + UserCount = userCount; + } + + public string Name { get; set; } + + public int UserCount { get; set; } + } +} \ No newline at end of file diff --git a/DSALib/Models/Network/Token.cs b/DSALib/Models/Network/Token.cs new file mode 100644 index 0000000..451cafc --- /dev/null +++ b/DSALib/Models/Network/Token.cs @@ -0,0 +1,21 @@ +using System; + +namespace DSACore.Models.Network +{ + public class Token + { + private readonly DateTime creation = DateTime.Now; + + public Token(string group) + { + Group = group; + } + + public string Group { get; set; } + + public bool IsValid() + { + return DateTime.Now - creation < TimeSpan.FromMinutes(1); + } + } +} \ No newline at end of file diff --git a/DSALib/Models/Network/User.cs b/DSALib/Models/Network/User.cs new file mode 100644 index 0000000..8b8008c --- /dev/null +++ b/DSALib/Models/Network/User.cs @@ -0,0 +1,9 @@ +namespace DSACore.Models.Network +{ + public class User + { + public string Name { get; set; } + public string ConnectionId { get; set; } + public int Char { get; set; } + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf