Skip to content

Commit

Permalink
Handle Midgardsormr reliability PK error in fallback (#836)
Browse files Browse the repository at this point in the history
The edge case fix in #800 for having full storage when trying to
complete the story that gives you Midgardsormr has its own edge case. It
causes a PK error if you somehow already have Midgardsormr - which is
possible via save editing.
  • Loading branch information
SapiensAnatis authored May 26, 2024
1 parent 8e74d2a commit 8dab367
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,49 @@ await this.Client.PostMsgpack<QuestReadStoryResponse>(
);
}

[Fact]
public async Task ReadStory_Midgardsormr_DoesNotAddReliabilityIfOwned()
{
int midgardStoryId = 1000109;
this.ApiContext.PlayerUserData.ExecuteUpdate(x =>
x.SetProperty(e => e.MaxDragonQuantity, 0)
);

await this.AddToDatabase(
new DbPlayerDragonReliability() { DragonId = Dragons.Midgardsormr }
);

QuestReadStoryResponse response = (
await this.Client.PostMsgpack<QuestReadStoryResponse>(
"/quest/read_story",
new QuestReadStoryRequest() { QuestStoryId = midgardStoryId }
)
).Data;

response.UpdateDataList.UserData.Should().NotBeNull();

response.UpdateDataList.DragonReliabilityList.Should().BeNull();

response
.EntityResult.OverPresentEntityList.Should()
.ContainSingle()
.Which.Should()
.BeEquivalentTo(
new AtgenBuildEventRewardEntityList()
{
EntityType = EntityTypes.Dragon,
EntityId = (int)Dragons.Midgardsormr,
EntityQuantity = 1,
}
);

response
.UpdateDataList.QuestStoryList.Should()
.ContainEquivalentOf(
new QuestStoryList() { QuestStoryId = midgardStoryId, State = StoryState.Read }
);
}

[Fact]
public async Task ReadStory_UpdatesDatabase()
{
Expand Down
7 changes: 6 additions & 1 deletion DragaliaAPI/DragaliaAPI/Features/Story/StoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ out QuestStoryRewardInfo? rewardInfo
)
);

if (reward is { Type: EntityTypes.Dragon, Id: (int)Dragons.Midgardsormr })
if (
reward is { Type: EntityTypes.Dragon, Id: (int)Dragons.Midgardsormr }
&& !await apiContext.PlayerDragonReliability.AnyAsync(x =>
x.DragonId == Dragons.Midgardsormr
)
)
{
// The game doesn't handle it well if you send the Chapter 1 Midgardsormr to the gift box.
// You will later be forced to give him a gift in the dragon's roost tutorial, which will fail
Expand Down

0 comments on commit 8dab367

Please sign in to comment.