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
C1 an out-of-range Use now approaches first via the existing client-predicted BeginApproach (Pickup's far-range shape mirrored; retail's ItemHolder::UseObject @0x00588A80 has no range check and the dispatch stays immediate). C2 Add-to-List stages into the Buying tab via VendorStagingList (RemoveProfileFromList's two shapes, pc:200497-200537), Buy All sends ONE batched 0x005F and flushes staging on send exactly as retail does (SendShopEvent -> Flush, pc:204075-204076 — not UseDone-gated), and X-close over a non-empty staging list shows retail's confirm string recovered verbatim from the binary data segment (0x007b5bd8) through the existing dialog factory. C3 the Selling tab's list is the sole drop target (retail's single IsAncestorOfMe gate, pc:204229-204246); VendorSellAcceptability ports InqAcceptability with all rejection strings recovered verbatim from the raw data segment; the sell side prices with BuyPrice (retail's inverted naming: what the vendor PAYS) and 0x0060 carries no trailing currency field, unlike Buy. C4 the status-bar reproduction test PASSES against the production toolbar mount — retail's toolbar shows count + name with the split bar and NO price parenthetical (that figure is the vendor row's own cost text); no code change, the live gate referees. C5 pack order verified correct, untouched. Register: AP-161 narrowed to its two pre-existing cosmetic gaps; AP-162 extended over Buy All; AP-164 (non-sellable bitfield unmodeled), AP-165 (DescStackSize for _maxStackSize in the removal test, bounded), AP-166 (purse text + pending-sell highlight cosmetic) filed. Clean-room complete solution: 11,482 passed / 4 skipped / 0 failed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
174 lines
6 KiB
C#
174 lines
6 KiB
C#
using AcDream.Core.Items;
|
|
|
|
namespace AcDream.Core.Tests.Items;
|
|
|
|
/// <summary>
|
|
/// Conformance tests for <see cref="VendorSellAcceptability"/> — the port of
|
|
/// <c>VendorSellUI::DragItemAcceptable</c> (<c>pc:201195-201307</c>) chained
|
|
/// into <c>VendorProfile::InqAcceptability</c> (<c>pc:484768-484797</c>).
|
|
/// </summary>
|
|
public sealed class VendorSellAcceptabilityTests
|
|
{
|
|
private const uint Armor = (uint)ItemType.Armor;
|
|
private const uint Weapon = (uint)ItemType.Weapon;
|
|
private const uint NoLimit = VendorSellAcceptability.NoLimit;
|
|
|
|
[Fact]
|
|
public void NotOwnedByPlayerIsRejectedBeforeAnyOtherCheck()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: false,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 100,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.NotOwnedByPlayer, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void ANonEmptyContainerBypassesTheTypeAndValueFilterEntirely()
|
|
{
|
|
// pc:201229-201233: GetNumContainedItems > 0 -> accept unconditionally,
|
|
// even though the container's OWN type (Weapon) does not intersect
|
|
// the vendor's merchandise mask (Armor) and it has zero value.
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 3,
|
|
itemTypeMask: Weapon,
|
|
perUnitValue: 0,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.None, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void AWrongItemTypeIsRejected()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Weapon,
|
|
perUnitValue: 100,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.WrongType, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void ZeroPerUnitValueIsRejectedAsNoValue()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 0,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.NoValue, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void AboveTheAuthoredMaxValueIsRejectedAsTooValuable()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 1001,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: 1000u);
|
|
|
|
Assert.Equal(VendorSellRejection.TooValuable, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void ExactlyAtTheAuthoredMaxValueIsAcceptable()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 1000,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 0u,
|
|
merchandiseMaxValue: 1000u);
|
|
|
|
Assert.Equal(VendorSellRejection.None, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void BelowTheAuthoredMinValueIsRejectedAsTooCheap()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 4,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 5u,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.TooCheap, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void NoLimitSentinelDisablesBothMaxAndMinChecks()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: int.MaxValue - 1,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: NoLimit,
|
|
merchandiseMaxValue: NoLimit);
|
|
|
|
Assert.Equal(VendorSellRejection.None, rejection);
|
|
}
|
|
|
|
[Fact]
|
|
public void AnOrdinaryAcceptableItemReturnsNone()
|
|
{
|
|
VendorSellRejection rejection = VendorSellAcceptability.Evaluate(
|
|
ownedByPlayer: true,
|
|
containedItemCount: 0,
|
|
itemTypeMask: Armor,
|
|
perUnitValue: 500,
|
|
merchandiseItemTypes: Armor,
|
|
merchandiseMinValue: 1u,
|
|
merchandiseMaxValue: 10_000u);
|
|
|
|
Assert.Equal(VendorSellRejection.None, rejection);
|
|
}
|
|
|
|
// ---- MessageFor: exact retail strings, recovered from the decompiled ----
|
|
// ---- binary's data segment (see VendorSellAcceptability's doc comment). ----
|
|
|
|
[Theory]
|
|
[InlineData(VendorSellRejection.NotOwnedByPlayer, "You can only sell items you are carrying")]
|
|
[InlineData(VendorSellRejection.CannotBeSoldHere, "That item cannot be sold here")]
|
|
[InlineData(VendorSellRejection.NoValue, "That item has no value and cannot be sold")]
|
|
[InlineData(VendorSellRejection.TooCheap, "That item is too cheap to sell here")]
|
|
[InlineData(VendorSellRejection.TooValuable, "That item is too valuable to sell here")]
|
|
[InlineData(VendorSellRejection.WrongType, "You cannot sell that here")]
|
|
public void MessageForReturnsRetailsExactString(VendorSellRejection rejection, string expected)
|
|
{
|
|
Assert.Equal(expected, VendorSellAcceptability.MessageFor(rejection));
|
|
}
|
|
|
|
[Fact]
|
|
public void MessageForAcceptableReturnsNull()
|
|
{
|
|
Assert.Null(VendorSellAcceptability.MessageFor(VendorSellRejection.None));
|
|
}
|
|
}
|