Skip to content

Commit

Permalink
Update GachaLogStatisticsTracker.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Dec 6, 2023
1 parent 716abc1 commit d8112f3
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ internal GachaLogStatisticsTracker(Map<int, int> idQualityMap, GachaEventBundle
/// <param name="gachaItems">祈愿记录</param>
public void Track(List<EntityGachaItem> gachaItems)
{
// Ignore items before first star5 item
bool avatarEventFirstStar5Found = false;
bool weaponEventFirstStar5Found = false;
bool standardFirstStar5Found = false;
Expand Down Expand Up @@ -174,6 +175,25 @@ private static void SaveStatistics<T>(AppDbContext appDbContext, IMemoryCache me
appDbContext.SaveChanges();
}

private static bool ImpossiblePresence(FrozenSet<int> upStar5Items, EntityGachaItem item, int quality)
{
// TODO: Handle quality 4
if (quality is 5)
{
if (upStar5Items.Contains(item.ItemId))
{
return false;
}

if (SpecializedGachaLogItems.IsStandardWishItem(item))
{
return false;
}
}

return true;
}

private void TrackForSpecficQueryTypeWish(EntityGachaItem item, ref bool star5Found, ref int lastStar5Counter, ref long totalPullsCounter, Map<int, long> distribution, int pullMaxThreshold)
{
switch (idQualityMap[item.ItemId])
Expand Down Expand Up @@ -220,12 +240,11 @@ private void TrackForSpecficQueryTypeWish(EntityGachaItem item, ref bool star5Fo

private void TryIncreaseCurrentWishItemCounter(EntityGachaItem item, int quality)
{
// TODO: Handle quality 4
if (currentAvatarEvent1.ItemInThisEvent(item))
{
currentAvatarEvent1Counter.IncreaseOne(item.ItemId);

if (quality is 5 && !(currentAvatarEvent1Star5Ids.Contains(item.ItemId) || SpecializedGachaLogItems.IsAvatarStandardWishItem(item)))
if (ImpossiblePresence(currentAvatarEvent1Star5Ids, item, quality))
{
invalidGachaUids.Add(Uid);
}
Expand All @@ -234,7 +253,7 @@ private void TryIncreaseCurrentWishItemCounter(EntityGachaItem item, int quality
{
currentAvatarEvent2Counter.IncreaseOne(item.ItemId);

if (quality is 5 && !(currentAvatarEvent2Star5Ids.Contains(item.ItemId) || SpecializedGachaLogItems.IsAvatarStandardWishItem(item)))
if (ImpossiblePresence(currentAvatarEvent2Star5Ids, item, quality))
{
invalidGachaUids.Add(Uid);
}
Expand All @@ -243,7 +262,7 @@ private void TryIncreaseCurrentWishItemCounter(EntityGachaItem item, int quality
{
currentWeaponEventCounter.IncreaseOne(item.ItemId);

if (quality is 5 && !(currentWeaponEventStar5Ids.Contains(item.ItemId) || SpecializedGachaLogItems.IsWeaponStandardWishItem(item)))
if (ImpossiblePresence(currentWeaponEventStar5Ids, item, quality))
{
invalidGachaUids.Add(Uid);
}
Expand Down

0 comments on commit d8112f3

Please sign in to comment.