acdream/tests/AcDream.Core.Tests/Items/BurdenMathTests.cs
Erik 1ccf07b705 fix(ui): D.2b-B — address phase-boundary review (burden % saturation + equipped filter)
Opus phase-boundary review findings:
- I1 (faithfulness): LoadToPercent now computes from the CLAMPED fill
  (floor(LoadToFill(load)*300)), so the burden % SATURATES at 300% like retail
  (decomp 176544-176576 clamps arg2 to [0,1] BEFORE the *300). The old
  floor(load*100) over-read to 400% at 4x capacity. Golden test corrected.
- I2 (partition): exclude equipped items (CurrentlyEquippedLocation != None) from
  the contents grid + selector — a mid-session self-wield routes them through
  MoveItem(item, WielderGuid=player) into GetContents(player); retail's gm3DItemsUI
  shows pack contents only. New conformance test.
- N1: drop dead 'using System.Collections.Generic' (left after the 383e8b7 cleanup).
- N3: AP-48 risk wording (drift can be low OR high vs server EncumbranceVal).

Build green; BurdenMath 17, InventoryController/UiMeter 10 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 09:28:29 +02:00

40 lines
1.5 KiB
C#

using AcDream.Core.Items;
using Xunit;
namespace AcDream.Core.Tests.Items;
public class BurdenMathTests
{
[Theory]
[InlineData(100, 0, 15000)] // base: str*150
[InlineData(100, 3, 24000)] // +clamp(3*30,0,150)=90 -> +90*100
[InlineData(100, 10, 30000)] // 10*30=300 clamped to 150 -> +150*100
[InlineData(0, 5, 0)] // str<=0 -> 0
public void EncumbranceCapacity_matches_retail(int str, int aug, int expected)
=> Assert.Equal(expected, BurdenMath.EncumbranceCapacity(str, aug));
[Theory]
[InlineData(15000, 7500, 0.5f)]
[InlineData(15000, 0, 0f)]
[InlineData(0, 100, 0f)] // cap<=0 guard
public void LoadRatio_is_burden_over_capacity(int cap, int burden, float expected)
=> Assert.Equal(expected, BurdenMath.LoadRatio(cap, burden), 4);
[Theory]
[InlineData(0f, 0f)]
[InlineData(0.5f, 0.16667f)]
[InlineData(1.0f, 0.33333f)]
[InlineData(3.0f, 1.0f)] // full at 300%
[InlineData(4.0f, 1.0f)] // clamped
public void LoadToFill_is_third_clamped(float load, float expected)
=> Assert.Equal(expected, BurdenMath.LoadToFill(load), 4);
[Theory]
[InlineData(0f, 0)]
[InlineData(0.5f, 50)]
[InlineData(1.0f, 100)]
[InlineData(3.0f, 300)] // 300% = full
[InlineData(4.0f, 300)] // SATURATES at 300% (computed from the clamped fill, decomp 176544-176576)
public void LoadToPercent_saturates_at_300(float load, int expected)
=> Assert.Equal(expected, BurdenMath.LoadToPercent(load));
}