From 50cee50df1ede38dbcdf03d45dd2e893a9dca0e7 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 18 Jun 2026 16:42:58 +0200 Subject: [PATCH] refactor(D.5.4): delete EnrichItem (superseded by Ingest merge-upsert) Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.Core/Items/ClientObjectTable.cs | 31 ------------ .../Items/ClientObjectTableTests.cs | 47 ------------------- 2 files changed, 78 deletions(-) diff --git a/src/AcDream.Core/Items/ClientObjectTable.cs b/src/AcDream.Core/Items/ClientObjectTable.cs index 1be5f3ba..94fa574f 100644 --- a/src/AcDream.Core/Items/ClientObjectTable.cs +++ b/src/AcDream.Core/Items/ClientObjectTable.cs @@ -143,37 +143,6 @@ public sealed class ClientObjectTable return true; } - /// - /// Enrich an already-known object (a stub created from PlayerDescription) with the - /// fuller data carried by its CreateObject (icon, name, type). Returns false if the - /// object isn't tracked yet — phase 1 enriches existing objects only; full - /// CreateObject ingestion of newly-acquired items is the inventory phase. - /// Raises ObjectUpdated whenever the object is found (matching the - /// UpdateProperties convention — it fires on found regardless of whether a field - /// actually changed) so bound widgets (the toolbar) re-render. - /// - /// D.5.1 (2026-06-17): also accepts and - /// from the extended WeenieHeader tail. Both - /// default to 0 (not sent by server). IconComposer.GetIcon already composites - /// underlay/base/overlay in the correct retail layer order and early-returns on 0. - /// - /// - public bool EnrichItem(uint objectId, uint iconId, string name, ItemType type, - uint iconOverlayId = 0, uint iconUnderlayId = 0, uint effects = 0) - { - if (!_objects.TryGetValue(objectId, out var item)) return false; - if (iconId != 0) item.IconId = iconId; - if (!string.IsNullOrEmpty(name)) item.Name = name; - if (type != default) item.Type = type; - if (iconOverlayId != 0) item.IconOverlayId = iconOverlayId; - if (iconUnderlayId != 0) item.IconUnderlayId = iconUnderlayId; - // D.5.2: 0 is a meaningful "no effect" state (e.g. a caster out of mana), - // so assign unconditionally — re-composition reflects the CURRENT state. - item.Effects = effects; - ObjectUpdated?.Invoke(item); - return true; - } - /// /// Apply a patch (e.g. from an /// IdentifyObjectResponse) to an existing object. Individual diff --git a/tests/AcDream.Core.Tests/Items/ClientObjectTableTests.cs b/tests/AcDream.Core.Tests/Items/ClientObjectTableTests.cs index 2aed953f..871451c5 100644 --- a/tests/AcDream.Core.Tests/Items/ClientObjectTableTests.cs +++ b/tests/AcDream.Core.Tests/Items/ClientObjectTableTests.cs @@ -117,40 +117,6 @@ public sealed class ClientObjectTableTests Assert.Equal(0, repo.ObjectCount); } - [Fact] - public void EnrichItem_updatesIconOnExistingStub_andRaisesUpdated() - { - var repo = new ClientObjectTable(); - repo.AddOrUpdate(new ClientObject { ObjectId = 0x5001u, WeenieClassId = 42u }); // stub from PlayerDescription - ClientObject? updated = null; - repo.ObjectUpdated += i => updated = i; - - bool hit = repo.EnrichItem(0x5001u, iconId: 0x06001234u, name: "Mana Stone", type: ItemType.Misc); - - Assert.True(hit); - Assert.Equal(0x06001234u, repo.Get(0x5001u)!.IconId); - Assert.Equal("Mana Stone", repo.Get(0x5001u)!.Name); - Assert.NotNull(updated); - } - - [Fact] - public void EnrichItem_returnsFalse_whenItemUnknown() - { - var repo = new ClientObjectTable(); - Assert.False(repo.EnrichItem(0x9999u, 0x06001234u, "x", ItemType.Misc)); - } - - [Fact] - public void EnrichItem_carriesEffects() - { - var repo = new ClientObjectTable(); - repo.AddOrUpdate(new ClientObject { ObjectId = 0x500000AAu }); - bool ok = repo.EnrichItem(0x500000AAu, iconId: 0x06001234u, name: "Wand", - type: ItemType.Caster, iconOverlayId: 0, iconUnderlayId: 0, effects: 0x1u); - Assert.True(ok); - Assert.Equal(0x1u, repo.Get(0x500000AAu)!.Effects); - } - [Fact] public void UpdateIntProperty_uiEffects_setsEffectsAndFires() { @@ -186,19 +152,6 @@ public sealed class ClientObjectTableTests Assert.Equal(0u, repo.Get(0x500000ACu)!.Effects); } - [Fact] - public void EnrichItem_effectsZero_clearsPriorEffects() - { - // A re-spawn (CreateObject) of a now-inert item carries effects=0; it must - // clear a previously-set effect (unconditional assign, not gated on != 0). - var repo = new ClientObjectTable(); - repo.AddOrUpdate(new ClientObject { ObjectId = 0x500000ADu, Effects = 0x1u }); - bool ok = repo.EnrichItem(0x500000ADu, iconId: 0x06001234u, name: "Wand", - type: ItemType.Caster, effects: 0u); - Assert.True(ok); - Assert.Equal(0u, repo.Get(0x500000ADu)!.Effects); - } - [Fact] public void ClientObject_NewFields_DefaultAndSettable() {