当前位置: 首页>>代码示例>>C++>>正文


C++ Inventory::containsItem方法代码示例

本文整理汇总了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);
}
开发者ID:cigo,项目名称:ufoai,代码行数:32,代码来源:test_inventory.cpp

示例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);
}
开发者ID:cigo,项目名称:ufoai,代码行数:27,代码来源:test_inventory.cpp

示例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));
}
开发者ID:cigo,项目名称:ufoai,代码行数:24,代码来源:test_inventory.cpp

示例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);
}
开发者ID:cigo,项目名称:ufoai,代码行数:69,代码来源:test_inventory.cpp


注:本文中的Inventory::containsItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。