Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: chapter 10 completion rewards #788

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@ 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, 30).SetProperty(e => e.Exp, 18990)
);

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(88980);
data.UpdateDataList.UserData.Level.Should().BeGreaterThanOrEqualTo(65);
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ISavefileUpdateTest(CustomWebApplicationFactory factory, ITestOutputHelpe
public void ISavefileUpdate_HasExpectedCount()
{
// Update this test when adding a new update.
this.updates.Should().HaveCount(21);
this.updates.Should().HaveCount(22);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using DragaliaAPI.Database.Entities;
using DragaliaAPI.Shared.MasterAsset;
using DragaliaAPI.Shared.MasterAsset.Models.Story;
using Microsoft.EntityFrameworkCore;

namespace DragaliaAPI.Integration.Test.Features.SavefileUpdate;

public class V22UpdateTest : SavefileUpdateTestFixture
{
protected override int StartingVersion => 21;
private const int Chapter10LastStoryId = 1001009;

public V22UpdateTest(CustomWebApplicationFactory factory, ITestOutputHelper outputHelper)
: base(factory, outputHelper) { }

[Fact]
public async Task V22Update_Chapter10Completed_GrantsRewards()
{
await this
.ApiContext.PlayerUserData.Where(x => x.ViewerId == this.ViewerId)
.ExecuteUpdateAsync(u =>
u.SetProperty(e => e.Level, 30).SetProperty(e => e.Exp, 18990)
);

await this
.ApiContext.PlayerPresents.Where(x => x.ViewerId == this.ViewerId)
.ExecuteDeleteAsync();

await this.AddToDatabase(
new DbPlayerStoryState()
{
ViewerId = this.ViewerId,
StoryId = Chapter10LastStoryId,
StoryType = StoryTypes.Quest,
State = StoryState.Read
}
);

await this.LoadIndex();

DbPlayerUserData userData = await this.ApiContext.PlayerUserData.FirstAsync(x =>
x.ViewerId == this.ViewerId
);

userData.Level.Should().Be(65);
userData.Exp.Should().Be(88980);

List<DbPlayerPresent> presentData = await this
.ApiContext.PlayerPresents.Where(x => x.ViewerId == this.ViewerId)
.ToListAsync();

List<QuestStoryReward> rewards = MasterAsset
.QuestStoryRewardInfo.Enumerable.Where(x => x.Id == Chapter10LastStoryId)
.First()
.Rewards.Where(x => x.Type is EntityTypes.Material or EntityTypes.HustleHammer)
.ToList();

presentData.Count.Should().Be(rewards.Count);

foreach (QuestStoryReward reward in rewards)
{
DbPlayerPresent present = presentData.First(x => x.EntityType == reward.Type);
present.EntityQuantity.Should().Be(present.EntityQuantity);
}
}

[Fact]
public async Task V22Update_Chapter10NotCompleted_DoesNotGrantRewards()
{
await this
.ApiContext.PlayerUserData.Where(x => x.ViewerId == this.ViewerId)
.ExecuteUpdateAsync(u =>
u.SetProperty(e => e.Level, 30).SetProperty(e => e.Exp, 18990)
);

await this
.ApiContext.PlayerStoryState.Where(x =>
x.ViewerId == this.ViewerId && x.StoryId == Chapter10LastStoryId
)
.ExecuteDeleteAsync();

await this
.ApiContext.PlayerPresents.Where(x => x.ViewerId == this.ViewerId)
.ExecuteDeleteAsync();

await this.LoadIndex();

DbPlayerUserData userData = await this.ApiContext.PlayerUserData.FirstAsync(x =>
x.ViewerId == this.ViewerId
);

userData.Level.Should().Be(30);
userData.Exp.Should().Be(18990);

List<DbPlayerPresent> presentData = await this
.ApiContext.PlayerPresents.Where(x => x.ViewerId == this.ViewerId)
.ToListAsync();

presentData.Count.Should().Be(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public async Task Import_LoadIndexReturnsImportedSavefile()
await this.Client.PostMsgpack<LoadIndexResponse>("load/index")
).Data;

storedSavefile.UserData.Exp.Should().Be(savefile.UserData.Exp + 69990); // Exp rewarded from V22Update
storedSavefile.UserData.Level.Should().Be(savefile.UserData.Level + 1); // Level diffenece due to exp rewarded from V22Update

storedSavefile
.Should()
.BeEquivalentTo(
Expand Down Expand Up @@ -107,6 +110,9 @@ await this.Client.PostMsgpack<LoadIndexResponse>("load/index")
);
opts.Excluding(x => x.UserData!.Level);
opts.Excluding(x => x.UserData!.Crystal);
opts.Excluding(x => x.UserData!.Exp);
opts.Excluding(x => x.UserData!.LastStaminaSingleUpdateTime);
opts.Excluding(x => x.UserData!.LastStaminaMultiUpdateTime);
opts.Excluding(x => x.TreasureTradeAllList);
opts.Excluding(x => x.MultiServer);
opts.Excluding(x => x.MissionNotice);
Expand Down
Loading
Loading