Skip to content

Commit

Permalink
Feature: chapter 10 completion rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredstrong89 committed May 8, 2024
1 parent e16c9fb commit a0c4dda
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,38 @@ await this.Client.PostMsgpack<QuestReadStoryResponse>(
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<StoryReadResponse>(
"/quest/read_story",
new QuestReadStoryRequest() { QuestStoryId = 1001009 }
)
).Data;

data.UpdateDataList.UserData.Should().NotBeNull();
data.UpdateDataList.QuestStoryList.Should()
.BeEquivalentTo(
new List<QuestStoryList>()
{
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)]
Expand Down
62 changes: 61 additions & 1 deletion DragaliaAPI/DragaliaAPI/Services/Game/StoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,11 +21,13 @@ public class StoryService(
ILogger<StoryService> 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;
Expand Down Expand Up @@ -256,6 +261,16 @@ await rewardService.GrantReward(
);
}

if (storyId == 1001009)
{
logger.LogDebug("Granting chapter 10 completion rewards.");

IEnumerable<Present> presents = GetChapter10PresentList();
presentService.AddPresent(presents);

await userService.AddExperience(69990);
}

return rewardList;
}

Expand Down Expand Up @@ -343,4 +358,49 @@ AtgenBuildEventRewardEntityList reward

return questReward;
}

private static List<Present> GetChapter10PresentList()
{
Dictionary<Materials, int> 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<Present> 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;
}
}

0 comments on commit a0c4dda

Please sign in to comment.