refactor(D.5.4): delete EnrichItem (superseded by Ingest merge-upsert)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-18 16:42:58 +02:00
parent cbbfe4cd49
commit 50cee50df1
2 changed files with 0 additions and 78 deletions

View file

@ -143,37 +143,6 @@ public sealed class ClientObjectTable
return true; return true;
} }
/// <summary>
/// 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.
/// <para>
/// D.5.1 (2026-06-17): also accepts <paramref name="iconOverlayId"/> and
/// <paramref name="iconUnderlayId"/> 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.
/// </para>
/// </summary>
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;
}
/// <summary> /// <summary>
/// Apply a <see cref="PropertyBundle"/> patch (e.g. from an /// Apply a <see cref="PropertyBundle"/> patch (e.g. from an
/// <c>IdentifyObjectResponse</c>) to an existing object. Individual /// <c>IdentifyObjectResponse</c>) to an existing object. Individual

View file

@ -117,40 +117,6 @@ public sealed class ClientObjectTableTests
Assert.Equal(0, repo.ObjectCount); 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] [Fact]
public void UpdateIntProperty_uiEffects_setsEffectsAndFires() public void UpdateIntProperty_uiEffects_setsEffectsAndFires()
{ {
@ -186,19 +152,6 @@ public sealed class ClientObjectTableTests
Assert.Equal(0u, repo.Get(0x500000ACu)!.Effects); 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] [Fact]
public void ClientObject_NewFields_DefaultAndSettable() public void ClientObject_NewFields_DefaultAndSettable()
{ {