diff --git a/src/Perpetuum.RequestHandlers/AdminTools/AccountCreate.cs b/src/Perpetuum.RequestHandlers/AdminTools/AccountCreate.cs index 1a73f75b6..790f0b15d 100644 --- a/src/Perpetuum.RequestHandlers/AdminTools/AccountCreate.cs +++ b/src/Perpetuum.RequestHandlers/AdminTools/AccountCreate.cs @@ -1,6 +1,7 @@ using Perpetuum.Accounting; using Perpetuum.Data; using Perpetuum.Host.Requests; +using System.Data; namespace Perpetuum.RequestHandlers.AdminTools { @@ -26,7 +27,8 @@ public void HandleRequest(IRequest request) CampaignId = "{\"host\":\"tooladmin\"}" }; - if (_accountRepository.Get(account.Email,account.Password) != null) + //If email exists - throw error + if (_accountRepository.Get(account.Email, account.Password) != null) { Message.Builder.FromRequest(request).WithError(ErrorCodes.AccountAlreadyExists).Send(); return; @@ -34,11 +36,6 @@ public void HandleRequest(IRequest request) _accountRepository.Insert(account); - Db.Query().CommandText("extensionPointsInject") - .SetParameter("@accountID", account.Id) - .SetParameter("@points", 40000) - .ExecuteNonQuery(); - Message.Builder.FromRequest(request).SetData(k.account, account.ToDictionary()).Send(); } } diff --git a/src/Perpetuum.RequestHandlers/AdminTools/AccountOpenCreate.cs b/src/Perpetuum.RequestHandlers/AdminTools/AccountOpenCreate.cs index 5f82e09d8..53933c688 100644 --- a/src/Perpetuum.RequestHandlers/AdminTools/AccountOpenCreate.cs +++ b/src/Perpetuum.RequestHandlers/AdminTools/AccountOpenCreate.cs @@ -1,5 +1,4 @@ using Perpetuum.Accounting; -using Perpetuum.Data; using Perpetuum.Host.Requests; using Perpetuum.Services.Relay; @@ -29,7 +28,7 @@ public void HandleRequest(IRequest request) // if an account was already created using this session, reject this creation attempt. if (request.Session.AccountCreatedInSession) { - throw new PerpetuumException(ErrorCodes.AccountAlreadyExists); + throw new PerpetuumException(ErrorCodes.MaxIterationsExceeded); } var account = new Account @@ -40,7 +39,8 @@ public void HandleRequest(IRequest request) CampaignId = "{\"host\":\"opencreate\"}" }; - if (_accountRepository.Get(account.Email,account.Password) != null) + //If email exists - throw error + if (_accountRepository.Get(account.Email, account.Password) != null) { Message.Builder.FromRequest(request).WithError(ErrorCodes.AccountAlreadyExists).Send(); return; @@ -51,11 +51,6 @@ public void HandleRequest(IRequest request) // if we get this far, make sure we can't sit here and make accounts. request.Session.AccountCreatedInSession = true; - Db.Query().CommandText("extensionPointsInject") - .SetParameter("@accountID", account.Id) - .SetParameter("@points", 40000) - .ExecuteNonQuery(); - Message.Builder.FromRequest(request).SetData(k.account, account.ToDictionary()).Send(); } } diff --git a/src/Perpetuum.RequestHandlers/Characters/CharacterCreate.cs b/src/Perpetuum.RequestHandlers/Characters/CharacterCreate.cs index 051ac8815..59cfe378a 100644 --- a/src/Perpetuum.RequestHandlers/Characters/CharacterCreate.cs +++ b/src/Perpetuum.RequestHandlers/Characters/CharacterCreate.cs @@ -61,6 +61,7 @@ public void HandleRequest(IRequest request) if (account.FirstCharacterDate == null) { account.FirstCharacterDate = DateTime.Now; + _accountManager.AddExtensionPoints(account, 40000); //TODO: starting EP - store in DB _accountManager.Repository.Update(account); } diff --git a/src/Perpetuum/Accounting/AccountRepository.cs b/src/Perpetuum/Accounting/AccountRepository.cs index 48d232c46..28c573d4d 100644 --- a/src/Perpetuum/Accounting/AccountRepository.cs +++ b/src/Perpetuum/Accounting/AccountRepository.cs @@ -116,6 +116,15 @@ public Account Get(int accountId, string steamId) return CreateAccountFromRecord(record); } + public Account Get(string email) + { + var record = Db.Query("select * from accounts where email = @email") + .SetParameter("email", email) + .ExecuteSingleRow(); + + return CreateAccountFromRecord(record); + } + public Account Get(string email, string password) { var record = Db.Query("select * from accounts where email = @email and password = @password") diff --git a/src/Perpetuum/Zones/Teleporting/Strategies/TrainingExitStrategy.cs b/src/Perpetuum/Zones/Teleporting/Strategies/TrainingExitStrategy.cs index 48f653244..23e3be035 100644 --- a/src/Perpetuum/Zones/Teleporting/Strategies/TrainingExitStrategy.cs +++ b/src/Perpetuum/Zones/Teleporting/Strategies/TrainingExitStrategy.cs @@ -26,7 +26,7 @@ public class TrainingExitStrategy : ITeleportStrategy public delegate TrainingExitStrategy Factory(TeleportDescription description); - public TrainingExitStrategy(TeleportDescription description,ITrainingRewardRepository trainingRewardRepository,IChannelManager channelManager,CharacterCleaner characterCleaner,SparkHelper sparkHelper) + public TrainingExitStrategy(TeleportDescription description, ITrainingRewardRepository trainingRewardRepository, IChannelManager channelManager, CharacterCleaner characterCleaner, SparkHelper sparkHelper) { _description = description; _trainingRewardRepository = trainingRewardRepository; @@ -45,7 +45,7 @@ public void DoTeleport(Player player) { //Throw if email not confirmed player.Character.GetAccount().EmailConfirmed.ThrowIfFalse(ErrorCodes.EmailNotConfirmed); - + player.States.Dock = true; var character = player.Character; @@ -56,7 +56,7 @@ public void DoTeleport(Player player) var info = GetCharacterWizardInfo(); - var newCorporation = DefaultCorporation.GetBySchool(info.raceId,info.schoolId); + var newCorporation = DefaultCorporation.GetBySchool(info.raceId, info.schoolId); oldCorporation.RemoveMember(character); newCorporation.AddMember(character, CorporationRole.NotDefined, oldCorporation); @@ -123,7 +123,7 @@ private struct CharacterWizardInfo public int schoolId; public int sparkId; - public CharacterWizardInfo(int raceId,int schoolId,int majorId,int sparkId) : this() + public CharacterWizardInfo(int raceId, int schoolId, int majorId, int sparkId) : this() { this.majorId = majorId; this.raceId = raceId;