private async Task <ServiceResponse> AddRaidAsync(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, int gymId, int level, RaidbossPokemon raidbossPokemon, TimeSpan timeLeft, RaidOcrResult raidOcrResult, FenceConfiguration[] fences, int interactiveLimit) { IPokemon pokemon = null; IRaidboss raidboss = null; if (raidbossPokemon != null) { pokemon = raidbossPokemon.Pokemon; raidboss = raidbossPokemon.Raidboss; } // aka (Unit)TestMode if (!SaveDebugImages) { return(await RaidService.AddResolveGymAsync(textResource, requestStartInUtc, userZone, gymId, (byte)level, pokemon, raidboss, timeLeft, interactiveLimit, fences)); } else { return(await ReturnTestInformation(raidOcrResult)); } }
private async Task <ServiceResponse> AddResolveGymAsync(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, string gymName, byte level, IPokemon pokemon, IRaidboss raidboss, TimeSpan timeSpan, int interactiveLimit, FenceConfiguration[] fences) { var gymResponse = await GymService.GetGymAsync(textResource, gymName, interactiveLimit, (selectedGymId) => AddResolveGymAsync(textResource, requestStartInUtc, userZone, selectedGymId, level, pokemon, raidboss, timeSpan, interactiveLimit, fences), fences); if (!gymResponse.IsSuccess) { return(gymResponse); } return(await AddSaveAsync(textResource, requestStartInUtc, userZone, gymResponse.Result, level, pokemon, raidboss, timeSpan)); }
public async Task <ServiceResponse> HatchSaveAsync(Type textResource, IGym gym, IPokemon pokemon, IRaidboss raidboss, int interactiveLimit) { var beforeSpawnTime = SystemClock.Instance.GetCurrentInstant().Minus(Duration.FromMinutes(90)).ToUnixTimeSeconds(); var raid = await RaidRepository.FindAsync(e => e.FortId == gym.Id && e.TimeSpawn > beforeSpawnTime); if (raid == null) { return(new ServiceResponse(false, LocalizationService.Get(textResource, "Raids_Errors_Hatch_NoEntryFound", gym.Name))); } raid.PokemonId = (short)raidboss.Id; await RaidRepository.SaveAsync(); await GymService.UpdateGymAsync(gym); return(new ServiceResponse(true, LocalizationService.Get(textResource, "Raids_Messages_BossHatched", pokemon.Name, gym.Name))); }
public async Task <ServiceResponse> HatchResolveGymWithIdAsync(Type textResource, int gymId, IPokemon pokemon, IRaidboss raidboss, int interactiveLimit) { var gym = await GymService.GetGymByIdAsync(gymId); return(await HatchSaveAsync(textResource, gym, pokemon, raidboss, interactiveLimit)); }
public async Task <ServiceResponse> HatchResolveGymAsync(Type textResource, string gymName, IPokemon pokemon, IRaidboss raidboss, int interactiveLimit, FenceConfiguration[] fences) { var gymResponse = await GymService.GetGymAsync(textResource, gymName, interactiveLimit, (selectedGymId) => HatchResolveGymWithIdAsync(textResource, selectedGymId, pokemon, raidboss, interactiveLimit), fences); if (!gymResponse.IsSuccess) { return(gymResponse); } return(await HatchSaveAsync(textResource, gymResponse.Result, pokemon, raidboss, interactiveLimit)); }
private async Task <ServiceResponse> AddSaveAsync(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, IGym gym, byte level, IPokemon pokemon, IRaidboss raidboss, TimeSpan timeSpan) { var utcNowAfterProcessing = SystemClock.Instance.GetCurrentInstant().InUtc(); var processingTime = utcNowAfterProcessing.Minus(requestStartInUtc); var durationMinusProcessing = Duration.FromTimeSpan(timeSpan).Minus(processingTime); var expiry = utcNowAfterProcessing.Plus(durationMinusProcessing).ToInstant(); // Create the raid entry var beforeSpawnTime = utcNowAfterProcessing.Minus(Duration.FromMinutes(105)).ToInstant().ToUnixTimeSeconds(); var raid = await RaidRepository.FindAsync(e => e.FortId == gym.Id && e.TimeSpawn > beforeSpawnTime); if (raid == null) { raid = RaidRepository.CreateInstance(); raid.ExternalId = ThreadLocalRandom.NextLong(); raid.FortId = gym.Id; RaidRepository.Add(raid); } string message; if (raidboss == null) { raid.Level = level; raid.TimeSpawn = (int)expiry.Minus(_eggDuration).ToUnixTimeSeconds(); raid.TimeBattle = (int)expiry.ToUnixTimeSeconds(); raid.TimeEnd = (int)expiry.Plus(_raidDuration).ToUnixTimeSeconds(); message = LocalizationService.Get(textResource, "Raids_Messages_EggAdded", level, gym.Name, FormatExpiry(expiry, userZone)); } else { raid.PokemonId = (short)raidboss.Id; raid.Level = level; raid.TimeSpawn = (int)expiry.Minus(Duration.FromMinutes(105)).ToUnixTimeSeconds(); raid.TimeBattle = (int)expiry.Minus(Duration.FromMinutes(45)).ToUnixTimeSeconds(); raid.TimeEnd = (int)expiry.ToUnixTimeSeconds(); message = LocalizationService.Get(textResource, "Raids_Messages_BossAdded", pokemon.Name, gym.Name, FormatExpiry(expiry, userZone)); } await RaidRepository.SaveAsync(); await GymService.UpdateGymAsync(gym); return(new ServiceResponse(true, message)); }
public async Task <ServiceResponse> AddResolveGymAsync(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, int gymId, byte level, IPokemon pokemon, IRaidboss raidboss, TimeSpan timeSpan, int interactiveLimit, FenceConfiguration[] fences) { var gym = await GymService.GetGymByIdAsync(gymId); return(await AddSaveAsync(textResource, requestStartInUtc, userZone, gym, level, pokemon, raidboss, timeSpan)); }
public RaidbossPokemon(IPokemon pokemon, IRaidboss raidboss) { Pokemon = pokemon; Raidboss = raidboss; }