1#ifndef NANOMMO_SERVER_INVENTORY_H_
2#define NANOMMO_SERVER_INVENTORY_H_
7#include "absl/status/status.h"
9#include "protocol/nanommo.pb.h"
30 static constexpr uint32_t
kMostGold = 1'000'000'000;
35 const protocol::Inventory&
items()
const {
return items_; }
36 uint32_t
revision()
const {
return items_.revision(); }
37 uint32_t
gold()
const {
return items_.gold(); }
40 const items::Stack*
At(
const protocol::Place& place)
const;
44 uint32_t
Add(
const ItemTable& table,
const items::Stack& stack);
47 uint32_t
AddGold(uint32_t amount);
62 absl::Status
Move(
const ItemTable& table,
const protocol::Place& from,
63 const protocol::Place& to, uint32_t count = 0);
66 absl::Status
TakeOne(
const protocol::Place& place);
70 absl::Status
Take(
const protocol::Place& place, uint32_t count);
73 absl::Status
TakeGold(uint32_t amount);
76 absl::Status
Destroy(
const protocol::Place& place);
79 items::Stack* MutableAt(
const protocol::Place& place);
80 void Put(
const protocol::Place& place, items::Stack stack);
81 void Clear(
const protocol::Place& place);
82 void Changed() { items_.set_revision(items_.revision() + 1); }
84 protocol::Inventory items_;
bool Wear(const ItemTable &table, const items::Stack &stack)
uint32_t AddGold(uint32_t amount)
Adds the gold, up to kMostGold, and returns how much didn't fit.
Inventory(protocol::Inventory items)
static constexpr uint32_t kBagSlots
absl::Status Destroy(const protocol::Place &place)
Throws away all of what's at the place.
uint32_t revision() const
absl::Status Move(const ItemTable &table, const protocol::Place &from, const protocol::Place &to, uint32_t count=0)
absl::Status TakeOne(const protocol::Place &place)
Takes one off the stack at the place, as using one does.
uint32_t Add(const ItemTable &table, const items::Stack &stack)
const protocol::Inventory & items() const
const items::Stack * At(const protocol::Place &place) const
What's at the place, or nullptr when it's empty, or isn't a place.
void Number(const ItemTable &table)
static constexpr uint32_t kMostGold
absl::Status Take(const protocol::Place &place, uint32_t count)
absl::Status TakeGold(uint32_t amount)
Takes the gold away, or the error says there isn't that much.
constexpr uint32_t kBagSlots
How many slots each player's bag has.
What a change to another member of a guild did, for the news.
The items in the items file, by id.