替换玩家模型素材,添加 ChildrenMap 配置挂点
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using SepCore.Battle;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.UI;
|
||||
@@ -176,6 +177,109 @@ namespace VampireLike.Tests.Gameplay.EditMode
|
||||
Assert.IsTrue(tagTiersContent.Contains("(3)"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WeaponUtility_TryGetNextTierWeaponId_CalculatesAndStopsAtRed()
|
||||
{
|
||||
// 1001 = WeaponKnife White -> 1002 Blue -> 1003 Purple -> 1004 Red -> Stops
|
||||
Assert.IsTrue(WeaponUtility.TryGetNextTierWeaponId(1001, out int next1));
|
||||
Assert.AreEqual(1002, next1);
|
||||
|
||||
Assert.IsTrue(WeaponUtility.TryGetNextTierWeaponId(1002, out int next2));
|
||||
Assert.AreEqual(1003, next2);
|
||||
|
||||
Assert.IsTrue(WeaponUtility.TryGetNextTierWeaponId(1003, out int next3));
|
||||
Assert.AreEqual(1004, next3);
|
||||
|
||||
// Red (4) 无法再升阶
|
||||
Assert.IsFalse(WeaponUtility.TryGetNextTierWeaponId(1004, out int next4));
|
||||
Assert.AreEqual(0, next4);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemTooltipContext_CanCombineFlag_ControlsShowCombineButton()
|
||||
{
|
||||
var rawDataCombinable = new ItemTooltipRawData
|
||||
{
|
||||
Index = 0,
|
||||
ItemType = ItemType.Weapon,
|
||||
Price = 100,
|
||||
Rarity = Rarity.White,
|
||||
CanCombine = true
|
||||
};
|
||||
var contextCombinable = new ItemTooltipContext(rawDataCombinable);
|
||||
Assert.IsTrue(contextCombinable.BasicContext.ShowCombineButton);
|
||||
|
||||
var rawDataNonCombinable = new ItemTooltipRawData
|
||||
{
|
||||
Index = 0,
|
||||
ItemType = ItemType.Weapon,
|
||||
Price = 100,
|
||||
Rarity = Rarity.Red,
|
||||
CanCombine = false
|
||||
};
|
||||
var contextNonCombinable = new ItemTooltipContext(rawDataNonCombinable);
|
||||
Assert.IsFalse(contextNonCombinable.BasicContext.ShowCombineButton);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WeaponSynthesis_NestedBatchUpdate_AtomicallyReplacesMilestonesWithoutIntermediateDip()
|
||||
{
|
||||
var pipeline = new AttributePipeline();
|
||||
pipeline.SetBaseValue(StatType.MaxHp, 100f);
|
||||
|
||||
var tagTier1 = new WeaponTagConfig(CreateBufferForTagConfig(401, (int)WeaponTag.Primitive, 2, StatType.MaxHp, 5f, ModifierType.Flat));
|
||||
var tagTier2 = new WeaponTagConfig(CreateBufferForTagConfig(402, (int)WeaponTag.Primitive, 4, StatType.MaxHp, 12f, ModifierType.Flat));
|
||||
|
||||
// 初始 4 件达成 2 档:100 + 12 = 112 HP
|
||||
pipeline.AddModifier(tagTier2.StatModifierConfigs[0], tagTier2);
|
||||
Assert.AreEqual(112f, pipeline.GetValue(StatType.MaxHp), 1e-4f);
|
||||
|
||||
float currentHealth = 112f;
|
||||
int notificationCount = 0;
|
||||
|
||||
pipeline.OnStatChanged += (statType, newValue) =>
|
||||
{
|
||||
if (statType == StatType.MaxHp)
|
||||
{
|
||||
notificationCount++;
|
||||
if (currentHealth > newValue)
|
||||
{
|
||||
currentHealth = newValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 模拟合成流程:外层 BeginBatchUpdate 包裹
|
||||
// 合成两把武器使得件数从 4 变 3(降至 1 档 5 HP),期间移除 4 档、甚至中间可能短暂降至 0 档
|
||||
using (pipeline.BeginBatchUpdate())
|
||||
{
|
||||
// 模拟第一把武器移除时的内部刷新(嵌套 BatchUpdate)
|
||||
using (pipeline.BeginBatchUpdate())
|
||||
{
|
||||
pipeline.RemoveAllModifiersFromSource(tagTier2);
|
||||
}
|
||||
|
||||
// 此时外层尚未结束,不应触发任何 OnStatChanged,当前血量不应被扣减
|
||||
Assert.AreEqual(0, notificationCount);
|
||||
Assert.AreEqual(112f, currentHealth);
|
||||
|
||||
// 模拟新合成武器挂载后的内部刷新(嵌套 BatchUpdate)
|
||||
using (pipeline.BeginBatchUpdate())
|
||||
{
|
||||
pipeline.AddModifier(tagTier1.StatModifierConfigs[0], tagTier1);
|
||||
}
|
||||
|
||||
Assert.AreEqual(0, notificationCount);
|
||||
}
|
||||
|
||||
// 外层作用域结束后,统一结算一次变化
|
||||
Assert.AreEqual(1, notificationCount);
|
||||
// 最终生命上限为 100 + 5 = 105
|
||||
Assert.AreEqual(105f, pipeline.GetValue(StatType.MaxHp), 1e-4f);
|
||||
// 当前生命平滑裁剪至 105,而不是在中间被 100 裁剪
|
||||
Assert.AreEqual(105f, currentHealth, 1e-4f);
|
||||
}
|
||||
|
||||
private static Luban.ByteBuf CreateBufferForTagConfig(int id, int tag, int requiredCount, StatType statType, float value, ModifierType modType)
|
||||
{
|
||||
var buf = new Luban.ByteBuf();
|
||||
|
||||
Reference in New Issue
Block a user