单个玩家的资源账本:当前量、上限、收支与浪费统计。 更多...
#include <EconomyLedger.h>
类 | |
| struct | Snapshot |
| Owning deterministic copy of all balance and accounting counters. 更多... | |
Public 成员函数 | |
| int | credit (const std::string &type, int amount) |
| 入账 amount。 | |
| bool | debit (const std::string &type, int amount) |
| 出账 amount;余额不足时返回 false 且不扣款。 | |
| bool | canAfford (const std::string &type, int amount) const |
| 是否可负担 amount。 | |
| int | get (const std::string &type) const |
| 当前持有量。 | |
| int | getCap (const std::string &type) const |
| 类型上限(来自注册表;未注册返回 0=不限)。 | |
| int | getWasted (const std::string &type) const |
| 因满仓而浪费的累计量。 | |
| int | getIncome (const std::string &type) const |
| 累计入账。 | |
| int | getExpense (const std::string &type) const |
| 累计出账。 | |
| void | swap (EconomyLedger &other) noexcept |
| Swap two ledgers without exposing an intermediate partial state. | |
| Snapshot | snapshot () const |
| Capture every ledger counter in deterministic key order. | |
| void | restore (const Snapshot &snapshot) |
| Restore a previously captured complete ledger state. | |
详细描述
单个玩家的资源账本:当前量、上限、收支与浪费统计。
在文件 EconomyLedger.h 第 14 行定义.
成员函数说明
◆ canAfford()
| bool eve::economy::EconomyLedger::canAfford | ( | const std::string & | type, |
| int | amount | ||
| ) | const |
◆ credit()
| int eve::economy::EconomyLedger::credit | ( | const std::string & | type, |
| int | amount | ||
| ) |
入账 amount。
- 返回
- 实际入账量(受类型上限约束,超限部分记为浪费)。
在文件 EconomyLedger.cpp 第 9 行定义.
引用了 current, eve::economy::ResourceTypeRegistry::find() , 以及 type.
◆ debit()
| bool eve::economy::EconomyLedger::debit | ( | const std::string & | type, |
| int | amount | ||
| ) |
◆ get()
| int eve::economy::EconomyLedger::get | ( | const std::string & | type | ) | const |
◆ getCap()
| int eve::economy::EconomyLedger::getCap | ( | const std::string & | type | ) | const |
类型上限(来自注册表;未注册返回 0=不限)。
在文件 EconomyLedger.cpp 第 44 行定义.
◆ getExpense()
| int eve::economy::EconomyLedger::getExpense | ( | const std::string & | type | ) | const |
◆ getIncome()
| int eve::economy::EconomyLedger::getIncome | ( | const std::string & | type | ) | const |
◆ getWasted()
| int eve::economy::EconomyLedger::getWasted | ( | const std::string & | type | ) | const |
◆ restore()
| void eve::economy::EconomyLedger::restore | ( | const Snapshot & | snapshot | ) |
Restore a previously captured complete ledger state.
在文件 EconomyLedger.cpp 第 77 行定义.
引用了 eve::economy::EconomyLedger::Snapshot::current, eve::economy::EconomyLedger::Snapshot::expense, eve::economy::EconomyLedger::Snapshot::income, snapshot() , 以及 eve::economy::EconomyLedger::Snapshot::wasted.
◆ snapshot()
| EconomyLedger::Snapshot eve::economy::EconomyLedger::snapshot | ( | ) | const |
Capture every ledger counter in deterministic key order.
在文件 EconomyLedger.cpp 第 72 行定义.
被这些函数引用 restore() , 以及 eve::economy::EconomySystem::snapshot().
◆ swap()
|
noexcept |
Swap two ledgers without exposing an intermediate partial state.
- 参数
-
other Ledger whose complete state is exchanged with this one.
- 备注
- Used by atomic adapters after a candidate ledger has been fully validated and built.
在文件 EconomyLedger.cpp 第 64 行定义.
该类的文档由以下文件生成:
- src/modules/economy/EconomyLedger.h
- src/modules/economy/EconomyLedger.cpp