From 486e7fffd262a8ae36c5063f2eb49e44ebee52bd Mon Sep 17 00:00:00 2001 From: Lightczx <1686188646@qq.com> Date: Fri, 25 Aug 2023 14:35:09 +0800 Subject: [PATCH] add enhanced count for composed reliquary sub affix --- .../Factory/SummaryReliquaryFactory.cs | 25 +++++++++++++------ .../View/Page/AvatarPropertyPage.xaml | 18 ++++++++++++- .../ReliquaryComposedSubProperty.cs | 22 ++++++++++++++++ .../AvatarProperty/ReliquarySubProperty.cs | 16 +++++------- .../ViewModel/AvatarProperty/ReliquaryView.cs | 2 +- 5 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryComposedSubProperty.cs diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/SummaryReliquaryFactory.cs b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/SummaryReliquaryFactory.cs index 4393a93f..34fd6f2a 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/SummaryReliquaryFactory.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/SummaryReliquaryFactory.cs @@ -8,6 +8,7 @@ using Snap.Hutao.Model.Metadata.Reliquary; using Snap.Hutao.Model.Primitive; using Snap.Hutao.ViewModel.AvatarProperty; using Snap.Hutao.Web.Enka.Model; +using System.Runtime.InteropServices; using MetadataReliquary = Snap.Hutao.Model.Metadata.Reliquary.Reliquary; using ModelAvatarInfo = Snap.Hutao.Web.Enka.Model.AvatarInfo; @@ -69,6 +70,8 @@ internal sealed class SummaryReliquaryFactory ArgumentNullException.ThrowIfNull(equip.Flat.ReliquarySubstats); result.ComposedSubProperties = equip.Flat.ReliquarySubstats.SelectList(CreateComposedSubProperty); + ApplyAffixEnhancedCount(result.ComposedSubProperties, equip.Reliquary.AppendPropIdList); + ReliquaryMainAffixLevel relicLevel = metadataContext.ReliquaryLevels.Single(r => r.Level == equip.Reliquary.Level && r.Rank == reliquary.RankLevel); FightProperty property = metadataContext.IdReliquaryMainAffixMap[equip.Reliquary.MainPropId]; @@ -112,11 +115,20 @@ internal sealed class SummaryReliquaryFactory }; } + private void ApplyAffixEnhancedCount(List composed, List appendProps) + { + foreach (ref readonly ReliquarySubAffixId subAffixId in CollectionsMarshal.AsSpan(appendProps)) + { + ReliquarySubAffix subAffix = metadataContext.IdReliquarySubAffixMap[subAffixId]; + composed.Single(prop => prop.Type == subAffix.Type).EnhancedCount++; + } + } + private float ScoreReliquary(FightProperty property, MetadataReliquary reliquary, ReliquaryMainAffixLevel relicLevel, List subProperties) { // 沙/杯/头 // equip.Flat.EquipType is EquipType.EQUIP_SHOES or EquipType.EQUIP_RING or EquipType.EQUIP_DRESS - if (equip.Flat.EquipType > EquipType.EQUIP_SHOES) + if (equip.Flat.EquipType >= EquipType.EQUIP_SHOES) { // 从喵插件抓取的圣遗物评分权重 // 部分复杂的角色暂时使用了默认值 @@ -138,17 +150,17 @@ internal sealed class SummaryReliquaryFactory } } - private ReliquarySubProperty CreateComposedSubProperty(ReliquarySubstat substat) + private ReliquaryComposedSubProperty CreateComposedSubProperty(ReliquarySubstat substat) { FormatMethod method = substat.AppendPropId.GetFormatMethod(); string valueFormatted = method switch { FormatMethod.Integer => $"{MathF.Round(substat.StatValue, MidpointRounding.AwayFromZero)}", - FormatMethod.Percent => $"{substat.StatValue}%", + FormatMethod.Percent => $"{substat.StatValue}%", // Different from FightPropertyFormat.FormatValue _ => $"{substat.StatValue}", }; - return new(substat.AppendPropId.GetLocalizedDescription(), valueFormatted, 0); + return new(substat.AppendPropId, valueFormatted, 0); } [SuppressMessage("", "SH002")] @@ -157,10 +169,7 @@ internal sealed class SummaryReliquaryFactory ReliquarySubAffix affix = metadataContext.IdReliquarySubAffixMap[appendPropId]; FightProperty property = affix.Type; - return new( - property.GetLocalizedDescription(), - FightPropertyFormat.FormatValue(property, affix.Value), - ScoreSubAffix(appendPropId)); + return new(property, FightPropertyFormat.FormatValue(property, affix.Value), ScoreSubAffix(appendPropId)); } private float ScoreSubAffix(in ReliquarySubAffixId appendId) diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml index 35bba5f6..57a1f2b0 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml @@ -660,10 +660,11 @@ - + + + + + + diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryComposedSubProperty.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryComposedSubProperty.cs new file mode 100644 index 00000000..53a7dd82 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryComposedSubProperty.cs @@ -0,0 +1,22 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Model.Intrinsic; + +namespace Snap.Hutao.ViewModel.AvatarProperty; + +internal class ReliquaryComposedSubProperty : ReliquarySubProperty +{ + public ReliquaryComposedSubProperty(FightProperty type, string value, float score) + : base(type, value, score) + { + Type = type; + } + + /// + /// 强化次数 + /// + public int EnhancedCount { get; set; } + + internal FightProperty Type { get; } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquarySubProperty.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquarySubProperty.cs index 9caf7e72..063b15f1 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquarySubProperty.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquarySubProperty.cs @@ -1,23 +1,19 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. +using Snap.Hutao.Model.Intrinsic; + namespace Snap.Hutao.ViewModel.AvatarProperty; /// /// 圣遗物副词条 /// [HighQuality] -internal sealed class ReliquarySubProperty +internal class ReliquarySubProperty { - /// - /// 构造副属性 - /// - /// 名称 - /// 值 - /// 评分 - public ReliquarySubProperty(string name, string value, float score) + public ReliquarySubProperty(FightProperty type, string value, float score) { - Name = name; + Name = type.GetLocalizedDescription(); Value = value; Score = score; @@ -44,4 +40,4 @@ internal sealed class ReliquarySubProperty /// 评分 /// internal float Score { get; } -} +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryView.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryView.cs index 4ead1f70..3d14a34a 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryView.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/ReliquaryView.cs @@ -22,7 +22,7 @@ internal sealed class ReliquaryView : Equip /// /// 合成的副属性 /// - public List ComposedSubProperties { get; set; } = default!; + public List ComposedSubProperties { get; set; } = default!; /// /// 格式化评分