mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix spiral abyss crash when using 4.2 metadata
This commit is contained in:
@@ -19,6 +19,8 @@ internal static class MonsterRelationship
|
||||
5071U => 507U, // 幻形花鼠 · 水 (强化)
|
||||
5102U => 510U, // 历经百战的浊水粉碎幻灵
|
||||
5112U => 511U, // 历经百战的浊水喷吐幻灵
|
||||
30605U => 30603U, // 历经百战的霜剑律从
|
||||
30606U => 30604U, // 历经百战的幽风铃兰
|
||||
60402U => 60401U, // (火)岩龙蜥
|
||||
60403U => 60401U, // (冰)岩龙蜥
|
||||
60404U => 60401U, // (雷)岩龙蜥
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
using Snap.Hutao.Core.Abstraction;
|
||||
using Snap.Hutao.Model.Metadata;
|
||||
using Snap.Hutao.Model.Metadata.Tower;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||
|
||||
@@ -12,7 +13,7 @@ internal sealed class BattleWave : IMappingFrom<BattleWave, TowerWave, SpiralAby
|
||||
private BattleWave(TowerWave towerWave, SpiralAbyssMetadataContext context)
|
||||
{
|
||||
Description = towerWave.Type.GetLocalizedDescriptionOrDefault() ?? SH.ModelMetadataTowerWaveTypeDefault;
|
||||
Monsters = towerWave.Monsters.SelectList(m => MonsterView.From(m, context.IdMonsterMap[MonsterRelationship.Normalize(m.Id)]));
|
||||
Monsters = towerWave.Monsters.SelectList(m => CreateMonsterViewOrDefault(m, context));
|
||||
}
|
||||
|
||||
public string Description { get; }
|
||||
@@ -23,4 +24,12 @@ internal sealed class BattleWave : IMappingFrom<BattleWave, TowerWave, SpiralAby
|
||||
{
|
||||
return new(tower, context);
|
||||
}
|
||||
|
||||
private static MonsterView CreateMonsterViewOrDefault(TowerMonster towerMonster, SpiralAbyssMetadataContext context)
|
||||
{
|
||||
MonsterRelationshipId normalizedId = MonsterRelationship.Normalize(towerMonster.Id);
|
||||
return context.IdMonsterMap.TryGetValue(normalizedId, out Model.Metadata.Monster.Monster? metadataMonster)
|
||||
? MonsterView.From(towerMonster, metadataMonster)
|
||||
: MonsterView.Default(normalizedId);
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,19 @@ using Snap.Hutao.Core.Abstraction;
|
||||
using Snap.Hutao.Model;
|
||||
using Snap.Hutao.Model.Metadata.Converter;
|
||||
using Snap.Hutao.Model.Metadata.Tower;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||
|
||||
internal sealed class MonsterView : INameIcon, IMappingFrom<MonsterView, TowerMonster, Model.Metadata.Monster.Monster>
|
||||
{
|
||||
private MonsterView(MonsterRelationshipId id)
|
||||
{
|
||||
Name = $"Unknown {id}";
|
||||
Icon = Web.HutaoEndpoints.UIIconNone;
|
||||
Count = 1;
|
||||
}
|
||||
|
||||
private MonsterView(TowerMonster towerMonster, Model.Metadata.Monster.Monster metaMonster)
|
||||
{
|
||||
Name = metaMonster.Name;
|
||||
@@ -19,6 +27,11 @@ internal sealed class MonsterView : INameIcon, IMappingFrom<MonsterView, TowerMo
|
||||
AttackMonolith = towerMonster.AttackMonolith;
|
||||
}
|
||||
|
||||
public static MonsterView Default(MonsterRelationshipId id)
|
||||
{
|
||||
return new(id);
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public Uri Icon { get; }
|
||||
|
||||
Reference in New Issue
Block a user