diff --git a/Fuyu.Backend.Core/DTO/Accounts/Account.cs b/Fuyu.Backend.Core/DTO/Accounts/Account.cs index eb7624c..519ccc7 100644 --- a/Fuyu.Backend.Core/DTO/Accounts/Account.cs +++ b/Fuyu.Backend.Core/DTO/Accounts/Account.cs @@ -16,6 +16,6 @@ public class Account public string Password; [DataMember] - public Dictionary> Games; + public Dictionary Games; } } \ No newline at end of file diff --git a/Fuyu.Backend.Core/Services/AccountService.cs b/Fuyu.Backend.Core/Services/AccountService.cs index b22efd7..88e6665 100644 --- a/Fuyu.Backend.Core/Services/AccountService.cs +++ b/Fuyu.Backend.Core/Services/AccountService.cs @@ -121,10 +121,10 @@ public static ERegisterStatus RegisterAccount(string username, string password) Id = GetNewAccountId(), Username = username.ToLowerInvariant(), Password = password, - Games = new Dictionary>() + Games = new Dictionary { - { "eft", new List() }, - { "arena", new List() }, + { "eft", null }, + { "arena", null } } }; @@ -137,6 +137,10 @@ public static ERegisterStatus RegisterAccount(string username, string password) public static ERegisterStatus RegisterGame(string sessionId, string game, string edition) { var account = CoreOrm.GetAccount(sessionId); + if (account.Games.TryGetValue(game, out var aid) && aid.HasValue) + { + return ERegisterStatus.AlreadyExists; + } string address; @@ -170,7 +174,7 @@ public static ERegisterStatus RegisterGame(string sessionId, string game, string var response = Json.Parse(responseJson); // set game account id - account.Games[game].Add(response.AccountId); + account.Games[game] = response.AccountId; } CoreOrm.SetOrAddAccount(account); diff --git a/Fuyu.Tests.Backend.EFT/EndToEnd/BackendTest.cs b/Fuyu.Tests.Backend.EFT/EndToEnd/BackendTest.cs index c423011..efbe359 100644 --- a/Fuyu.Tests.Backend.EFT/EndToEnd/BackendTest.cs +++ b/Fuyu.Tests.Backend.EFT/EndToEnd/BackendTest.cs @@ -39,7 +39,7 @@ public static void AssemblyInitialize(TestContext testContext) Fuyu.Backend.Core.Services.AccountService.RegisterAccount("test-username", "test-password"); var coreSessionId = Fuyu.Backend.Core.Services.AccountService.LoginAccount("test-username", "test-password"); Fuyu.Backend.Core.Services.AccountService.RegisterGame(coreSessionId, "eft", "unheard"); - var eftAccountId = CoreOrm.GetAccount(coreSessionId).Games["eft"][0]; + var eftAccountId = CoreOrm.GetAccount(coreSessionId).Games["eft"].Value; var eftSessionId = Fuyu.Backend.EFT.Services.AccountService.LoginAccount(eftAccountId); // create request clients