nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
items.h
Go to the documentation of this file.
1#ifndef NANOMMO_CONTENT_ITEMS_H_
2#define NANOMMO_CONTENT_ITEMS_H_
3
4#include <cstdint>
5#include <map>
6#include <string_view>
7#include <vector>
8
9#include "absl/status/statusor.h"
10#include "content/items.pb.h"
11
12namespace nanommo {
13
14/// How many slots each player's bag has.
15constexpr uint32_t kBagSlots = 24;
16
17/// The items in the items file, by id.
18struct ItemTable {
19 std::map<uint32_t, items::Item> by_id;
20 /// What each new player starts with.
21 std::vector<items::Stack> starting;
22};
23
24/// The items in text format, or what's wrong with them: a field items.proto
25/// doesn't have, an item with no id or with another's, or with parts that
26/// don't go together, such as a weapon that isn't held in the main hand, or a
27/// kit with an item the file doesn't have.
28absl::StatusOr<ItemTable> ParseItems(std::string_view text);
29
30/// How many of the item go in one slot of a bag.
31uint32_t StackSize(const items::Item& item);
32
33/// How many are in the stack, which is one when it doesn't say.
34uint32_t CountOf(const items::Stack& stack);
35
36/// The slot's name, as a player would say it, such as "main hand".
37std::string_view SlotName(items::Slot slot);
38
39} // namespace nanommo
40
41#endif // NANOMMO_CONTENT_ITEMS_H_
Definition chat.cc:9
uint32_t CountOf(const items::Stack &stack)
How many are in the stack, which is one when it doesn't say.
Definition items.cc:102
absl::StatusOr< ItemTable > ParseItems(std::string_view text)
Definition items.cc:61
constexpr uint32_t kBagSlots
How many slots each player's bag has.
Definition items.h:15
uint32_t StackSize(const items::Item &item)
How many of the item go in one slot of a bag.
Definition items.cc:98
std::string_view SlotName(items::Slot slot)
The slot's name, as a player would say it, such as "main hand".
Definition items.cc:106
The items in the items file, by id.
Definition items.h:18
std::vector< items::Stack > starting
What each new player starts with.
Definition items.h:21
std::map< uint32_t, items::Item > by_id
Definition items.h:19