本文整理汇总了C++中Player::AddDroid方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::AddDroid方法的具体用法?C++ Player::AddDroid怎么用?C++ Player::AddDroid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::AddDroid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
void RceUpdateSocialItemHandle::handle(Event* e)
{
int64 uid = e->uid();
GameDataHandler* pUserManager = eh_->getDataHandler();
if(!pUserManager)
{
return;
}
User *pUser = pUserManager->getUser(uid);
if ( !pUser)
{
return;
}
Player* pPlayer = pUser->GetPlayer();
if ( !pPlayer || !pPlayer->CanUse())
{
return ;
}
RceUpdateSocialItem* req = e->mutable_ce_rceupdatesocialitem();
if( !req )
{
return;
}
RseUpdateSocialItem rse;
rse.set_ret(RseUpdateSocialItemRet_Success);
int planetId = req->planetid();
string strAction = req->action();
MsgTransaction* MT = req->mutable_transaction();
if(MT)
{
for(int i = 0;i<MT->socialitems_size();i++)
{
MsgSocialItems* MSI = MT->mutable_socialitems(i);
if(!pPlayer->CostSocialItem(MSI->sku(), 1))
{
SendRet2User(pUser,RseUpdateSocialItemRet_SocialItemNotEnough,rse);
}
}
}
if(strAction == "nextStep")
{
int quantity = 0;
int tm = 0;
if(req->postion() == 1)//爆出物品
{
CFG_Item* Tbl = ItemTblInst::instance().GetItem(req->sku());
if(!Tbl)
return;
string givenCondition = Tbl->givenCondition;
tm = Tbl->timeToGive * 1000;
string currentCount = toString(req->currentcount());
if(givenCondition.find("listSequence") >= 0 &&givenCondition.find("listSequence") <= givenCondition.size()&& givenCondition.find(currentCount))
{
quantity = 1;
}
}
if(!pPlayer->AddSocialItem(req->sku(),quantity,req->currentquantity(),tm))
{
SendRet2User(pUser,RseUpdateSocialItemRet_AddSocialItemFailed,rse);
return;
}
SendRet2User(pUser,RseUpdateSocialItemRet_Success,rse);
eh_->getDataHandler()->markUserDirty(pUser);
}
else if(strAction == "addItem")
{
MsgSocialItems* MSI = NULL;
for(int i = 0;i<MT->socialitems_size();i++)
{
MSI = MT->mutable_socialitems(i);
if(!pPlayer->AddSocialItem(MSI->sku(),req->currentquantity()))
{
SendRet2User(pUser,RseUpdateSocialItemRet_AddSocialItemFailed,rse);
return ;
}
}
eh_->getDataHandler()->markUserDirty(pUser);
SendRet2User(pUser,RseUpdateSocialItemRet_Success,rse);
}
else if(strAction == "useItem")
{
DB_Model* model = pPlayer->GetDBPlayer()->mutable_model();
int Sku = 0;
string randomSku = req->num();
safe_atoi(req->sku(),Sku);
DB_SocialItem* pDBSI = pPlayer->GetSocialItem(req->sku());
if(!pDBSI || !model)
{
SendRet2User(pUser,RseUpdateSocialItemRet_SocialItemNotEnough,rse);
return;
}
if(Sku == SocialItem_worker_freeWorker)//雇佣工人
{
if(!pPlayer->AddDroid(planetId))
//.........这里部分代码省略.........