本文整理汇总了C++中Inventory::hasItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::hasItem方法的具体用法?C++ Inventory::hasItem怎么用?C++ Inventory::hasItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::hasItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
// ---------------------------------------------------------
bool LocationCommand::execute()
{
map<Name, const Item *> itemTable = myMap->getItemLocations();
map<Name, const Item *>::iterator iter;
for ( iter = itemTable.begin(); iter != itemTable.end(); ++iter )
{
cout << iter->first << '\t';
if ( iter->second == 0 )
{
Inventory * inv = myAdventurer->getInventory();
if ( inv->hasItem( iter->first ) )
{
cout << "(inventory)" << '\n';
}
else
{
cout << "(unknown)" << '\n';
}
}
else
{
cout << iter->second->getID() << '\n';
}
}
cout << endl;
return true;
}
示例2: execute
//////////////////////////////////////////////////////////////////////////////
// 플레이어가 팔려고 하는 아이템을 가지고 있는지 확인한 다음에,
// 일반 아이템과 모터 사이클 처리 부분으로 분기한다.
//////////////////////////////////////////////////////////////////////////////
void CGShopRequestSellHandler::execute (CGShopRequestSell* pPacket , Player* pPlayer)
throw(ProtocolException , Error) {
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
Assert(pPacket != NULL);
Assert(pPlayer != NULL);
ObjectID_t ITEMOID = pPacket->getItemObjectID();
BYTE OPCODE = pPacket->getOpCode();
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Creature* pCreature = pGamePlayer->getCreature();
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
if (OPCODE == SHOP_REQUEST_SELL_NORMAL) {
// 플레이어가 팔려고 하는 아이템을 가지고 있는지 검사
Inventory* pInventory = pPC->getInventory();
if (pInventory->hasItem(ITEMOID) == false)
throw ProtocolException("CGShopRequestSellHandler::execute() : No such item to sell!");
Item* pItem = pInventory->getItemWithObjectID(ITEMOID);
if (pItem == NULL || pPC->getStore()->hasItem(pItem))
return sendFailPacket(pPacket, pPlayer);
//ItemInfo* pItemInfo = g_pItemInfoManager->getItemInfo(pItem->getItemClass(), pItem->getItemType());
//Assert(pItemInfo!=NULL);
// 유니크 아이템은 못판다.
// 특정 아이템 클래스는 팔 수 없다. by sigi. 2002.8.29
// 선물 상자는 팔 수 있다. by bezz. 2002.12.13
// 커플링은 팔 수 없다. by Sequoia. 2003. 3. 3
// ItemUtil 안에 canSell 로 Extract 2003. 3. 3
if (!canSell(pItem))
return sendFailPacket(pPacket, pPlayer);
else if (pItem->getItemClass() == Item::ITEM_CLASS_KEY && pItem->getItemType() == 2)
executeMotorcycle(pPacket, pPlayer);
else
executeNormal(pPacket, pPlayer);
}
else if (OPCODE == SHOP_REQUEST_SELL_ALL_SKULL)
executeOpAllSkull(pPacket, pPlayer);
else if (OPCODE == SHOP_REQUEST_SWAP_ADVANCEMENT_ITEM)
executeOpSwapAdvancementItem(pPacket, pPlayer);
else
throw ProtocolException("CGShopRequestSellHandler::execute() : unknown op code");
#endif
__END_DEBUG_EX __END_CATCH
}
示例3: Inventory_has_item
/**
* Looks for the given item in the inventory. Returns true if the given item was found.
*
* @param Item item The item to look for in the inventory.
* @returns boolean True if the item was found.
*/
int Inventory_has_item(lua_State *lua)
{
Inventory *inv = castUData<Inventory>(lua, 1);
if (inv)
{
Item *item = castUData<Item>(lua, 2);
if (item)
{
lua_pushboolean(lua, inv->hasItem(item));
return 1;
}
return LuaState::expectedArgs(lua, "has_item", "Item item");
}
return LuaState::expectedContext(lua, "has_item", "Inventory");
}
示例4: execute
void ActionRedeemMotorcycle::execute (Creature * pCreature1 , Creature* pCreature2)
throw(Error)
{
__BEGIN_TRY
Assert(pCreature1 != NULL);
Assert(pCreature2 != NULL);
Assert(pCreature1->isNPC());
Assert(pCreature2->isPC());
Player* pPlayer = pCreature2->getPlayer();
Assert(pPlayer != NULL);
// 일단 클라이언트를 위해 ok패킷을 하나 날려주고...
GCNPCResponse answerOKpkt;
pPlayer->sendPacket(&answerOKpkt);
// 플레이어가 슬레이어인지 검사한다.
if (pCreature2->isSlayer())
{
Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature2);
Zone* pZone = pSlayer->getZone();
Inventory* pInventory = pSlayer->getInventory();
uint InvenWidth = pInventory->getWidth();
uint InvenHeight = pInventory->getHeight();
Item* pItem = NULL;
Inventory* pBeltInventory = NULL;
uint BeltInvenWidth = 0;
uint BeltInvenHeight = 0;
Item* pBelt = NULL;
pBelt = pSlayer->getWearItem(Slayer::WEAR_BELT);
if(pBelt != NULL)
{
pBeltInventory = ((Belt*)pBelt)->getInventory();
BeltInvenWidth = pBeltInventory->getWidth();
BeltInvenHeight = pBeltInventory->getHeight();
}
// 인벤토리를 검색한다.
for (uint y=0; y<InvenHeight; y++)
{
for (uint x=0; x<InvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pInventory->hasItem(x, y))
{
pItem = pInventory->getItem(x, y);
if (load(pItem, pSlayer, pZone, pSlayer->getX(), pSlayer->getY()))
{
return;
}
}
}
}
if(pBelt != NULL)
{
// 벨트를 검색한다
for (uint y = 0; y < BeltInvenHeight; y++)
{
for(uint x = 0; x < BeltInvenWidth; x++)
{
if(pBeltInventory->hasItem(x, y))
{
pItem= pBeltInventory->getItem(x, y);
if (load(pItem, pSlayer, pZone, pSlayer->getX(), pSlayer->getY()))
{
return;
}
}
}
}
}
}
else // 뱀파이어라면...오토바이를 찾아줄 이유가 있을까?
{
}
__END_CATCH
}
示例5: execute
void ActionSearchMotorcycle::execute (Creature * pCreature1 , Creature* pCreature2)
throw(Error)
{
__BEGIN_TRY
Assert(pCreature1 != NULL);
Assert(pCreature2 != NULL);
Assert(pCreature1->isNPC());
Assert(pCreature2->isPC());
Player* pPlayer = pCreature2->getPlayer();
Assert(pPlayer != NULL);
// 일단 클라이언트를 위해 ok패킷을 하나 날려주고...
GCNPCResponse answerOKpkt;
pPlayer->sendPacket(&answerOKpkt);
// 플레이어가 슬레이어인지 검사한다.
if (pCreature2->isSlayer())
{
Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature2);
Inventory* pInventory = pSlayer->getInventory();
uint InvenWidth = pInventory->getWidth();
uint InvenHeight = pInventory->getHeight();
Item* pItem = NULL;
uint motorZoneID = 0;
uint motorX = 0;
uint motorY = 0;
Inventory* pBeltInventory = NULL;
uint BeltInvenWidth = 0;
uint BeltInvenHeight = 0;
Item* pBelt = NULL;
pBelt = pSlayer->getWearItem(Slayer::WEAR_BELT);
if(pBelt != NULL)
{
pBeltInventory = ((Belt*)pBelt)->getInventory();
BeltInvenWidth = pBeltInventory->getWidth();
BeltInvenHeight = pBeltInventory->getHeight();
}
// 인벤토리를 검색한다.
for (uint y=0; y<InvenHeight; y++)
{
for (uint x=0; x<InvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pInventory->hasItem(x, y))
{
pItem = pInventory->getItem(x, y);
if (search(pItem, motorZoneID, motorX, motorY))
{
GCSearchMotorcycleOK okpkt;
okpkt.setZoneID(motorZoneID);
okpkt.setX(motorX);
okpkt.setY(motorY);
pPlayer->sendPacket(&okpkt);
return;
}
}
}
}
if(pBelt != NULL)
{
// 인벤토리를 검색한다.
for (uint y=0; y<BeltInvenHeight; y++)
{
for (uint x=0; x<BeltInvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pBeltInventory->hasItem(x, y))
{
pItem = pBeltInventory->getItem(x, y);
if (search(pItem, motorZoneID, motorX, motorY))
{
GCSearchMotorcycleOK okpkt;
okpkt.setZoneID(motorZoneID);
okpkt.setX(motorX);
okpkt.setY(motorY);
pPlayer->sendPacket(&okpkt);
return;
}
}
}
}
}
}
else // 뱀파이어라면...오토바이를 찾아줄 이유가 있을까?
{
}
GCSearchMotorcycleFail failpkt;
pPlayer->sendPacket(&failpkt);
__END_CATCH
}
示例6: execute
//.........这里部分代码省略.........
CoordInven_t InvenY = pPacket->getInvenY();
if (InvenX >= pInventory->getWidth() || InvenY >= pInventory->getHeight() || itemObjectID != pPacket->getObjectID() ||
!pInventory->canAdding(InvenX, InvenY, pItem)) {
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
TPOINT pt;
pt.x = 99;
pt.y = 99;
// 넣을려는 Inventory Slot의 Item을 받아온다.
Item* pPrevItem = pInventory->searchItem(InvenX, InvenY , pItem, pt);
// 그 장소에 아이템이 있다면
if (pPrevItem != NULL) {
bool bisSame = true;
// 아이템 클래스가 같을때 숫자를 올려 주고 마우스에 있는 것은 없앤다.
if (canStack(pItem, pPrevItem)) {
int MaxStack = ItemMaxStack[pItem->getItemClass()];
VolumeWidth_t ItemWidth = pItem->getVolumeWidth();
VolumeHeight_t ItemHeight = pItem->getVolumeHeight();
VolumeWidth_t InvenWidth = pInventory->getWidth();
VolumeWidth_t InvenHeight= pInventory->getHeight();
if ((InvenX + ItemWidth <= InvenWidth) && (InvenY + ItemHeight <= InvenHeight)) {
for (int x = InvenX; x < (InvenX + ItemWidth); x++) {
for (int y = InvenY; y < (InvenY + ItemHeight); y++) {
if (pInventory->hasItem(x, y)) {
if(pInventory->getItem(x,y) != pPrevItem ) {
bisSame = false;
break;
}
} else {
bisSame = false;
break;
}
}
}
}
// 들어갈 아이템과 들어있는 아이템의 좌표가 꼭 일치 한다면?
if(bisSame) {
// 숫자가 9개를 넘으면 9개 될때까지만 Add 하고 나머지는 마우스에 달아둔다.
if (pItem->getNum() + pPrevItem->getNum() > MaxStack) {
ItemNum_t CurrentNum = pPrevItem->getNum();
ItemNum_t AddNum = pItem->getNum();
ItemNum_t NewNum = AddNum + CurrentNum - MaxStack;
pPrevItem->setNum(MaxStack);
pItem->setNum(NewNum);
pInventory->increaseNum(MaxStack - CurrentNum);
pInventory->increaseWeight(pItem->getWeight()* (MaxStack - CurrentNum));
//pPrevItem->save(pPC->getName(), STORAGE_INVENTORY, 0, InvenX, InvenY);
// item저장 최적화. by sigi. 2002.5.13
char pField[80];
sprintf(pField, "Num=%d, Storage=%d, StorageID=%d, X=%d, Y=%d", MaxStack, STORAGE_INVENTORY, invenID, InvenX, InvenY);
pPrevItem->tinysave(pField);
//pItem->save(pPC->getName(), STORAGE_EXTRASLOT, 0, 0, 0);
// item저장 최적화. by sigi. 2002.5.13