test(app): D.2b-B B-Wire — burden wire-first + live-refresh tests + review notes
Final-review response. Adds the spec §5 / Task-16 burden end-to-end coverage the per-task plan missed: (1) burden reads wire EncumbranceVal over the carried sum (asserts 50% from wire 7500, not 20% from sum 3000 — retires AP-48's fallback as the primary), (2) a live player-int update repaints the bar (60%), which only happens via the C1d Concerns `o.ObjectId == p` branch. Both are discriminating (fail if the respective branch is reverted). Plus two clarifying comments from the review: the 0x02CD player route depends on the login PD upsert having created the player object (no-ops, no phantom, if not); and a TODO that the container-open phase must treat ViewContents as a full replace, not the additive merge used here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aa0ecaeb4d
commit
7badecf387
3 changed files with 48 additions and 1 deletions
|
|
@ -152,6 +152,46 @@ public class InventoryControllerTests
|
|||
Assert.Contains("Contents of Backpack", CaptionText(contentsCap));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Burden_reads_wire_EncumbranceVal_over_carried_sum()
|
||||
{
|
||||
// B-Wire: the burden bar must read the server's wire EncumbranceVal (PropertyInt 5),
|
||||
// NOT the client-side carried-Burden sum (retires AP-48 — the sum is only the fallback).
|
||||
var (layout, _, _, _, meter, burdenText, _, _) = BuildLayout();
|
||||
var objects = new ClientObjectTable();
|
||||
// Str 100 → capacity 15000. A carried item sums to 3000 (would read 20%), but the
|
||||
// server says EncumbranceVal = 7500 → load 0.5 → fill 0.1667 → "50%". Wire wins.
|
||||
objects.AddOrUpdate(new ClientObject { ObjectId = 0xA, ContainerId = Player, Burden = 3000 });
|
||||
var bundle = new PropertyBundle();
|
||||
bundle.Ints[5] = 7500; // EncumbranceVal (PropertyInt 5)
|
||||
objects.UpsertProperties(Player, bundle);
|
||||
|
||||
Bind(layout, objects, strength: 100);
|
||||
|
||||
Assert.Equal(0.16667f, meter.Fill() ?? -1f, 3); // 7500/15000/3 (wire), not 3000-based 0.0667
|
||||
Assert.Contains("50%", CaptionText(burdenText)); // not "20%"
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Live_player_int_update_refreshes_burden()
|
||||
{
|
||||
// B-Wire C1d: a live PrivateUpdatePropertyInt (0x02CD) for the player's EncumbranceVal
|
||||
// fires ObjectUpdated on the PLAYER object; Concerns now includes o.ObjectId == player,
|
||||
// so the burden bar repaints. Without the C1d branch this update would be ignored.
|
||||
var (layout, _, _, _, meter, burdenText, _, _) = BuildLayout();
|
||||
var objects = new ClientObjectTable();
|
||||
var bundle = new PropertyBundle();
|
||||
bundle.Ints[5] = 3000; // initial EncumbranceVal → load 0.2 → "20%"
|
||||
objects.UpsertProperties(Player, bundle);
|
||||
Bind(layout, objects, strength: 100);
|
||||
Assert.Contains("20%", CaptionText(burdenText));
|
||||
|
||||
objects.UpdateIntProperty(Player, 5u, 9000); // live 0x02CD: → load 0.6 → "60%"
|
||||
|
||||
Assert.Contains("60%", CaptionText(burdenText));
|
||||
Assert.Equal(0.2f, meter.Fill() ?? -1f, 3); // 9000/15000/3
|
||||
}
|
||||
|
||||
// Reads the text of the UiText caption child attached by the controller.
|
||||
private static string CaptionText(UiElement host)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue