add enhanced count for composed reliquary sub affix

This commit is contained in:
Lightczx
2023-08-25 14:35:09 +08:00
parent 0fd018f42e
commit 486e7fffd2
5 changed files with 63 additions and 20 deletions

View File

@@ -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<ReliquaryComposedSubProperty> composed, List<ReliquarySubAffixId> 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<ReliquarySubProperty> 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)

View File

@@ -660,10 +660,11 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid ColumnSpacing="6">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock
Style="{StaticResource BaseTextBlockStyle}"
@@ -671,6 +672,21 @@
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
<TextBlock Grid.Column="1" Text="{Binding Value}"/>
<Grid Grid.Column="2" Opacity="0.7">
<Ellipse
Width="16"
Height="16"
Margin="0,0,0,0"
Stroke="{ThemeResource TextFillColorPrimaryBrush}"
StrokeThickness="1"/>
<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="{ThemeResource InfoBadgeValueFontSize}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding EnhancedCount}"/>
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>

View File

@@ -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;
}
/// <summary>
/// 强化次数
/// </summary>
public int EnhancedCount { get; set; }
internal FightProperty Type { get; }
}

View File

@@ -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;
/// <summary>
/// 圣遗物副词条
/// </summary>
[HighQuality]
internal sealed class ReliquarySubProperty
internal class ReliquarySubProperty
{
/// <summary>
/// 构造副属性
/// </summary>
/// <param name="name">名称</param>
/// <param name="value">值</param>
/// <param name="score">评分</param>
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
/// 评分
/// </summary>
internal float Score { get; }
}
}

View File

@@ -22,7 +22,7 @@ internal sealed class ReliquaryView : Equip
/// <summary>
/// 合成的副属性
/// </summary>
public List<ReliquarySubProperty> ComposedSubProperties { get; set; } = default!;
public List<ReliquaryComposedSubProperty> ComposedSubProperties { get; set; } = default!;
/// <summary>
/// 格式化评分