From a0c4dda448af6f8ae6f83a23246fd757a44a2a3e Mon Sep 17 00:00:00 2001 From: jaredstrong89 <106406993+jaredstrong89@users.noreply.github.com> Date: Wed, 8 May 2024 14:10:30 -0500 Subject: [PATCH] Feature: chapter 10 completion rewards --- .../Dragalia/QuestReadStoryTest.cs | 32 ++++++++++ .../DragaliaAPI/Services/Game/StoryService.cs | 62 ++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/DragaliaAPI/DragaliaAPI.Integration.Test/Dragalia/QuestReadStoryTest.cs b/DragaliaAPI/DragaliaAPI.Integration.Test/Dragalia/QuestReadStoryTest.cs index 12d44a5dd..01b9d64fb 100644 --- a/DragaliaAPI/DragaliaAPI.Integration.Test/Dragalia/QuestReadStoryTest.cs +++ b/DragaliaAPI/DragaliaAPI.Integration.Test/Dragalia/QuestReadStoryTest.cs @@ -82,6 +82,38 @@ await this.Client.PostMsgpack( response.UpdateDataList.UserData.TutorialStatus.Should().Be(10600); } + [Fact] + public async Task ReadStory_Chapter10Completion_GrantsRewards() + { + await this + .ApiContext.PlayerUserData.Where(x => x.ViewerId == this.ViewerId) + .ExecuteUpdateAsync(u => u.SetProperty(e => e.Level, 1).SetProperty(e => e.Exp, 0)); + + StoryReadResponse data = ( + await this.Client.PostMsgpack( + "/quest/read_story", + new QuestReadStoryRequest() { QuestStoryId = 1001009 } + ) + ).Data; + + data.UpdateDataList.UserData.Should().NotBeNull(); + data.UpdateDataList.QuestStoryList.Should() + .BeEquivalentTo( + new List() + { + new() { QuestStoryId = 1001009, State = StoryState.Read } + } + ); + data.UpdateDataList.UserData.Exp.Should().BeGreaterThanOrEqualTo(69990); + data.UpdateDataList.UserData.Level.Should().BeGreaterThanOrEqualTo(60); + this.ApiContext.PlayerPresents.Where(x => + x.ViewerId == this.ViewerId && x.EntityType == EntityTypes.HustleHammer + ) + .First() + .EntityQuantity.Should() + .Be(350); + } + [Theory] [InlineData(2044303, Charas.Harle)] [InlineData(2046203, Charas.Origa)] diff --git a/DragaliaAPI/DragaliaAPI/Services/Game/StoryService.cs b/DragaliaAPI/DragaliaAPI/Services/Game/StoryService.cs index 298189d70..c7847b3ce 100644 --- a/DragaliaAPI/DragaliaAPI/Services/Game/StoryService.cs +++ b/DragaliaAPI/DragaliaAPI/Services/Game/StoryService.cs @@ -2,10 +2,13 @@ using DragaliaAPI.Database.Repositories; using DragaliaAPI.Features.Fort; using DragaliaAPI.Features.Missions; +using DragaliaAPI.Features.Player; +using DragaliaAPI.Features.Present; using DragaliaAPI.Features.Reward; using DragaliaAPI.Features.Shop; using DragaliaAPI.Models.Generated; using DragaliaAPI.Shared.Definitions.Enums; +using DragaliaAPI.Shared.Features.Presents; using DragaliaAPI.Shared.MasterAsset; using DragaliaAPI.Shared.MasterAsset.Models.Event; using DragaliaAPI.Shared.MasterAsset.Models.Story; @@ -18,11 +21,13 @@ public class StoryService( ILogger logger, IUserDataRepository userDataRepository, IInventoryRepository inventoryRepository, + IPresentService presentService, ITutorialService tutorialService, IFortRepository fortRepository, IMissionProgressionService missionProgressionService, IRewardService rewardService, - IPaymentService paymentService + IPaymentService paymentService, + IUserService userService ) : IStoryService { private const int DragonStoryWyrmite = 25; @@ -256,6 +261,16 @@ await rewardService.GrantReward( ); } + if (storyId == 1001009) + { + logger.LogDebug("Granting chapter 10 completion rewards."); + + IEnumerable presents = GetChapter10PresentList(); + presentService.AddPresent(presents); + + await userService.AddExperience(69990); + } + return rewardList; } @@ -343,4 +358,49 @@ AtgenBuildEventRewardEntityList reward return questReward; } + + private static List GetChapter10PresentList() + { + Dictionary materialCounts = + new() + { + { Materials.WindOrb, 76 }, + { Materials.StormOrb, 1 }, + { Materials.WaterOrb, 86 }, + { Materials.StreamOrb, 3 }, + { Materials.DelugeOrb, 1 }, + { Materials.FlameOrb, 116 }, + { Materials.BlazeOrb, 7 }, + { Materials.InfernoOrb, 2 }, + { Materials.LightOrb, 270 }, + { Materials.RadianceOrb, 15 }, + { Materials.RefulgenceOrb, 3 }, + { Materials.ShadowOrb, 66 }, + { Materials.Talonstone, 87 }, + { Materials.LightMetal, 18 }, + { Materials.IronOre, 25 }, + { Materials.Granite, 10 }, + { Materials.FiendsClaw, 25 }, + { Materials.FiendsHorn, 10 }, + { Materials.BatsWing, 25 }, + { Materials.AncientBirdsFeather, 10 }, + { Materials.DyrenellAes, 2520 } + }; + + List presents = + new() { new Present(PresentMessage.Chapter10Clear, EntityTypes.HustleHammer, 0, 350) }; + foreach ((Materials material, int count) in materialCounts) + { + presents.Add( + new Present( + PresentMessage.Chapter10Clear, + EntityTypes.Material, + (int)material, + count + ) + ); + } + + return presents; + } }