本文整理汇总了C++中Bank::updateCredits方法的典型用法代码示例。如果您正苦于以下问题:C++ Bank::updateCredits方法的具体用法?C++ Bank::updateCredits怎么用?C++ Bank::updateCredits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bank
的用法示例。
在下文中一共展示了Bank::updateCredits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleUIEvent
//.........这里部分代码省略.........
// Invalid object.
// Insure attempt failed.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "insure_fail");
break;
}
TangibleObject* tangibleObject = dynamic_cast<TangibleObject*>(object);
if (!tangibleObject)
{
// Not a tangible object.
// Insure attempt failed.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "insure_fail");
}
else if (!tangibleObject->hasInternalAttribute("insured"))
{
// [Insurance] Item uninsurable: %TT.
gMessageLib->sendSystemMessage(playerObject,L"","error_message","prose_item_uninsurable", "","", L"", 0, "", "", selectedItemm);
}
else if (tangibleObject->getInternalAttribute<bool>("insured"))
{
// [Insurance] Item already insured: %TT.
gMessageLib->sendSystemMessage(playerObject,L"","error_message","prose_item_already_insured", "","", L"", 0, "", "", selectedItemm);
}
else if ((creditsAtBank+creditsInInventory) < mInsuranceFee)
{
// You have insufficient funds to insure your %TT.
gMessageLib->sendSystemMessage(playerObject,L"","error_message","prose_nsf_insure", "","", L"", 0, "", "", selectedItemm);
}
else
{
int32 delta = creditsInInventory - mInsuranceFee;
if(delta >= 0)
{
inventoryObject->updateCredits(-mInsuranceFee);
}
else if(delta < 0 && creditsAtBank >= (-delta))
{
inventoryObject->updateCredits(mInsuranceFee + delta);
bankObject->updateCredits(delta);
}
// The credits is drawn from the player inventory and/or bank.
// System message: You successfully make a payment of %DI credits to %TO.
gMessageLib->sendSystemMessage(playerObject, L"", "base_player", "prose_pay_acct_success", "terminal_name", "terminal_insurance", L"", mInsuranceFee);
// Update attribute.
// string str("insured");
tangibleObject->setInternalAttribute("insured","1");
gWorldManager->getDatabase()->ExecuteSqlAsync(NULL,NULL,"UPDATE item_attributes SET value=1 WHERE item_id=%"PRIu64" AND attribute_id=%u",tangibleObject->getId(), 1270);
//gLogger->logMsgF("UPDATE item_attributes SET value=1 WHERE item_id=%"PRIu64" AND attribute_id=%u", MSG_NORMAL, tangibleObject->getId(), 1270);
tangibleObject->setTypeOptions(tangibleObject->getTypeOptions() | 4);
// Update insurance status.
(void)gMessageLib->sendUpdateTypeOption(tangibleObject, playerObject);
// You successfully insure your %TT.
gMessageLib->sendSystemMessage(playerObject,L"","base_player","prose_insure_success", "","", L"", 0, "", "", selectedItemm);
}
/*else
{
// An attempt to insure your %TT has failed. Most likely, this is due to lack of funds.
gMessageLib->sendSystemMessage(playerObject,L"","error_message","prose_insure_fail", "","", L"", 0, "", "", selectedItemm);
}*/
}
示例2: _handlePurchaseTicket
void ObjectController::_handlePurchaseTicket(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
BString dataStr;
BStringVector dataElements;
uint16 elements;
float purchaseRange = gWorldConfig->getConfiguration<float>("Player_TicketTerminalAccess_Distance",(float)10.0);
if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return;
}
//however we are able to use the purchaseticket command in starports
//without having to use a ticketvendor by just giving commandline parameters
//when we are *near* a ticket vendor
TravelTerminal* terminal = dynamic_cast<TravelTerminal*> (gWorldManager->getNearestTerminal(playerObject,TanType_TravelTerminal));
// iterate through the results
if((!terminal)|| (glm::distance(terminal->mPosition, playerObject->mPosition) > purchaseRange))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "too_far"), playerObject);
return;
}
playerObject->setTravelPoint(terminal);
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
elements = dataStr.split(dataElements,' ');
if(elements < 4)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
// get price and planet ids
TicketProperties ticketProperties;
gTravelMapHandler->getTicketInformation(dataElements,&ticketProperties);
if(!ticketProperties.dstPoint)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
uint8 roundTrip = 0;
if(elements > 4)
roundTrip = atoi(dataElements[4].getAnsi());
if(dataElements[4].getCrc() == BString("single").getCrc())
roundTrip = 0;
//how many tickets will it be?
uint32 amount = 1;
if(roundTrip)
amount = 2;
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Bank* bank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
if(!inventory->checkSlots(static_cast<uint8>(amount)))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "inv_full"), playerObject);
return;
}
if(roundTrip == 1)
{
ticketProperties.price *= 2;
}
// update bank or inventory credits
if(!(inventory->updateCredits(-ticketProperties.price)))
{
if(!(bank->updateCredits(-ticketProperties.price)))
{
//gMessageLib->sendSystemMessage(entertainer,L"","travel","route_not_available");
gUIManager->createNewMessageBox(NULL,"ticketPurchaseFailed","The Galactic Travel Commission","You do not have enough money to complete the ticket purchase.",playerObject);
return;
}
}
if(playerObject->isConnected())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_pay_acct_success", "", "", "", "", "money/acct_n", "travelsystem", ticketProperties.price), playerObject);
gObjectFactory->requestNewTravelTicket(inventory,ticketProperties,inventory->getId(),99);
//.........这里部分代码省略.........