From b7ef3c860375baea7b5db95940519ce0746b6ecc Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Mon, 1 Oct 2018 22:20:36 +0200 Subject: added Command Response Handling --- DSACore/Models/Database/DatabaseChar.cs | 16 ++++++++++++++++ DSACore/Models/Database/GeneralSpell.cs | 4 ++++ DSACore/Models/Database/Talent.cs | 9 +++++++++ DSACore/Models/Network/CommandResponse.cs | 31 +++++++++++++++++++++++++++++++ DSACore/Models/Network/Group.cs | 25 +++++++++++++++---------- 5 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 DSACore/Models/Network/CommandResponse.cs (limited to 'DSACore/Models') diff --git a/DSACore/Models/Database/DatabaseChar.cs b/DSACore/Models/Database/DatabaseChar.cs index 03383b8..9cd865f 100644 --- a/DSACore/Models/Database/DatabaseChar.cs +++ b/DSACore/Models/Database/DatabaseChar.cs @@ -8,6 +8,22 @@ 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; } diff --git a/DSACore/Models/Database/GeneralSpell.cs b/DSACore/Models/Database/GeneralSpell.cs index 6a6e94c..f53081e 100644 --- a/DSACore/Models/Database/GeneralSpell.cs +++ b/DSACore/Models/Database/GeneralSpell.cs @@ -17,5 +17,9 @@ namespace DSACore.Models.Database public GeneralSpell(string name, string roll) : base(name, roll) { } + + public GeneralSpell() + { + } } } diff --git a/DSACore/Models/Database/Talent.cs b/DSACore/Models/Database/Talent.cs index 117d0f7..aca65a4 100644 --- a/DSACore/Models/Database/Talent.cs +++ b/DSACore/Models/Database/Talent.cs @@ -7,6 +7,15 @@ 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)); diff --git a/DSACore/Models/Network/CommandResponse.cs b/DSACore/Models/Network/CommandResponse.cs new file mode 100644 index 0000000..ed4b7d0 --- /dev/null +++ b/DSACore/Models/Network/CommandResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +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; private set; } + public ResponseType ResponseType { get; private set;} + + public override string ToString() + { + return message; + } + } + + public enum ResponseType + { + Broadcast, + Caller, + Error + } +} diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs index 6e62dc8..76c3efb 100644 --- a/DSACore/Models/Network/Group.cs +++ b/DSACore/Models/Network/Group.cs @@ -7,18 +7,15 @@ namespace DSACore.Models.Network { public class Group { - private int _online; - public Group(string name, string password) { Name = name; Password = password; } - public Group(string name, int userCount) + public Group(string name, int userOnline) { Name = name ?? throw new ArgumentNullException(nameof(name)); - UserCount = userCount; } public string Name { get; set; } @@ -27,18 +24,26 @@ namespace DSACore.Models.Network public int UserCount { - get { return _online; RefreshOnline();} - set { _online = value; RefreshOnline();} + get { return Users.Count; } } - private void RefreshOnline() + public SendGroup SendGroup() { - _online = Users.Count; + return new SendGroup( Name, UserCount); } + } - public Group SendGroup() + public class SendGroup + { + public SendGroup(string name, int userCount) { - return new Group( Name, UserCount); + Name = name ?? throw new ArgumentNullException(nameof(name)); + UserCount = userCount; } + + public string Name { get; set; } + + public int UserCount { get; set; } + } } -- cgit v1.2.3-54-g00ecf