载入中...
搜索中...
未找到
EconomyLedger.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <string>
6#include <map>
7#include <unordered_map>
8
9namespace eve::economy {
10
15public:
17 struct Snapshot {
18 std::map<std::string, int> current;
19 std::map<std::string, int> wasted;
20 std::map<std::string, int> income;
21 std::map<std::string, int> expense;
22 };
27 int credit(const std::string& type, int amount);
29 bool debit(const std::string& type, int amount);
31 bool canAfford(const std::string& type, int amount) const;
33 int get(const std::string& type) const;
35 int getCap(const std::string& type) const;
37 int getWasted(const std::string& type) const;
39 int getIncome(const std::string& type) const;
41 int getExpense(const std::string& type) const;
42
49 void swap(EconomyLedger& other) noexcept;
51 [[nodiscard]] Snapshot snapshot() const;
53 void restore(const Snapshot& snapshot);
54
55private:
56 std::unordered_map<std::string, int> current_;
57 std::unordered_map<std::string, int> wasted_;
58 std::unordered_map<std::string, int> income_;
59 std::unordered_map<std::string, int> expense_;
60};
61
62} // namespace eve::economy
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
单个玩家的资源账本:当前量、上限、收支与浪费统计。
Owning deterministic copy of all balance and accounting counters.
std::map< std::string, int > wasted
std::map< std::string, int > income
std::map< std::string, int > current
std::map< std::string, int > expense