mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-09 17:08:06 +00:00
![copilot-swe-agent[bot]](/assets/img/avatar_default.png)
- Add FindBehaviorSlotByEquipLocation method to map equipLocation strings to BehaviorSlot enum - Update AddItemSkills and RemoveItemSkills to use equipLocation instead of itemType - This fixes issue where items with same skill but different equipLocations would conflict - Add unit tests to verify the new behavior - Based on issue #1339: Server doesn't allow same skill in multiple slots Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
#include "GameDependencies.h"
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "InventoryComponent.h"
|
|
#include "BehaviorSlot.h"
|
|
|
|
class InventoryComponentTest : public GameDependenciesTest {
|
|
protected:
|
|
void SetUp() override {
|
|
SetUpDependencies();
|
|
}
|
|
|
|
void TearDown() override {
|
|
TearDownDependencies();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Test that FindBehaviorSlotByEquipLocation correctly maps equipLocation strings to BehaviorSlot enum values
|
|
*/
|
|
TEST_F(InventoryComponentTest, FindBehaviorSlotByEquipLocationTest) {
|
|
// Test the mappings from the issue comments
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("special_r"), BehaviorSlot::Primary);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("hair"), BehaviorSlot::Head);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("special_l"), BehaviorSlot::Offhand);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("clavicle"), BehaviorSlot::Neck);
|
|
|
|
// Test that unknown equipLocations return Invalid
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("unknown"), BehaviorSlot::Invalid);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation(""), BehaviorSlot::Invalid);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("root"), BehaviorSlot::Invalid);
|
|
EXPECT_EQ(InventoryComponent::FindBehaviorSlotByEquipLocation("leftHand"), BehaviorSlot::Invalid);
|
|
} |