本文整理汇总了C++中Inventory::getCredits方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getCredits方法的具体用法?C++ Inventory::getCredits怎么用?C++ Inventory::getCredits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getCredits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyMoney
//=============================================================================
//handles the financial side
//
void EntertainerManager::applyMoney(PlayerObject* customer,PlayerObject* designer,int32 amount)
{
int32 amountcash;
int32 amountbank;
int8 sql[1024];
amountcash = amount;
amountbank = 0;
Inventory* inventory = dynamic_cast<Inventory*>(customer->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
if(inventory && inventory->getCredits() < amount)
{
// cash alone isnt sufficient
amountcash = inventory->getCredits();
amountbank = (amount - amountcash);
}
EntertainerManagerAsyncContainer* asyncContainer = new EntertainerManagerAsyncContainer(EMQuery_IDFinances,0);
Transaction* mTransaction = mDatabase->startTransaction(this,asyncContainer);
asyncContainer->customer = customer;
asyncContainer->performer = designer;
asyncContainer->amountcash = amountcash;
asyncContainer->amountbank = amountbank;
sprintf(sql,"UPDATE inventories SET credits=credits-%i WHERE id=%"PRIu64"",amountcash, customer->getId()+1);
mTransaction->addQuery(sql);
sprintf(sql,"UPDATE banks SET credits=credits-%i WHERE id=%"PRIu64"",amountbank, customer->getId()+4);
mTransaction->addQuery(sql);
sprintf(sql,"UPDATE banks SET credits=credits+%i WHERE id=%"PRIu64"",amount, designer->getId()+4);
mTransaction->addQuery(sql);
mTransaction->execute();
}
示例2: handleUIEvent
void InsuranceTerminal::handleUIEvent(uint32 action,int32 element,string inputStr,UIWindow* window)
{
// gLogger->logMsgF("InsuranceTerminal::handleUIEvent You are here!",MSG_NORMAL);
if(window == NULL)
{
return;
}
PlayerObject* playerObject = window->getOwner(); // window owner
if(playerObject == NULL || !playerObject->isConnected() || playerObject->getSamplingState() || playerObject->isIncapacitated() || playerObject->isDead()|| playerObject->checkState(CreatureState_Combat))
{
return;
}
switch(window->getWindowType())
{
case SUI_Window_Insurance_Newbie_MessageBox: // Tried to insure item when still having free rounds left.
{
switch(action)
{
case 0: // Yes
{
// Player selected to continue with insurance of item even if no need for.
// gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox Yes",MSG_NORMAL);
// Build the items list and optional use error-messages if needed.
BStringVector insuranceList;
this->getUninsuredItems(playerObject, &insuranceList);
// We should display all uninsured items that can be insured, and that are wearing or carrying in our inventory.
// Items in backpackage or in other containers within our inventory shall also be handled.
gUIManager->createNewListBox(this,"insure","@sui:mnu_insure","Select an item to insure.",insuranceList,playerObject,SUI_Window_Insurance_ListBox, SUI_MB_OKCANCEL);
}
break;
case 1: // No
{
// Player selected to abort, since all items are still treated as insured.
// gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox No",MSG_NORMAL);
}
break;
default:
{
gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox Invalid selection!",MSG_NORMAL);
}
break;
}
}
break;
case SUI_Window_Insurance_ListBox:
{
switch (action)
{
case 0: // OK
{
// Insure one item.
// gLogger->logMsgF("SUI_Window_Insurance_ListBox OK",MSG_NORMAL);
Inventory* inventoryObject = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Bank* bankObject = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
if(!inventoryObject || !bankObject)
return;
int32 creditsInInventory = inventoryObject->getCredits();
int32 creditsAtBank = bankObject->getCredits();
if (mSortedInsuranceList.size() == 0)
{
// You have no insurable items.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "no_insurables");
}
else if (element > (int32)mSortedInsuranceList.size() - 1 || element < 0)
{
// Unable to process insure item request.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "bad_insure_request");
}
else
{
string selectedItemm((mSortedInsuranceList.at(element).first).getAnsi());
selectedItemm.convert(BSTRType_Unicode16);
Object* object = gWorldManager->getObjectById(mSortedInsuranceList.at(element).second);
if (!object)
{
// 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");
//.........这里部分代码省略.........
示例3: handleUIEvent
void PlayerStructure::handleUIEvent(BString strCharacterCash, BString strHarvesterCash, UIWindow* window)
{
PlayerObject* player = window->getOwner();
if(!player)
{
return;
}
switch(window->getWindowType())
{
case SUI_Window_Deposit_Power:
{
strCharacterCash.convert(BSTRType_ANSI);
BString characterPower = strCharacterCash;
strHarvesterCash.convert(BSTRType_ANSI);
BString harvesterPower = strHarvesterCash;
int32 harvesterPowerDelta = atoi(harvesterPower.getAnsi());
gStructureManager->deductPower(player,harvesterPowerDelta);
this->setCurrentPower(getCurrentPower()+harvesterPowerDelta);
gWorldManager->getDatabase()->executeSqlAsync(0,0,"UPDATE %s.structure_attributes SET value='%u' WHERE structure_id=%" PRIu64 " AND attribute_id=384",gWorldManager->getDatabase()->galaxy(),getCurrentPower(),this->getId());
}
break;
case SUI_Window_Pay_Maintenance:
{
strCharacterCash.convert(BSTRType_ANSI);
strHarvesterCash.convert(BSTRType_ANSI);
Bank* bank = dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
int32 bankFunds = bank->credits();
int32 inventoryFunds = inventory->getCredits();
int32 funds = inventoryFunds + bankFunds;
int32 characterMoneyDelta = atoi(strCharacterCash.getAnsi()) - funds;
int32 harvesterMoneyDelta = atoi(strHarvesterCash.getAnsi()) - this->getCurrentMaintenance();
// the amount transfered must be greater than zero
if(harvesterMoneyDelta == 0 || characterMoneyDelta == 0)
{
return;
}
//lets get the money from the bank first
if((bankFunds +characterMoneyDelta)< 0)
{
characterMoneyDelta += bankFunds;
bankFunds = 0;
inventoryFunds += characterMoneyDelta;
}
else
{
bankFunds += characterMoneyDelta;
}
if(inventoryFunds < 0)
{
return;
}
int32 maintenance = this->getCurrentMaintenance() + harvesterMoneyDelta;
if(maintenance < 0)
{
return;
}
bank->credits(bankFunds);
inventory->setCredits(inventoryFunds);
gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.banks SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),bank->credits(),bank->getId()));
gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.inventories SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),inventory->getCredits(),inventory->getId()));
//send the appropriate deltas.
gMessageLib->sendInventoryCreditsUpdate(player);
gMessageLib->sendBankCreditsUpdate(player);
//get the structures conditiondamage and see whether it needs repair
uint32 damage = this->getDamage();
if(damage)
{
uint32 cost = this->getRepairCost();
uint32 all = cost*damage;
if(maintenance <= (int32)all)
{
all -= (uint32)maintenance;
damage = (uint32)(all/cost);
maintenance = 0;
}
//.........这里部分代码省略.........