public static void Boss_StartBimbo() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.Boss_Bimbo = ACTIVE; worldStatRepo.SavePvPWorldStat(stat); }
public static void StopUpdatingWorld() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.WorldIsUpdating = false; worldStatRepo.SavePvPWorldStat(stat); }
public static void Boss_EndValentine() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.Boss_Valentine = COMPLETED; worldStatRepo.SavePvPWorldStat(stat); }
public static void Boss_EndFaeBoss() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.Boss_Faeboss = COMPLETED; worldStatRepo.SavePvPWorldStat(stat); }
public static void Boss_EndMotorcycleGang() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.Boss_MotorcycleGang = COMPLETED; worldStatRepo.SavePvPWorldStat(stat); }
public static void Boss_StartMotorcycleGang() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.Boss_MotorcycleGang = ACTIVE; worldStatRepo.SavePvPWorldStat(stat); }
public static void UpdateWorldTurnCounter_UpdateDone() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var stat = worldStatRepo.PvPWorldStats.First(); stat.WorldIsUpdating = false; stat.LastUpdateTimestamp_Finished = DateTime.UtcNow; worldStatRepo.SavePvPWorldStat(stat); }
public IHttpActionResult Post() { var allowedIps = new List <string> { "127.0.0.1", "::1" }; var owinContext = Request.GetOwinContext(); if (owinContext == null) { return(BadRequest()); } if (!allowedIps.Contains(owinContext.Request.RemoteIpAddress)) { return(Unauthorized()); } IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); var world = worldStatRepo.PvPWorldStats.First(); if (world.TurnNumber == world.RoundDuration && !world.ChaosMode) { var round = Int32.Parse(PvPStatics.AlphaRound.Split(' ')[2]); var errorSavingLeaderboards = false; try { DomainRegistry.Repository.Execute(new SavePvPLeaderboards { RoundNumber = round }); } catch (DomainException) { errorSavingLeaderboards = true; } try { DomainRegistry.Repository.Execute(new SaveXpLeaderboards { RoundNumber = round }); } catch (DomainException) { errorSavingLeaderboards = true; } try { DomainRegistry.Repository.Execute(new SaveItemLeaderboards { RoundNumber = round }); } catch (DomainException) { errorSavingLeaderboards = true; } if (errorSavingLeaderboards) { return(InternalServerError()); } // TODO: Set the turn number to 0 and enable chaos mode once we are confident that leaderboards are saving properly, including achievements and badges return(Ok()); } // Don't do a turn update if the round is over or we're still in an update if (world.TurnNumber >= PvPStatics.RoundDuration || world.WorldIsUpdating) { return(BadRequest()); } // Don't do a turn update if it hasn't been long enough yet var gracePeriodSeconds = 10; // account for delays in fetching the URL var secondsElapsed = DateTime.UtcNow.Subtract(world.LastUpdateTimestamp).TotalSeconds + gracePeriodSeconds; if (secondsElapsed < TurnTimesStatics.GetTurnLengthInSeconds()) { return(BadRequest()); } world.TurnNumber++; world.WorldIsUpdating = true; world.LastUpdateTimestamp = DateTime.UtcNow; // save changes to database worldStatRepo.SavePvPWorldStat(world); try { JokeShopProcedures.SetJokeShopActive(world.JokeShop); WorldUpdateProcedures.UpdateWorld(); } catch (Exception e) { return(InternalServerError(e)); } return(Ok()); }
public void Configuration(IAppBuilder app) { var container = new Container(); var httpConfig = new HttpConfiguration(); var signalrResolver = new SimpleInjectorSignalRDependencyResolver(container); container.RegisterContainer(httpConfig, app.GetDataProtectionProvider); // cross owin and simple injector for OnValidateIdentity app.CreatePerOwinContext(container.GetInstance <ApplicationUserManager>); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, User>( validateInterval: TimeSpan.FromMinutes(5), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.MapScopableHubConnection(async(request, connectionId, next) => { using (AsyncScopedLifestyle.BeginScope(container)) { if (container.GetInstance <IHubRequestAccessor>() is HubRequestAccessor hubRequestAccessor) { hubRequestAccessor.Request = request; } if (container.GetInstance <IHubConnectionIdAccessor>() is HubConnectionIdAccessor hubConnectionIdAccessor) { hubConnectionIdAccessor.ConnectionId = connectionId; } await next(); } }, resolver: signalrResolver); app.Use(async(context, next) => { // check if there is a HttpContext for WebRequestLifestyle to store its scope if (HttpContext.Current != null) { // capture the owin context for any service dependant on it and store it in the async scoped container // this will use WebRequestLifestyle's cache if (container.GetInstance <IOwinContextAccessor>() is OwinContextAccessor webrequestCallContextOwinContextAccessor) { webrequestCallContextOwinContextAccessor.CurrentContext = context; } } using (AsyncScopedLifestyle.BeginScope(container)) { // capture the owin context for any service dependant on it and store it in the async scoped container // this will use AsyncScopedLifestyle's cache if (container.GetInstance <IOwinContextAccessor>() is OwinContextAccessor asyncCallContextOwinContextAccessor) { asyncCallContextOwinContextAccessor.CurrentContext = context; } await next(); } }); app.UseWebApi(httpConfig); AttackProcedures.LoadCovenantOwnersIntoRAM(); DungeonProcedures.GenerateDungeon(); // set chaos mode IPvPWorldStatRepository repo = new EFPvPWorldStatRepository(); var data = repo.PvPWorldStats.FirstOrDefault(); PvPStatics.ChaosMode = data != null ? data.ChaosMode : false; PvPStatics.RoundDuration = data != null ? data.RoundDuration : 5000; TurnTimesStatics.ActiveConfiguration = data != null && TurnTimesStatics.IsValidConfiguration(data.TurnTimeConfiguration) ? data.TurnTimeConfiguration : TurnTimesStatics.FiveMinuteTurns; PvPStatics.AlphaRound = DomainRegistry.Repository.FindSingle(new GetWorld()).RoundNumber ?? PvPStatics.AlphaRound; if (data != null) { JokeShopProcedures.SetJokeShopActive(data.JokeShop); } }
public static DateTime GetLastWorldUpdate() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); return(worldStatRepo.PvPWorldStats.First().LastUpdateTimestamp); }
public static int GetWorldTurnNumber() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); return(worldStatRepo.PvPWorldStats.First().TurnNumber); }
public static PvPWorldStat GetWorldStats() { IPvPWorldStatRepository worldStatRepo = new EFPvPWorldStatRepository(); return(worldStatRepo.PvPWorldStats.First()); }