本文整理汇总了C++中PlayerObject::getTrade方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getTrade方法的具体用法?C++ PlayerObject::getTrade怎么用?C++ PlayerObject::getTrade使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getTrade方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleTeach
void ObjectController::_handleTeach(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// check if our attribute targetplayer exists
// check if our target is a player
// parse the string if a known skill was selected
// check what skills we can teach
// check which of these skills the target might learn
PlayerObject* teacherObject = dynamic_cast<PlayerObject*>(mObject);
PlayerObject* pupilObject = dynamic_cast<PlayerObject*> (teacherObject->getTarget());
// check if we have a target
if(!pupilObject )
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","no_target");
return;
}
if(pupilObject == teacherObject)
{
// target self:(
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","no_teach_self");
return;
}
if((teacherObject->getGroupId() == 0)||(teacherObject->getGroupId() != pupilObject ->getGroupId()))
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","not_in_same_group","","",L"",0,"","",L"",pupilObject->getId());
return;
}
//check if our pupil already gets taught
if (!pupilObject->getTrade()->getTeacher())
{
pupilObject->getTrade()->setTeacher(teacherObject);
gSkillManager->teach(pupilObject,teacherObject,"");
}
else
{
gMessageLib->sendSystemMessage(teacherObject,L"","teaching","student_has_offer_to_learn","","",L"",0,"","",L"",pupilObject->getId());
}
}
示例2: handleSecureTradeInvitation
void ObjectController::handleSecureTradeInvitation(uint64 targetId,Message* message)
{
//targetId is the Id of the one who IS INVITING
//receiverId is the Id of the one who GETS INVITED
uint32 unknown,error;
uint64 receiverId,unknown64;
message->getUint32(unknown);
message->getUint32(error);
message->getUint64(unknown64);//sender (target) id
message->getUint64(receiverId);
PlayerObject* invitingPlayer = dynamic_cast<PlayerObject*>(mObject);
//PlayerObject* invitingPlayer =
PlayerObject* invitedPlayer = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(receiverId));
switch(error)
{
case 2:
{
// snd invitation returns error as 2 and the id of the invited as 0 :(
invitedPlayer = dynamic_cast<PlayerObject*>(invitingPlayer->GetCreature()->getTarget());
error = 0;
}
break;
case 0:
{
//first invitation set the setInvite to the Inviter
//invitedPlayer = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(receiverId));
}
break;
default:
{
// Always use a default if message damaged....
DLOG(info) << "ObjController:: Error in trade invitation";
// Since receiver is default NULL, we can use the error message below
// return;
}
}
if(!invitedPlayer)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "start_fail_target_not_player"), invitingPlayer);
return;
}
if(invitedPlayer->GetCreature()->states.checkStatesEither(CreatureState_Combat | CreatureState_Tumbling | CreatureState_Swimming))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer);
return;
}
// Can NOT use bitwise operation on non bitwise constants. CreaturePostures are used exclusive.
// if(invitedPlayer->states.checkPosturesEither(CreaturePosture_Dead | CreaturePosture_Incapacitated))
if (invitedPlayer->GetCreature()->states.checkPosture(CreaturePosture_Dead) || invitedPlayer->GetCreature()->states.checkPosture(CreaturePosture_Incapacitated))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer);
return;
}
// Can NOT use bitwise operation on non bitwise constants.
// if(invitingPlayer->states.checkPosturesEither(CreaturePosture_Dead | CreaturePosture_Incapacitated))
if (invitingPlayer->GetCreature()->states.checkPosture(CreaturePosture_Dead) || invitingPlayer->GetCreature()->states.checkPosture(CreaturePosture_Incapacitated))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer);
return;
}
if (error == 0)
{
if (invitedPlayer->getTradeStatus() == false )
{
// If sender is invited by receiver already, then accept even if receiver have sender in the Ignore-list.
if (!invitingPlayer->getTrade()->verifyInvitation(invitedPlayer))
{
// We are not invited, check Ignore.
// If receiver have sender ignored, auto decline trade request.
BString ignoreName = invitingPlayer->GetCreature()->getFirstName().c_str();
ignoreName.toLower();
// check receivers ignorelist
if (invitedPlayer->checkIgnoreList(ignoreName.getCrc()))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "request_player_denied_prose", invitedPlayer->getId(), 0, 0), invitingPlayer);
return;
}
}
gTradeManager->addTradeInvitation(invitedPlayer,invitingPlayer);
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "request_player_busy_prose", invitedPlayer->getId(), 0, 0), invitingPlayer);
}
}
}