feat: 支持自动刷新价值调整
This commit is contained in:
@@ -4,6 +4,7 @@ using Volo.Abp.Domain.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.DigitalCollectibles.Domain.Entities;
|
||||
using Yi.Framework.DigitalCollectibles.Domain.Shared.Caches;
|
||||
using Yi.Framework.DigitalCollectibles.Domain.Shared.Consts;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.DigitalCollectibles.Domain.Managers;
|
||||
@@ -111,4 +112,36 @@ public class CollectiblesManager:DomainService
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 全量更新藏品价值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateAllValueAsync()
|
||||
{
|
||||
//全部藏品
|
||||
var collectibles = await _collectiblesRepository.GetListAsync();
|
||||
foreach (var item in collectibles)
|
||||
{
|
||||
var defaultValue= item.Rarity.GetDefaultValue();
|
||||
//计算实际的百分比
|
||||
var realValueRate= CalculateValue(item.FindTotal);
|
||||
|
||||
var realValue = Math.Round(defaultValue * realValueRate);
|
||||
item.ValueNumber = realValue.To<decimal>();
|
||||
}
|
||||
|
||||
await _collectiblesRepository.UpdateRangeAsync(collectibles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 价值计算公式
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
private double CalculateValue(double x)
|
||||
{
|
||||
return 0.1 + 0.9 * Math.Exp(-0.00824 * (x - 1));
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class MiningPoolManager : DomainService
|
||||
|
||||
//如果概率是挖到了矿,再从矿物中随机选择一个稀有度,再在当前稀有度中的矿物列表,随机选择一个具体的矿物
|
||||
var pool = await GetMiningPoolContentAsync();
|
||||
if (pool is null|| pool.TotalNumber == 0)
|
||||
if (pool is null || pool.TotalNumber == 0)
|
||||
{
|
||||
throw new UserFriendlyException($"失败,矿池已经被掏空了,请等矿池刷新后再来");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user