本文整理汇总了C++中Item::GetDurPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetDurPoints方法的具体用法?C++ Item::GetDurPoints怎么用?C++ Item::GetDurPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::GetDurPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
uint CGShopSpecialRepairHandler::Execute( CGShopSpecialRepair* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
Assert( pGamePlayer ) ;
Obj_Human* pHuman = pGamePlayer->GetHuman() ;
Assert( pHuman ) ;
Scene* pScene = pHuman->getScene() ;
if( pScene==NULL )
{
Assert(FALSE) ;
return PACKET_EXE_ERROR ;
}
//检查线程执行资源是否正确
Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;
//交易状态不可操作
if(pHuman->m_ExchangBox.m_Status > 0)
{//丢弃
g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
return PACKET_EXE_CONTINUE ;
}
//摆摊状态不可操作
if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
{//丢弃
g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
return PACKET_EXE_CONTINUE ;
}
BYTE Opt = pPacket->GetOpt();
BYTE BagIndex = pPacket->GetBagIndex(); //包中的位置
Item* pCurItem = NULL;
INT MoneySpent = 0;
INT MoneyLast = 0;
INT MoneyHave = pHuman->GetMoney();
INT RepairedIndex = 0;
GCShopSpecialRepairResult MsgResult;
GCShopSpecialRepairResult::REPAIRED_ITEM ItemList;
if(Opt == CGShopSpecialRepair::FromBag)
{
//一定是修理单个
ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman, BagIndex);
if (pItemContainer == NULL)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler BagIndex is invalid, BagIndex = %d", BagIndex) ;
return PACKET_EXE_ERROR;
}
if (!pItemContainer->IsCanUse())
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler extrabag is invalid time BagIndex = %d", BagIndex) ;
return PACKET_EXE_CONTINUE ;
}
pCurItem = pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex));
if(!pCurItem->IsEmpty())
{
if(pCurItem->GetItemClass() != ICLASS_EQUIP)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler pCurItem->GetItemClass() != ICLASS_EQUIP ") ;
return PACKET_EXE_ERROR ;
}
EQUIP_SPECIALREPAIR_TB* pSpecialRepair = g_ItemTable.GetSpecialRepairTB();
Assert (pSpecialRepair != NULL);
if (!pSpecialRepair)
{
g_pLog->FastSaveLog( LOG_FILE_1, "[CGShopSpecialRepairHandler::Execute] GetSpecialRepairTB index is error");
return PACKET_EXE_ERROR;
}
//获得Human背包中对应ItemIndex的物品位置
UINT nItemCount = HumanItemLogic::CalcBagItemCount(pHuman, pSpecialRepair->m_ItemID);
if((nItemCount == 0)||(nItemCount < pPacket->GetItemNum()))
{
MsgResult.SetResult(EQUIPSPECIALREPAIR_ITEM);
pGamePlayer->SendPacket(&MsgResult);
g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler nItemIndex = %d", pSpecialRepair->m_ItemID) ;
return PACKET_EXE_CONTINUE ;
}
FLOAT fCur = (FLOAT)pCurItem->GetDurPoints();
FLOAT fMax = (FLOAT)pCurItem->GetMaxDurPoint();
FLOAT fCurMax = (FLOAT)pCurItem->GetCurMaxDurPoint();
if(fMax != fCurMax)
{
UINT nUsedItem = 0;
for (UINT i=0; i<pPacket->GetItemNum(); ++i)
{
++nUsedItem;
fCurMax = pSpecialRepair->m_RecoverPoint + fCurMax;
if (fCurMax>=fMax)
{
fCurMax = fMax;
break;
//.........这里部分代码省略.........
示例2: Execute
//.........这里部分代码省略.........
break;
case SHOP_DEFENCE: //饰物
{
nBeginPoint = HEQUIP_CAP;
nEndPoint = HEQUIP_BOOT;
}
break;
case SHOP_ADORN: //武器
{
nBeginPoint = HEQUIP_SASH;
nEndPoint = HEQUIP_RIDER;
}
break;
default:
{
return PACKET_EXE_CONTINUE;
}
break;
}
for(INT i =nBeginPoint; i<=nEndPoint; i++)
{
pCurItem = HumanItemLogic::GetEquip(pHuman,(HUMAN_EQUIP)i);
//pCurItem = pHuman->GetEquip((HUMAN_EQUIP)i);
if(!pCurItem->IsEmpty())
{//有东西
//判定是否狗修理等级
if(pCurItem->GetRequireLevel() > pShop->m_nRepairLevel)
{
continue;
}
FLOAT fCur = (FLOAT)pCurItem->GetDurPoints();
FLOAT fMax = (FLOAT)pCurItem->GetMaxDurPoint();
FLOAT V = (FLOAT)pCurItem->GetPrice();
if(fCur != fMax)
{
//if(fCur<fMax/3)
// MoneySpent += (INT)(7*V*V*fCur*6/(4*fMax)+V*V);
//else if(fCur>=fMax/3&&fCur<fMax*2/3)
// MoneySpent += (INT)(V*V*fCur*6/fMax+V*V*3/4);
//else if(fCur>=fMax*2/3&&fCur<fMax)
// MoneySpent += (INT)(V*V*fCur*6/(4*fMax)+V*V/4);
MoneySpent += (INT) ( ((REPAIR_SPEND * (1- fCur/fMax) * V) * pShop->m_nRepairSpend) + 0.5);
//临时的修理费计算方法
// FLOAT scale = (FLOAT)(fCur/fMax);
// scale = 1-scale;
// MoneySpent += static_cast<INT>(pCurItem->GetPrice()*scale);
if(MoneyHave<MoneySpent)
break;
MoneyLast = MoneySpent;
HumanItemLogic::SetEquipDur(pHuman,(HUMAN_EQUIP)i, (INT)fMax);
ItemList[RepairedIndex].IsIn = GCShopRepair::EQUIP;
ItemList[RepairedIndex++].BagIndex = (BYTE)i;
}
}
}
if(MoneyHave<MoneySpent)
{//break出来的
if(RepairedIndex)
{
示例3: Execute
//.........这里部分代码省略.........
break;
case SHOP_MATERIAL: //材料
{
if( ICLASS_MATERIAL != pCurrentItem->GetItemClass())
{
bCanBuy = FALSE;
}
}
break;
case SHOP_COMITEM: //药品
{
if( ICLASS_COMITEM != pCurrentItem->GetItemClass())
{
bCanBuy = FALSE;
}
}
break;
default:
{
bCanBuy = FALSE;
break;
}
}
}
//是否返回失败消息???
if(bCanBuy == FALSE)
{
return PACKET_EXE_CONTINUE;
}
INT iPrice = ShopMgr::ConvertItemType2Money(ConvertSerial2ItemType(pCurrentItem->GetItemTableIndex()));
iPrice *= pCurrentItem->GetLayedNum();
//2006-4-21
//玩家向商店出售已经鉴定过的物品或者无需鉴定的物品按照基础价格*系数A(=1/3) 计算;
//若出售未鉴定物品,价格应该更低,设此价格系数为B(=1/10),这个有待于调整,请在config中开放调整A,B的接口。
//耐久衰减系数D=当前耐久/最大耐久
//修理失败衰减次数F=1/(修理失败次数+1)
//因此最终的出售价格为V=基础价格B*A*D*F
//再乘以商店得价格比例
FLOAT fCur = 1;
FLOAT fMax = 1;
INT iFailTimes = 0;
if(pCurrentItem->GetItemClass() == ICLASS_EQUIP)
{
fCur = (FLOAT)pCurrentItem->GetDurPoints();
fMax = (FLOAT)pCurrentItem->GetMaxDurPoint();
iFailTimes = pCurrentItem->GetFailTimes();
}
if(pCurrentItem->GetItemIdent())
{
iPrice = (INT)( ((FLOAT)iPrice/(FLOAT)3.0) * (fCur/fMax) * ((FLOAT)1/(FLOAT)(iFailTimes+1)) * (pShop->m_scale) );
}
else
{
iPrice = (INT)( ((FLOAT)iPrice/(FLOAT)10.0) * (fCur/fMax) * ((FLOAT)1/(FLOAT)(iFailTimes+1)) * (pShop->m_scale) );
}
//备份一下,一会儿放到购回列表里
_ITEM tempitem;
pCurrentItem->SaveValueTo(&tempitem);
//备份到回购列表中
pHuman->AddToSoldList(m_nBagIndex, iPrice);
//给钱
pHuman->SetMoney( pHuman->GetMoney() + iPrice);
MONEY_LOG_PARAM MoneyLogParam;
MoneyLogParam.CharGUID = pHuman->GetGUID();
MoneyLogParam.OPType = MONEY_SHOP_SELL;
MoneyLogParam.Count = iPrice;
MoneyLogParam.SceneID = pHuman->getScene()->SceneID();
MoneyLogParam.XPos = pHuman->getWorldPos()->m_fX;
MoneyLogParam.ZPos = pHuman->getWorldPos()->m_fZ;
SaveMoneyLog(&MoneyLogParam);
//把这个回购商品显示到界面
GCShopSoldList::_MERCHANDISE_ITEM SoldItem;
SoldItem.item_data = tempitem;
GCShopSoldList MsgSold;
MsgSold.SetMerchadiseNum(1);
MsgSold.SetMerchadiseList(&SoldItem);
pHuman->GetPlayer()->SendPacket( &MsgSold );
GCShopSell MsgSell;
pHuman->GetPlayer()->SendPacket( &MsgSell );
g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSellHandler m_nBagIndex=%d ",
m_nBagIndex ) ;
return PACKET_EXE_CONTINUE;
__LEAVE_FUNCTION
return PACKET_EXE_ERROR ;
}