🐛 Fix perk subscription getter

This commit is contained in:
2026-02-04 12:43:09 +08:00
parent e86f630024
commit 12199d99b7
8 changed files with 34 additions and 13 deletions

View File

@@ -1,9 +1,10 @@
using DysonNetwork.Shared.Models;
using DysonNetwork.Shared.Registry;
using Microsoft.EntityFrameworkCore;
namespace DysonNetwork.Pass.Leveling;
public class ExperienceService(AppDatabase db)
public class ExperienceService(AppDatabase db, RemoteSubscriptionService subscriptions)
{
public async Task<SnExperienceRecord> AddRecord(string reasonType, string reason, long delta, Guid accountId)
{
@@ -15,6 +16,20 @@ public class ExperienceService(AppDatabase db)
AccountId = accountId,
};
var perkSubscription = await subscriptions.GetPerkSubscription(accountId);
if (perkSubscription is not null)
{
record.BonusMultiplier = perkSubscription.Identifier switch
{
SubscriptionType.Stellar => 1.5,
SubscriptionType.Nova => 2,
SubscriptionType.Supernova => 2.5,
_ => 1
};
if (record.Delta >= 0)
record.Delta = (long)Math.Floor(record.Delta * record.BonusMultiplier);
}
db.ExperienceRecords.Add(record);
await db.SaveChangesAsync();