From 91fc989eea5ee16c2f000064b5c040a6fe6f23b9 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 16 May 2019 01:10:10 +0200 Subject: Implement tokens --- DSACore/Models/Database/Advantage.cs | 19 --------- DSACore/Models/Database/CharSpell.cs | 19 --------- DSACore/Models/Database/DSA/Advantage.cs | 16 ++++++++ DSACore/Models/Database/DSA/CharSpell.cs | 16 ++++++++ DSACore/Models/Database/DSA/DatabaseChar.cs | 61 ++++++++++++++++++++++++++++ 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 | 50 +++++++++++++++++++++++ DSACore/Models/Database/DSA/WeaponTalent.cs | 18 +++++++++ DSACore/Models/Database/DatabaseChar.cs | 63 ----------------------------- DSACore/Models/Database/Field.cs | 19 --------- DSACore/Models/Database/GeneralSpell.cs | 25 ------------ DSACore/Models/Database/Group.cs | 19 --------- DSACore/Models/Database/GroupChar.cs | 18 --------- DSACore/Models/Database/Groups/DSAGroup.cs | 10 +++++ DSACore/Models/Database/Groups/Group.cs | 13 ++++++ DSACore/Models/Database/Inventory.cs | 15 ------- DSACore/Models/Database/Talent.cs | 29 ------------- DSACore/Models/Database/Weapon.cs | 53 ------------------------ DSACore/Models/Database/WeaponTalent.cs | 18 --------- DSACore/Models/Network/Token.cs | 21 ++++++++++ 24 files changed, 292 insertions(+), 297 deletions(-) delete mode 100644 DSACore/Models/Database/Advantage.cs delete mode 100644 DSACore/Models/Database/CharSpell.cs create mode 100644 DSACore/Models/Database/DSA/Advantage.cs create mode 100644 DSACore/Models/Database/DSA/CharSpell.cs create mode 100644 DSACore/Models/Database/DSA/DatabaseChar.cs create mode 100644 DSACore/Models/Database/DSA/Field.cs create mode 100644 DSACore/Models/Database/DSA/GeneralSpell.cs create mode 100644 DSACore/Models/Database/DSA/GroupChar.cs create mode 100644 DSACore/Models/Database/DSA/Inventory.cs create mode 100644 DSACore/Models/Database/DSA/Talent.cs create mode 100644 DSACore/Models/Database/DSA/Weapon.cs create mode 100644 DSACore/Models/Database/DSA/WeaponTalent.cs delete mode 100644 DSACore/Models/Database/DatabaseChar.cs delete mode 100644 DSACore/Models/Database/Field.cs delete mode 100644 DSACore/Models/Database/GeneralSpell.cs delete mode 100644 DSACore/Models/Database/Group.cs delete mode 100644 DSACore/Models/Database/GroupChar.cs create mode 100644 DSACore/Models/Database/Groups/DSAGroup.cs create mode 100644 DSACore/Models/Database/Groups/Group.cs delete mode 100644 DSACore/Models/Database/Inventory.cs delete mode 100644 DSACore/Models/Database/Talent.cs delete mode 100644 DSACore/Models/Database/Weapon.cs delete mode 100644 DSACore/Models/Database/WeaponTalent.cs create mode 100644 DSACore/Models/Network/Token.cs (limited to 'DSACore/Models') diff --git a/DSACore/Models/Database/Advantage.cs b/DSACore/Models/Database/Advantage.cs deleted file mode 100644 index 67965fc..0000000 --- a/DSACore/Models/Database/Advantage.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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; } - } -} diff --git a/DSACore/Models/Database/CharSpell.cs b/DSACore/Models/Database/CharSpell.cs deleted file mode 100644 index 670488c..0000000 --- a/DSACore/Models/Database/CharSpell.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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; } - } -} diff --git a/DSACore/Models/Database/DSA/Advantage.cs b/DSACore/Models/Database/DSA/Advantage.cs new file mode 100644 index 0000000..2f0b443 --- /dev/null +++ b/DSACore/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; } + } +} diff --git a/DSACore/Models/Database/DSA/CharSpell.cs b/DSACore/Models/Database/DSA/CharSpell.cs new file mode 100644 index 0000000..63d917a --- /dev/null +++ b/DSACore/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; } + } +} diff --git a/DSACore/Models/Database/DSA/DatabaseChar.cs b/DSACore/Models/Database/DSA/DatabaseChar.cs new file mode 100644 index 0000000..8c51821 --- /dev/null +++ b/DSACore/Models/Database/DSA/DatabaseChar.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +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(DSA_Game.Characters.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(); + } + } +} diff --git a/DSACore/Models/Database/DSA/Field.cs b/DSACore/Models/Database/DSA/Field.cs new file mode 100644 index 0000000..5022768 --- /dev/null +++ b/DSACore/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)); + this.Value = value; + } + + public string Name { get; set; } + public int Value { get; set; } + } +} diff --git a/DSACore/Models/Database/DSA/GeneralSpell.cs b/DSACore/Models/Database/DSA/GeneralSpell.cs new file mode 100644 index 0000000..74b95d7 --- /dev/null +++ b/DSACore/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() + { + } + } +} diff --git a/DSACore/Models/Database/DSA/GroupChar.cs b/DSACore/Models/Database/DSA/GroupChar.cs new file mode 100644 index 0000000..70b8fc1 --- /dev/null +++ b/DSACore/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; } + } +} diff --git a/DSACore/Models/Database/DSA/Inventory.cs b/DSACore/Models/Database/DSA/Inventory.cs new file mode 100644 index 0000000..69c7b08 --- /dev/null +++ b/DSACore/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(); + } +} diff --git a/DSACore/Models/Database/DSA/Talent.cs b/DSACore/Models/Database/DSA/Talent.cs new file mode 100644 index 0000000..a6de395 --- /dev/null +++ b/DSACore/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]; + } +} diff --git a/DSACore/Models/Database/DSA/Weapon.cs b/DSACore/Models/Database/DSA/Weapon.cs new file mode 100644 index 0000000..24b334a --- /dev/null +++ b/DSACore/Models/Database/DSA/Weapon.cs @@ -0,0 +1,50 @@ +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 string TpKK { get; set; } + public int INI { get; set; } + public string MW { get; set; } + + public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price) + { + } + } + + public class RangedWeapon : Weapon + { + 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; } + + public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price) + { + } + } +} diff --git a/DSACore/Models/Database/DSA/WeaponTalent.cs b/DSACore/Models/Database/DSA/WeaponTalent.cs new file mode 100644 index 0000000..869cb35 --- /dev/null +++ b/DSACore/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/DSACore/Models/Database/DatabaseChar.cs b/DSACore/Models/Database/DatabaseChar.cs deleted file mode 100644 index 9cd865f..0000000 --- a/DSACore/Models/Database/DatabaseChar.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using DSALib; - -namespace DSACore.Models.Database -{ - 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(DSA_Game.Characters.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(); - } - } -} diff --git a/DSACore/Models/Database/Field.cs b/DSACore/Models/Database/Field.cs deleted file mode 100644 index b14d9da..0000000 --- a/DSACore/Models/Database/Field.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - public class Field - { - public Field(string name, int value = 0) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - this.Value = value; - } - - public string Name { get; set; } - public int Value { get; set; } - } -} diff --git a/DSACore/Models/Database/GeneralSpell.cs b/DSACore/Models/Database/GeneralSpell.cs deleted file mode 100644 index f53081e..0000000 --- a/DSACore/Models/Database/GeneralSpell.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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() - { - } - } -} diff --git a/DSACore/Models/Database/Group.cs b/DSACore/Models/Database/Group.cs deleted file mode 100644 index a7bb929..0000000 --- a/DSACore/Models/Database/Group.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - public class Group - { - public string Name { get; set; } - public string Discord { get; set; } - public string Password { get; set; } - public int Id { get; set; } - public List Chars { get; set; }= new List(); - - } - - -} diff --git a/DSACore/Models/Database/GroupChar.cs b/DSACore/Models/Database/GroupChar.cs deleted file mode 100644 index 1dfc4ea..0000000 --- a/DSACore/Models/Database/GroupChar.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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; } - } -} diff --git a/DSACore/Models/Database/Groups/DSAGroup.cs b/DSACore/Models/Database/Groups/DSAGroup.cs new file mode 100644 index 0000000..8f20278 --- /dev/null +++ b/DSACore/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/DSACore/Models/Database/Groups/Group.cs b/DSACore/Models/Database/Groups/Group.cs new file mode 100644 index 0000000..23e5f68 --- /dev/null +++ b/DSACore/Models/Database/Groups/Group.cs @@ -0,0 +1,13 @@ +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; } + + } + + +} diff --git a/DSACore/Models/Database/Inventory.cs b/DSACore/Models/Database/Inventory.cs deleted file mode 100644 index e6b47ec..0000000 --- a/DSACore/Models/Database/Inventory.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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(); - } -} diff --git a/DSACore/Models/Database/Talent.cs b/DSACore/Models/Database/Talent.cs deleted file mode 100644 index aca65a4..0000000 --- a/DSACore/Models/Database/Talent.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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]; - } -} diff --git a/DSACore/Models/Database/Weapon.cs b/DSACore/Models/Database/Weapon.cs deleted file mode 100644 index b2f8a1e..0000000 --- a/DSACore/Models/Database/Weapon.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace DSACore.Models.Database -{ - 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 string TpKK { get; set; } - public int INI { get; set; } - public string MW { get; set; } - - public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price) - { - } - } - - public class RangedWeapon : Weapon - { - 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; } - - public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name, damage, weight, weaponTalent, price) - { - } - } -} diff --git a/DSACore/Models/Database/WeaponTalent.cs b/DSACore/Models/Database/WeaponTalent.cs deleted file mode 100644 index 4b98d24..0000000 --- a/DSACore/Models/Database/WeaponTalent.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace DSACore.Models.Database -{ - 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/DSACore/Models/Network/Token.cs b/DSACore/Models/Network/Token.cs new file mode 100644 index 0000000..0021317 --- /dev/null +++ b/DSACore/Models/Network/Token.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.EntityFrameworkCore; + +namespace DSACore.Models.Network +{ + public class Token + { + public string Group { get; set; } + private DateTime creation = DateTime.Now; + + public Token(string @group) + { + Group = @group; + } + + public bool IsValid() + { + return DateTime.Now - creation < TimeSpan.FromMinutes(1); + } + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf