feat(vendor): Slice 6 buy arc — shop items are real objects, vendor selection is THE selection, and Buy works (0x005F)
Some checks are pending
Headless portability / portable-headless (ubuntu-latest) (push) Waiting to run
Headless portability / portable-headless (windows-latest) (push) Waiting to run
Headless portability / linux-graphical (push) Waiting to run
Headless portability / linux-vulkan (push) Waiting to run
Some checks are pending
Headless portability / portable-headless (ubuntu-latest) (push) Waiting to run
Headless portability / portable-headless (windows-latest) (push) Waiting to run
Headless portability / linux-graphical (push) Waiting to run
Headless portability / linux-vulkan (push) Waiting to run
Three ordered pieces in one landing (the shared controller/composition files carry all three; the internal order was 6.1 -> 6.2 -> 6.3): 6.1 VendorShopItemMaterializer diff-merges the shop list into the live ClientObjectTable on VendorState transitions (so client-local close and session teardown retire the entries too) and never claims a guid it did not add — ACE's UniqueItemsForSale can re-list a guid a player once held (AP-163 files the collision-skip; no retail counterpart traced). Right-click examine on shop items now routes through the ordinary appraisal path — the 5.4 F7c blocker dissolves with the table entries. 6.2 SelectionChangeSource.Vendor: row clicks, auto-select, and examine all flow through the canonical SelectionState; the status bar and the existing byte-faithful StackSplitQuantityState slider light up unmodified. VendorSplitPolicy is the single 0xDC41CB0 mask owner; the slider VALUE seeds to 1 for exempt items while maxSplitSize keeps the stack (the splitSize/maxSplitSize distinction, research §B.3). Selection clears at retail's actual site — VendorItemsUI::RemoveFromShop (pc:202848), not a CloseVendor-level clear that does not exist. 6.3 BuildBuy (0x005F): vendorGuid, count, (i32 amount, u32 guid) pairs, and the trailing alternateCurrencyId the REAL client sends (CM_Vendor::Event_Buy pc:689288) though ACE's reader ignores it. TryBuy rides the EXISTING J5.2 one-request-at-a-time reservation and completes on UseDone; the Buy button disables while a request is in flight. The reconciliation round-trip (money property update, inventory CreateObject, ApproachVendor refresh -> panel rebuild) is proven by a synthetic-inbound test against existing machinery — no new owner. Register: AP-161 narrowed (selection + examine residuals close; staging/Sell remain; double-click-to-buy confirmed ABSENT from retail with negative evidence cited — we match retail). AP-162 files the conscious no-client-side-affordability-precheck deferral. Clean-room complete solution: 11,368 passed / 4 skipped / 0 failed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c884a938e0
commit
97cf873870
19 changed files with 1577 additions and 65 deletions
|
|
@ -27,6 +27,7 @@ public sealed class ItemInteractionControllerTests
|
|||
public readonly List<uint> Drops = new();
|
||||
public readonly List<(uint Item, uint Amount)> SplitDrops = new();
|
||||
public readonly List<(uint Target, uint Item, uint Amount)> Gives = new();
|
||||
public readonly List<(uint VendorGuid, uint ItemGuid, int Amount, uint AlternateCurrencyId)> Buys = new();
|
||||
public readonly List<string> Toasts = new();
|
||||
public readonly List<string> SystemMessages = new();
|
||||
public readonly List<CombatMode> CombatModeRequests = new();
|
||||
|
|
@ -94,7 +95,9 @@ public sealed class ItemInteractionControllerTests
|
|||
},
|
||||
combatState: Combat,
|
||||
sendChangeCombatMode: CombatModeRequests.Add,
|
||||
requestUse: requestUse);
|
||||
requestUse: requestUse,
|
||||
sendBuy: (vendorGuid, itemGuid, amount, alternateCurrencyId) =>
|
||||
Buys.Add((vendorGuid, itemGuid, amount, alternateCurrencyId)));
|
||||
}
|
||||
|
||||
public ItemInteractionController Controller { get; }
|
||||
|
|
@ -2145,4 +2148,123 @@ public sealed class ItemInteractionControllerTests
|
|||
Assert.Equal(0, h.Controller.BusyCount);
|
||||
Assert.Equal(InteractionModeKind.None, h.Controller.InteractionState.Current.Kind);
|
||||
}
|
||||
|
||||
// ── Slice 6.3: TryBuy ───────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_Succeeds_SendsBuyAndTakesTheSharedUseReservation()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
bool result = h.Controller.TryBuy(
|
||||
vendorGuid: 0x40001000u,
|
||||
itemGuid: 0x50002000u,
|
||||
amount: 1,
|
||||
alternateCurrencyId: 0u);
|
||||
|
||||
Assert.True(result);
|
||||
Assert.Equal(
|
||||
new[] { (0x40001000u, 0x50002000u, 1, 0u) },
|
||||
h.Buys);
|
||||
// BeginUseRequestReservation increments BusyCount synchronously,
|
||||
// before/independent of any wire response -- this is what makes the
|
||||
// Buy button disable immediately (research doc §A.4: "no second
|
||||
// gate", the SAME BusyCount>0 check every other request rides).
|
||||
Assert.Equal(1, h.Controller.BusyCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_StackedQuantity_ForwardsTheExactAmount()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002001u, 25, 0u));
|
||||
|
||||
Assert.Equal(25, h.Buys.Single().Amount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_AlternateCurrencyVendor_ForwardsTheCurrencyWcid()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002000u, 1, 0x12345678u));
|
||||
|
||||
Assert.Equal(0x12345678u, h.Buys.Single().AlternateCurrencyId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_WhileAnotherRequestIsBusy_IsRejectedAndSendsNothing()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Controller.IncrementBusyCount(); // simulates any other in-flight request
|
||||
|
||||
bool result = h.Controller.TryBuy(0x40001000u, 0x50002000u, 1, 0u);
|
||||
|
||||
Assert.False(result);
|
||||
Assert.Empty(h.Buys);
|
||||
Assert.Equal(1, h.Controller.BusyCount); // unchanged -- no second reservation taken
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_ASecondBuyWhileTheFirstIsInFlight_IsRejected()
|
||||
{
|
||||
var h = new Harness();
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002000u, 1, 0u));
|
||||
|
||||
bool second = h.Controller.TryBuy(0x40001000u, 0x50002001u, 1, 0u);
|
||||
|
||||
Assert.False(second);
|
||||
Assert.Single(h.Buys);
|
||||
Assert.Equal(1, h.Controller.BusyCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0u, 0x50002000u, 1)]
|
||||
[InlineData(0x40001000u, 0u, 1)]
|
||||
[InlineData(0x40001000u, 0x50002000u, 0)]
|
||||
[InlineData(0x40001000u, 0x50002000u, -1)]
|
||||
public void TryBuy_InvalidArguments_IsRejectedWithoutTakingAReservation(
|
||||
uint vendorGuid, uint itemGuid, int amount)
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
bool result = h.Controller.TryBuy(vendorGuid, itemGuid, amount, 0u);
|
||||
|
||||
Assert.False(result);
|
||||
Assert.Empty(h.Buys);
|
||||
Assert.Equal(0, h.Controller.BusyCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_CompleteUse_ReleasesTheReservationAndReenablesFurtherRequests()
|
||||
{
|
||||
// Research doc §A.4: UseDone (0x01C7) is the completion signal for
|
||||
// Buy, resolved through the SAME RuntimeInteractionTransactionState.
|
||||
// CompleteUse the existing UseDone handler already calls -- no new
|
||||
// completion plumbing needed on the receive side.
|
||||
var h = new Harness();
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002000u, 1, 0u));
|
||||
Assert.Equal(1, h.Controller.BusyCount);
|
||||
|
||||
h.Controller.CompleteUse(0);
|
||||
|
||||
Assert.Equal(0, h.Controller.BusyCount);
|
||||
// The gate is free again -- a second Buy can now proceed.
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002001u, 1, 0u));
|
||||
Assert.Equal(2, h.Buys.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryBuy_FailedUseDone_AlsoReleasesTheReservation()
|
||||
{
|
||||
// A.2's failure paths all still end in exactly one SendUseDoneEvent
|
||||
// -- success or failure, the reservation resolves the same way.
|
||||
var h = new Harness();
|
||||
Assert.True(h.Controller.TryBuy(0x40001000u, 0x50002000u, 1, 0u));
|
||||
|
||||
h.Controller.CompleteUse(0x0009u); // an arbitrary nonzero WeenieError
|
||||
|
||||
Assert.Equal(0, h.Controller.BusyCount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue