本文整理汇总了C++中Inventory::containsItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::containsItem方法的具体用法?C++ Inventory::containsItem怎么用?C++ Inventory::containsItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::containsItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testItemMove
static void testItemMove (void)
{
Inventory inv;
const objDef_t* od;
const invDef_t* container, *containerTo;
Item* addedItem;
ResetInventoryList();
od = INVSH_GetItemByIDSilent("assault");
CU_ASSERT_PTR_NOT_NULL(od);
container = INVSH_GetInventoryDefinitionByID("right");
CU_ASSERT_PTR_NOT_NULL(container);
Item item(od);
CU_ASSERT(inv.containsItem(container->id, &item) == false);
addedItem = i.addToInventory(&inv, &item, container, NONE, NONE, 1);
CU_ASSERT_PTR_NOT_NULL(addedItem);
CU_ASSERT(inv.containsItem(container->id, &item) == true);
containerTo = INVSH_GetInventoryDefinitionByID("backpack");
CU_ASSERT_PTR_NOT_NULL(containerTo);
CU_ASSERT_EQUAL(IA_MOVE, i.moveInInventory(&inv, container, addedItem, containerTo, NONE, NONE, nullptr, nullptr));
CU_ASSERT(inv.containsItem(container->id, &item) == false);
CU_ASSERT(inv.containsItem(containerTo->id, &item) == true);
}
示例2: testItemDel
static void testItemDel (void)
{
Inventory inv;
const objDef_t* od;
const invDef_t* container;
Item* addedItem;
ResetInventoryList();
od = INVSH_GetItemByIDSilent("assault");
CU_ASSERT_PTR_NOT_NULL(od);
container = INVSH_GetInventoryDefinitionByID("right");
CU_ASSERT_PTR_NOT_NULL(container);
Item item(od);
CU_ASSERT(inv.containsItem(container->id, &item) == false);
addedItem = i.addToInventory(&inv, &item, container, NONE, NONE, 1);
CU_ASSERT(inv.containsItem(container->id, &item) == true);
CU_ASSERT(i.removeFromInventory(&inv, container, addedItem));
CU_ASSERT(inv.containsItem(container->id, &item) == false);
}
示例3: testItemToHeadgear
static void testItemToHeadgear (void)
{
Inventory inv;
const objDef_t* od;
const invDef_t* container;
ResetInventoryList();
od = INVSH_GetItemByIDSilent("irgoggles");
CU_ASSERT_PTR_NOT_NULL_FATAL(od);
container = INVSH_GetInventoryDefinitionByID("headgear");
CU_ASSERT_PTR_NOT_NULL_FATAL(container);
Item item(od);
CU_ASSERT_FALSE(inv.containsItem(container->id, &item));
CU_ASSERT_PTR_NOT_NULL(i.addToInventory(&inv, &item, container, NONE, NONE, 1));
CU_ASSERT_TRUE(inv.containsItem(container->id, &item));
CU_ASSERT_PTR_NULL(i.addToInventory(&inv, &item, container, NONE, NONE, 1));
}
示例4: testItemReload
static void testItemReload (void)
{
Inventory inv;
const objDef_t* od, *ad;
const invDef_t* container, *containerFrom;
Item* addedItem;
ResetInventoryList();
od = INVSH_GetItemByIDSilent("rpg");
CU_ASSERT_PTR_NOT_NULL(od);
container = INVSH_GetInventoryDefinitionByID("right");
CU_ASSERT_PTR_NOT_NULL(container);
Item item(od);
CU_ASSERT(inv.containsItem(container->id, &item) == false);
addedItem = i.addToInventory(&inv, &item, container, NONE, NONE, 1);
CU_ASSERT_PTR_NOT_NULL(addedItem);
CU_ASSERT(inv.containsItem(container->id, &item) == true);
ad = INVSH_GetItemByIDSilent("rpg_ammo");
CU_ASSERT_PTR_NOT_NULL(ad);
Item ammo(ad);
containerFrom = INVSH_GetInventoryDefinitionByID("backpack");
CU_ASSERT_PTR_NOT_NULL(containerFrom);
CU_ASSERT(inv.containsItem(containerFrom->id, &ammo) == false);
addedItem = i.addToInventory(&inv, &ammo, containerFrom, NONE, NONE, 1);
CU_ASSERT_PTR_NOT_NULL(addedItem);
CU_ASSERT(inv.containsItem(containerFrom->id, &ammo) == true);
CU_ASSERT_EQUAL(IA_RELOAD, i.moveInInventory(&inv, containerFrom, addedItem, container, NONE, NONE, nullptr, nullptr));
CU_ASSERT(inv.containsItem(containerFrom->id, &ammo) == false);
item.setAmmoDef(ad);
item.setAmmoLeft(1);
CU_ASSERT(inv.containsItem(container->id, &item) == true);
ad = INVSH_GetItemByIDSilent("rpg_incendiary_ammo");
CU_ASSERT_PTR_NOT_NULL(ad);
Item ammoFrom(ad);
CU_ASSERT(inv.containsItem(containerFrom->id, &ammoFrom) == false);
addedItem = i.addToInventory(&inv, &ammoFrom, containerFrom, NONE, NONE, 1);
CU_ASSERT_PTR_NOT_NULL(addedItem);
CU_ASSERT(inv.containsItem(containerFrom->id, &ammoFrom) == true);
CU_ASSERT_EQUAL(IA_RELOAD_SWAP, i.moveInInventory(&inv, containerFrom, addedItem, container, NONE, NONE, nullptr, nullptr));
CU_ASSERT(inv.containsItem(containerFrom->id, &ammoFrom) == false);
CU_ASSERT(inv.containsItem(containerFrom->id, &ammo) == true);
item.setAmmoDef(ad);
CU_ASSERT(inv.containsItem(container->id, &item) == true);
}