Working on can equip, putting it in the general inventory class.

This commit is contained in:
KimLS
2015-02-27 02:40:44 -08:00
parent 18b4d068ea
commit 7870bf103a
8 changed files with 91 additions and 51 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ SET(tests_headers
ADD_EXECUTABLE(tests ${tests_sources} ${tests_headers})
TARGET_LINK_LIBRARIES(tests common cppunit)
TARGET_LINK_LIBRARIES(tests common cppunit debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE})
INSTALL(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
+38 -8
View File
@@ -26,13 +26,14 @@
class InventoryTest : public Test::Suite {
typedef void(InventoryTest::*TestFunction)(void);
public:
InventoryTest() {
InventoryTest() : inv(1, 1) {
InitContainer();
InitArmor();
InitAugment();
InitStackable();
InitInventory();
TEST_ADD(InventoryTest::InventoryVerifyInitialItemsTest);
TEST_ADD(InventoryTest::InventoryCanEquipTest);
}
~InventoryTest() {
@@ -144,15 +145,15 @@ private:
std::shared_ptr<EQEmu::ItemInstance> m_armor(new EQEmu::ItemInstance(&armor));
std::shared_ptr<EQEmu::ItemInstance> m_augment(new EQEmu::ItemInstance(&augment));
std::shared_ptr<EQEmu::ItemInstance> m_stackable(new EQEmu::ItemInstance(&stackable, 45));
inv.Put(EQEmu::InventorySlot(0, 23), m_bag);
inv.Put(EQEmu::InventorySlot(0, 23, 0), m_armor);
inv.Put(EQEmu::InventorySlot(0, 23, 1), m_augment);
inv.Put(EQEmu::InventorySlot(0, 23, 7), m_stackable);
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1), m_bag);
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, 0), m_armor);
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, 1), m_augment);
inv.Put(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, 7), m_stackable);
}
void InventoryVerifyInitialItemsTest()
{
auto m_bag = inv.Get(EQEmu::InventorySlot(0, 23));
auto m_bag = inv.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1));
TEST_ASSERT(m_bag);
TEST_ASSERT(m_bag->GetItem());
TEST_ASSERT(m_bag->GetItem()->ID == 1000);
@@ -173,12 +174,41 @@ private:
TEST_ASSERT(m_stackable->GetItem()->ID == 1003);
}
void InventoryCanEquipTest() {
auto m_bag = inv.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1));
TEST_ASSERT(m_bag);
TEST_ASSERT(m_bag->GetItem());
TEST_ASSERT(m_bag->GetItem()->ID == 1000);
auto m_armor = m_bag->Get(0);
TEST_ASSERT(m_armor);
TEST_ASSERT(m_armor->GetItem());
TEST_ASSERT(m_armor->GetItem()->ID == 1001);
auto can_equip = inv.CanEquip(m_armor, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotChest));
TEST_ASSERT(can_equip);
can_equip = inv.CanEquip(m_armor, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotWaist));
TEST_ASSERT(!can_equip);
armor.Classes -= 1;
can_equip = inv.CanEquip(m_armor, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotChest));
TEST_ASSERT(!can_equip);
armor.Classes += 1;
armor.Races -= 1;
can_equip = inv.CanEquip(m_armor, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotChest));
TEST_ASSERT(!can_equip);
armor.Races += 1;
}
void InventorySwapItemsTest()
{
auto swap_result = inv.Swap(EQEmu::InventorySlot(0, 23), EQEmu::InventorySlot(0, 24), 0);
auto swap_result = inv.Swap(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1),
EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral2), 0);
TEST_ASSERT(swap_result == true);
auto m_bag = inv.Get(EQEmu::InventorySlot(0, 24));
auto m_bag = inv.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral2));
TEST_ASSERT(m_bag);
TEST_ASSERT(m_bag->GetItem());
TEST_ASSERT(m_bag->GetItem()->ID == 1000);
+3
View File
@@ -20,6 +20,7 @@
#include <iostream>
#include <fstream>
#include <memory>
#include "../common/eqemu_logsys.h"
#include "memory_mapped_file_test.h"
#include "ipc_mutex_test.h"
#include "fixed_memory_test.h"
@@ -32,6 +33,8 @@
#include "inventory_test.h"
#include "memory_buffer_test.h"
EQEmuLogSys Log;
int main() {
try {
std::ofstream outfile("test_output.txt");