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


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

本文整理汇总了C++中Inventory::removeItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::removeItem方法的具体用法?C++ Inventory::removeItem怎么用?C++ Inventory::removeItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory::removeItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InventoryL_RemoveItem

static int InventoryL_RemoveItem(lua_State* luaVM)
{
   bool success = false;
   const int nargs = lua_gettop(luaVM);
   Inventory* inv;
   
   if(nargs > 1)
   {
      inv = luaW_to<Inventory>(luaVM, 1);
      switch(nargs)
      {
         case 2:
         {
            success = inv->removeItem(lua_tonumber(luaVM, 2));
            break;
         }
         case 3:
         {
            success = inv->removeItem(lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3));
            break;
         }
      }      
   }
   
   lua_pushboolean(luaVM, success);
   return 1;
}
开发者ID:secretrobotron,项目名称:EDEn,代码行数:27,代码来源:LuaInventory.cpp

示例2: makeASale

void Employee::makeASale(Item *i, int amount) {
	Inventory *inv = getInventory();
	string name = i->getName();
	if (inv->isInStock(i->getName())) {
			inv->removeItem(i->getName(), amount);
			totalSales += i->getPrice() * amount;
	}
	else {
		cout << "Item " << i->getName() << " could not be found in the inventory" << endl;
	}
}
开发者ID:jprojas15,项目名称:COP3503Team17,代码行数:11,代码来源:TeamProject_1.cpp

示例3: Inventory_remove_item

	/**
	 * Removes the given item from the inventory, returns true if the item was found in the inventory
	 * and removed.
	 *
	 * @param Item item The item to remove from the inventory.
	 * @returns boolean True if the item was removed.
	 */
	int Inventory_remove_item(lua_State *lua)
	{
		Inventory *inv = castUData<Inventory>(lua, 1);
		if (inv)
		{
			Item *item = castUData<Item>(lua, 2);
			if (item)
			{
				lua_pushboolean(lua, inv->removeItem(item));
				return 1;
			}
			return LuaState::expectedArgs(lua, "remove_item", "Item item");
		}
		return LuaState::expectedContext(lua, "remove_item", "Inventory");
	}
开发者ID:astrellon,项目名称:GPP,代码行数:22,代码来源:lua_inventory.cpp

示例4: run

void StoreTab::run(Inventory &stationData)
{
	//run through the store tab
	//uis tend to have a ton of bloated code
	loadInventories(playerData.getConvertedInventory(), stationData.getConvertedInventory());

	playerCash->setText((stringw(L"Your Credits :") + stringw(playerData.getCredits())).c_str());
	int index = playerInventory->getSelected();

	//this is needed to maintain syncing between the index and objectmanager enum
	std::vector<ObjectManager::E_ITEM_LIST> syncedInventory = playerData.getConvertedInventoryNoSpaces();
	if (index != -1) {
		//has something selected so we load its information
		selectedValue->setText((stringw(L"Value :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getPrice())).c_str());
		selectedWeight->setText((stringw(L"Weight :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getWeight())).c_str());
		selectedDescription->setText(ObjectManager::itemList[syncedInventory[index]]->getDesc());

		if (sellButton->isPressed()) {
			//sell selected item
			playerData.addCredits(ObjectManager::itemList[syncedInventory[index]]->getPrice());
			playerData.removeItem(syncedInventory[index]);
			stationData.addItem(syncedInventory[index], 1);
			playerInventory->clear();
			stationInventory->clear();
		}
	} else {
		//reset text if nothing is selected
		selectedValue->setText(L"Value :");
		selectedWeight->setText(L"Weight :");
		selectedDescription->setText(L"");
	}
	index = stationInventory->getSelected();
	syncedInventory = stationData.getConvertedInventoryNoSpaces();
	if (index != -1) {
		//has something selected so we load its information
		selectedValue->setText((stringw(L"Value :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getPrice())).c_str());
		selectedWeight->setText((stringw(L"Weight :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getWeight())).c_str());
		selectedDescription->setText(ObjectManager::itemList[syncedInventory[index]]->getDesc());
		if (buyButton->isPressed()) {
			//sell selected item
			playerData.addCredits(-ObjectManager::itemList[syncedInventory[index]]->getPrice());
			playerData.addItem(syncedInventory[index], 1);
			stationData.removeItem(syncedInventory[index]);
			playerInventory->clear();
			stationInventory->clear();
		}
	}
}
开发者ID:benquach16,项目名称:Lost-Horizons,代码行数:48,代码来源:storetab.cpp

示例5: main


//.........这里部分代码省略.........
	}
      }//end if west
      else if (input ==""){}//fix seg fault	
      else if(input == "i"){
	cout << "Inventory:  " ;
	inventory.getItems();
	cout << endl;
      }//end inventory
      else if (input == "open exit"){
	if (current_room->getType() == "exit") {
	  cout << "Game Over" << endl;
	  return 0;
	}
	else {
	  cout << "Error" << endl;
	}
      }
      else{
      input_vector = split(input, ' '); 
      if (input_vector[0] == "read" && input_vector.size() == 2){
	inventory.read(input_vector[1]);
      }
      else if (input_vector[0] == "drop" && input_vector.size() == 2){
	inventory.drop(input_vector[1],current_room);
      }
      else if (input_vector[0] == "put" && input_vector.size() == 4){
	t_item = inventory.getItem(input_vector[1]);
	if (t_item != NULL) {
	  temp_cont = current_room->getContainers();
	  for (int i = 0; i < temp_cont.size(); i++) {
	    if (temp_cont[i]->getName() == input_vector[3]) { // find the container that matches what you are trying to insert item into
	      if (temp_cont[i]->getAccept() == t_item->getName() || temp_cont[i]->getAccept() == "") {
	      temp_cont[i]->addItem(t_item);
	      inventory.removeItem(t_item->getName());
	      cout << "Item " <<t_item->getName() << " added to " << temp_cont[i]->getName() << endl;
	       temp_trigg = temp_cont[i]->getTriggers();
		for (int j = 0; j < temp_trigg.size(); j++) {
		    if (temp_trigg[j]->getObject() == t_item->getName()) {
		      fixed_vector = temp_trigg[j]->getActions();
		      int size = fixed_vector.size();
			for (int l = 0; l < size; l++) {
			action_list.push_back( fixed_vector.back());
			fixed_vector.pop_back();
		      }
			cout << temp_trigg[j]->getPrint() << endl;
			
		    }
		}
		
		
	      }
	    }
	  }
	}
	else {
	  cout << "Error" << endl;
	}
	
      }
      else if (input_vector[0] == "Game" && input_vector[1] == "Over") {
	found_exit = true;
      }
      else if (input_vector[0] == "turn" && input_vector[1] == "on" && input_vector.size() == 3){
	if (inventory.hasa(input_vector[2])) {
	  Item * temp_item = inventory.getItem(input_vector[2]);
	    fixed_vector = temp_item->getActions();
开发者ID:igalfsg,项目名称:ECE30862,代码行数:67,代码来源:main.cpp


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