mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 18:55:28 +00:00
fix: a trade offer takes no undeletable item and no unapproved model
The client's trade window also refuses an item that can not be deleted and a brick built model whose moderation status is not approved. An offer with such an item is now refused like the other offers the window can not make. Whether an item can be deleted is what the inventory already works out for a delete: not the item of the mount the player rides, and not an item its row of the DeletionRestrictions table restricts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,8 @@ namespace {
|
||||
{ 200, { 3040, 1 } },
|
||||
{ 300, { 1727, 2, true, false } },
|
||||
{ 400, { 1727, 2, false, true } },
|
||||
{ 500, { 1727, 2, false, false, false, true } },
|
||||
{ 600, { 6662, 1, false, false, true, false } },
|
||||
};
|
||||
|
||||
class TradeAcceptTest : public GameDependenciesTest {
|
||||
@@ -80,6 +82,43 @@ TEST(TradeOfferTest, AnEquippedItemIsRefused) {
|
||||
EXPECT_FALSE(Trade::ResolveOffer({ { 400, 1727, 1 } }, FindHeld).has_value());
|
||||
}
|
||||
|
||||
TEST(TradeOfferTest, AnItemThatMayNotBeDeletedIsRefused) {
|
||||
EXPECT_FALSE(Trade::ResolveOffer({ { 500, 1727, 1 } }, FindHeld).has_value());
|
||||
EXPECT_FALSE(Trade::ResolveOffer({ { 100, 1727, 1 }, { 500, 1727, 1 } }, FindHeld).has_value());
|
||||
}
|
||||
|
||||
TEST(TradeOfferTest, AModelThatIsNotApprovedIsRefused) {
|
||||
EXPECT_FALSE(Trade::ResolveOffer({ { 600, 6662, 1 } }, FindHeld).has_value());
|
||||
EXPECT_FALSE(Trade::ResolveOffer({ { 100, 1727, 1 }, { 600, 6662, 1 } }, FindHeld).has_value());
|
||||
}
|
||||
|
||||
TEST(TradeOfferTest, OnlyAnApprovedBrickBuiltModelIsApproved) {
|
||||
LwoNameValue config;
|
||||
// No moderation status
|
||||
EXPECT_FALSE(Trade::IsApproved(Trade::BrickBuiltModelLot, config));
|
||||
|
||||
config.Insert<int32_t>(u"userModelMod", 0);
|
||||
EXPECT_FALSE(Trade::IsApproved(Trade::BrickBuiltModelLot, config));
|
||||
|
||||
config.Insert<int32_t>(u"userModelMod", 2);
|
||||
EXPECT_FALSE(Trade::IsApproved(Trade::BrickBuiltModelLot, config));
|
||||
|
||||
// Not a number
|
||||
config.Insert<bool>(u"userModelMod", true);
|
||||
EXPECT_FALSE(Trade::IsApproved(Trade::BrickBuiltModelLot, config));
|
||||
|
||||
config.Insert<int32_t>(u"userModelMod", Trade::ApprovedModerationStatus);
|
||||
EXPECT_TRUE(Trade::IsApproved(Trade::BrickBuiltModelLot, config));
|
||||
}
|
||||
|
||||
TEST(TradeOfferTest, AnItemThatIsNotAModelHasNoModerationStatus) {
|
||||
LwoNameValue config;
|
||||
EXPECT_TRUE(Trade::IsApproved(1727, config));
|
||||
|
||||
config.Insert<int32_t>(u"userModelMod", 0);
|
||||
EXPECT_TRUE(Trade::IsApproved(1727, config));
|
||||
}
|
||||
|
||||
TEST(TradeOfferTest, AnOfferFillsTheSlotsOfTheTradeWindowAtMost) {
|
||||
const auto findAny = [](const LWOOBJID) -> std::optional<HeldTradeItem> {
|
||||
return HeldTradeItem{ 1727, 1 };
|
||||
|
||||
Reference in New Issue
Block a user