refine code

This commit is contained in:
DismissedLight
2023-07-12 17:27:17 +08:00
parent e065ba0964
commit 4cef096cb5
11 changed files with 65 additions and 55 deletions

View File

@@ -15,44 +15,44 @@ internal static class Materials
{
private static readonly ImmutableHashSet<MaterialId> MondayThursdayItemsInner = new HashSet<MaterialId>
{
104301, 104302, 104303, // 「自由」
104310, 104311, 104312, // 「繁荣」
104320, 104321, 104322, // 「浮世」
104329, 104330, 104331, // 「诤言」
104338, 104339, 104340, // 「公平」
114001, 114002, 114003, 114004, // 高塔孤王
114013, 114014, 114015, 114016, // 孤云寒林
114025, 114026, 114027, 114028, // 远海夷地
114037, 114038, 114039, 114040, // 谧林涓露
114049, 114050, 114051, 114052, // 悠古弦音
104301U, 104302U, 104303U, // 「自由」
104310U, 104311U, 104312U, // 「繁荣」
104320U, 104321U, 104322U, // 「浮世」
104329U, 104330U, 104331U, // 「诤言」
104338U, 104339U, 104340U, // 「公平」
114001U, 114002U, 114003U, 114004U, // 高塔孤王
114013U, 114014U, 114015U, 114016U, // 孤云寒林
114025U, 114026U, 114027U, 114028U, // 远海夷地
114037U, 114038U, 114039U, 114040U, // 谧林涓露
114049U, 114050U, 114051U, 114052U, // 悠古弦音
}.ToImmutableHashSet();
private static readonly ImmutableHashSet<MaterialId> TuesdayFridayItemsInner = new HashSet<MaterialId>
{
104304, 104305, 104306, // 「抗争」
104313, 104314, 104315, // 「勤劳」
104323, 104324, 104325, // 「风雅」
104332, 104333, 104334, // 「巧思」
104341, 104342, 104343, // 「正义」
114005, 114006, 114007, 114008, // 凛风奔狼
114017, 114018, 114019, 114020, // 雾海云间
114029, 114030, 114031, 114032, // 鸣神御灵
114041, 114042, 114043, 114044, // 绿洲花园
114053, 114054, 114055, 114056, // 纯圣露滴
104304U, 104305U, 104306U, // 「抗争」
104313U, 104314U, 104315U, // 「勤劳」
104323U, 104324U, 104325U, // 「风雅」
104332U, 104333U, 104334U, // 「巧思」
104341U, 104342U, 104343U, // 「正义」
114005U, 114006U, 114007U, 114008U, // 凛风奔狼
114017U, 114018U, 114019U, 114020U, // 雾海云间
114029U, 114030U, 114031U, 114032U, // 鸣神御灵
114041U, 114042U, 114043U, 114044U, // 绿洲花园
114053U, 114054U, 114055U, 114056U, // 纯圣露滴
}.ToImmutableHashSet();
private static readonly ImmutableHashSet<MaterialId> WednesdaySaturdayItemsInner = new HashSet<MaterialId>
{
104307, 104308, 104309, // 「诗文」
104316, 104317, 104318, // 「黄金」
104326, 104327, 104328, // 「天光」
104335, 104336, 104337, // 「笃行」
104344, 104345, 104346, // 「秩序」
114009, 114010, 114011, 114012, // 狮牙斗士
114021, 114022, 114023, 114024, // 漆黑陨铁
114033, 114034, 114035, 114036, // 今昔剧画
114045, 114046, 114047, 114048, // 谧林涓露
114057, 114058, 114059, 114060, // 无垢之海
104307U, 104308U, 104309U, // 「诗文」
104316U, 104317U, 104318U, // 「黄金」
104326U, 104327U, 104328U, // 「天光」
104335U, 104336U, 104337U, // 「笃行」
104344U, 104345U, 104346U, // 「秩序」
114009U, 114010U, 114011U, 114012U, // 狮牙斗士
114021U, 114022U, 114023U, 114024U, // 漆黑陨铁
114033U, 114034U, 114035U, 114036U, // 今昔剧画
114045U, 114046U, 114047U, 114048U, // 谧林涓露
114057U, 114058U, 114059U, 114060U, // 无垢之海
}.ToImmutableHashSet();
/// <summary>

View File

@@ -21,7 +21,7 @@ internal sealed partial class Weapon : IStatisticsItemSource, ISummaryItemSource
[JsonIgnore]
public WeaponCollocationView? Collocation { get; set; }
/// <inheritdoc/>
/// <inheritdoc cref="INameQuality.Quality" />
[JsonIgnore]
public QualityType Quality
{

View File

@@ -17,14 +17,6 @@ internal sealed class DailyNoteOptions : DbStoreOptions
{
private readonly IServiceProvider serviceProvider;
private readonly IScheduleTaskInterop scheduleTaskInterop;
private readonly List<NameValue<int>> refreshTimes = new()
{
new(SH.ViewModelDailyNoteRefreshTime4, 240),
new(SH.ViewModelDailyNoteRefreshTime8, 480),
new(SH.ViewModelDailyNoteRefreshTime30, 1800),
new(SH.ViewModelDailyNoteRefreshTime40, 2400),
new(SH.ViewModelDailyNoteRefreshTime60, 3600),
};
private NameValue<int>? selectedRefreshTime;
private bool? isReminderNotification;
@@ -44,7 +36,14 @@ internal sealed class DailyNoteOptions : DbStoreOptions
/// <summary>
/// 刷新时间
/// </summary>
public List<NameValue<int>> RefreshTimes { get => refreshTimes; }
public List<NameValue<int>> RefreshTimes { get; } = new()
{
new(SH.ViewModelDailyNoteRefreshTime4, 240),
new(SH.ViewModelDailyNoteRefreshTime8, 480),
new(SH.ViewModelDailyNoteRefreshTime30, 1800),
new(SH.ViewModelDailyNoteRefreshTime40, 2400),
new(SH.ViewModelDailyNoteRefreshTime60, 3600),
};
/// <summary>
/// 选中的刷新时间

View File

@@ -23,7 +23,7 @@ internal static class GachaStatisticsExtension
{
int sum = 0;
int count = 0;
foreach (byte b in span)
foreach (ref readonly byte b in span)
{
sum += b;
count++;

View File

@@ -75,6 +75,8 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
purpleAvatarCounter.IncreaseOne(avatar);
targetHistoryWishBuilder?.IncreasePurple(avatar);
break;
default:
break;
}
standardWishBuilder.Track(item, avatar, isUp);
@@ -102,6 +104,8 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
targetHistoryWishBuilder?.IncreaseBlue(weapon);
blueWeaponCounter.IncreaseOne(weapon);
break;
default:
break;
}
standardWishBuilder.Track(item, weapon, isUp);

View File

@@ -51,6 +51,8 @@ internal sealed partial class GachaStatisticsSlimFactory : IGachaStatisticsSlimF
case GachaConfigType.WeaponEventWish:
Track(nameQuality, ref weaponOrangeTracker, ref weaponPurpleTracker);
break;
default:
break;
}
}
@@ -85,6 +87,8 @@ internal sealed partial class GachaStatisticsSlimFactory : IGachaStatisticsSlimF
++orangeTracker;
++purpleTracker;
break;
default:
break;
}
}
}

View File

@@ -15,7 +15,6 @@ namespace Snap.Hutao.Service.GachaLog.Factory;
internal sealed class HistoryWishBuilder
{
private readonly GachaEvent gachaEvent;
private readonly GachaConfigType configType;
private readonly Dictionary<IStatisticsItemSource, int> orangeUpCounter = new();
private readonly Dictionary<IStatisticsItemSource, int> purpleUpCounter = new();
@@ -34,24 +33,25 @@ internal sealed class HistoryWishBuilder
public HistoryWishBuilder(GachaEvent gachaEvent, GachaLogServiceContext context)
{
this.gachaEvent = gachaEvent;
configType = gachaEvent.Type;
ConfigType = gachaEvent.Type;
if (configType is GachaConfigType.AvatarEventWish or GachaConfigType.AvatarEventWish2)
switch (ConfigType)
{
orangeUpCounter = gachaEvent.UpOrangeList.Select(id => context.IdAvatarMap[id]).ToDictionary(a => (IStatisticsItemSource)a, a => 0);
purpleUpCounter = gachaEvent.UpPurpleList.Select(id => context.IdAvatarMap[id]).ToDictionary(a => (IStatisticsItemSource)a, a => 0);
}
else if (configType is GachaConfigType.WeaponEventWish)
{
orangeUpCounter = gachaEvent.UpOrangeList.Select(id => context.IdWeaponMap[id]).ToDictionary(w => (IStatisticsItemSource)w, w => 0);
purpleUpCounter = gachaEvent.UpPurpleList.Select(id => context.IdWeaponMap[id]).ToDictionary(w => (IStatisticsItemSource)w, w => 0);
case GachaConfigType.AvatarEventWish or GachaConfigType.AvatarEventWish2:
orangeUpCounter = gachaEvent.UpOrangeList.Select(id => context.IdAvatarMap[id]).ToDictionary(a => (IStatisticsItemSource)a, a => 0);
purpleUpCounter = gachaEvent.UpPurpleList.Select(id => context.IdAvatarMap[id]).ToDictionary(a => (IStatisticsItemSource)a, a => 0);
break;
case GachaConfigType.WeaponEventWish:
orangeUpCounter = gachaEvent.UpOrangeList.Select(id => context.IdWeaponMap[id]).ToDictionary(w => (IStatisticsItemSource)w, w => 0);
purpleUpCounter = gachaEvent.UpPurpleList.Select(id => context.IdWeaponMap[id]).ToDictionary(w => (IStatisticsItemSource)w, w => 0);
break;
}
}
/// <summary>
/// 祈愿配置类型
/// </summary>
public GachaConfigType ConfigType { get => configType; }
public GachaConfigType ConfigType { get; }
/// <inheritdoc cref="GachaEvent.From"/>
public DateTimeOffset From { get => gachaEvent.From; }

View File

@@ -55,7 +55,7 @@ internal sealed class HutaoStatisticsFactory
{
8U => idAvatarMap[item.Item],
5U => idWeaponMap[item.Item],
_ => throw Must.NeverHappen("不支持的物品 Id"),
_ => throw Must.NeverHappen($"不支持的物品 Id{item.Item}"),
};
StatisticsItem statisticsItem = source.ToStatisticsItem(unchecked((int)item.Count));

View File

@@ -117,6 +117,9 @@ internal sealed class TypedWishSummaryBuilder
++totalBluePullTracker;
break;
}
default:
break;
}
}
}

View File

@@ -36,7 +36,7 @@ internal sealed partial class UIGFImportService : IUIGFImportService
.OrderBy(i => i.Id)
.FirstOrDefault()?.Id ?? long.MaxValue;
logger.LogInformation("Last Id to trim with: [{id}]", trimId);
logger.LogInformation("Last Id to trim with: [{Id}]", trimId);
_ = uigf.IsCurrentVersionSupported(out UIGFVersion version);

View File

@@ -36,7 +36,7 @@ internal sealed partial class ManualGameLocator : IGameLocator
if (isPickerOk)
{
string fileName = System.IO.Path.GetFileName(file);
if (fileName == GameConstants.YuanShenFileName || fileName == GameConstants.GenshinImpactFileName)
if (fileName is GameConstants.YuanShenFileName or GameConstants.GenshinImpactFileName)
{
return new(true, file);
}