Skip to content

Commit

Permalink
Fix change tracker error with rotating gifts (#729)
Browse files Browse the repository at this point in the history
Golden chalice appears twice in the rotating gift list, so we must
continually update the dict as we go along
  • Loading branch information
SapiensAnatis authored Mar 20, 2024
1 parent 2b87200 commit 77a14f6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,36 @@ await this
.Be(100, because: "the reset action should not affect stored gifts");
}

[Fact]
public async Task LoginIndex_LastLoginBeforeReset_NoDragonGifts_ResetsDragonGiftCount()
{
await this
.ApiContext.PlayerDragonGifts.Where(x => x.ViewerId == ViewerId)
.ExecuteDeleteAsync();

this.MockTimeProvider.SetUtcNow(
new DateTimeOffset(2049, 03, 15, 23, 13, 59, TimeSpan.Zero)
); // Monday

await this.Client.PostMsgpack<LoginIndexResponse>("/login/index", new LoginIndexRequest());

List<DbPlayerDragonGift> dbPlayerDragonGifts = await this.GetDragonGifts();

dbPlayerDragonGifts
.Where(x => x.DragonGiftId <= DragonGifts.HeartyStew)
.Should()
.AllSatisfy(
x => x.Quantity.Should().Be(1),
because: "purchasable gifts should be reset"
);

dbPlayerDragonGifts
.Should()
.Contain(x => x.DragonGiftId == DragonGifts.JuicyMeat)
.Which.Quantity.Should()
.Be(1, because: "the current day's rotating gift should be made available");
}

[Fact]
public async Task LoginIndex_GrantsLoginBonusBasedOnDb_GrantsEachDayReward()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public async Task Apply()
};

apiContext.PlayerDragonGifts.Add(dbGift);

dbGifts[giftId] = dbGift;
}

dbGift.Quantity = 1;
Expand All @@ -56,6 +58,8 @@ public async Task Apply()
};

apiContext.PlayerDragonGifts.Add(dbGift);

dbGifts[dailyGiftId] = dbGift;
}

if (dayNo == (int)todayDayOfWeek)
Expand Down

0 comments on commit 77a14f6

Please sign in to comment.