|
nanoMMO 0.97.8
Building an MMO: The Engineering Series
|
#include <inventory.h>
Public Member Functions | |
| Inventory ()=default | |
| Inventory (protocol::Inventory items) | |
| const protocol::Inventory & | items () const |
| uint32_t | revision () const |
| uint32_t | gold () 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. | |
| uint32_t | Add (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. | |
| bool | Wear (const ItemTable &table, const items::Stack &stack) |
| void | Number (const ItemTable &table) |
| 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. | |
| 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. | |
| absl::Status | Destroy (const protocol::Place &place) |
| Throws away all of what's at the place. | |
Static Public Attributes | |
| static constexpr uint32_t | kBagSlots = nanommo::kBagSlots |
| static constexpr uint32_t | kMostGold = 1'000'000'000 |
What a player carries, in a bag of kBagSlots, and wears, an item in each slot, kept as the message that's saved and sent. Each change takes it to its next revision. Items the table doesn't have, such as one taken out of the content, stay where they are, so that nothing is lost by a mistake in the file, but they can't be worn, used or stacked.
Definition at line 24 of file inventory.h.
|
default |
|
inlineexplicit |
Definition at line 33 of file inventory.h.
| uint32_t nanommo::Inventory::Add | ( | const ItemTable & | table, |
| const items::Stack & | stack ) |
Into the bag: onto stacks of the item that have room, then into empty slots, from the first. Returns how many didn't fit.
Definition at line 121 of file inventory.cc.
| uint32_t nanommo::Inventory::AddGold | ( | uint32_t | amount | ) |
Adds the gold, up to kMostGold, and returns how much didn't fit.
Definition at line 170 of file inventory.cc.
| const items::Stack * nanommo::Inventory::At | ( | const protocol::Place & | place | ) | const |
What's at the place, or nullptr when it's empty, or isn't a place.
Definition at line 90 of file inventory.cc.
| absl::Status nanommo::Inventory::Destroy | ( | const protocol::Place & | place | ) |
Throws away all of what's at the place.
Definition at line 289 of file inventory.cc.
|
inline |
Definition at line 37 of file inventory.h.
|
inline |
Definition at line 35 of file inventory.h.
| absl::Status nanommo::Inventory::Move | ( | const ItemTable & | table, |
| const protocol::Place & | from, | ||
| const protocol::Place & | to, | ||
| uint32_t | count = 0 ) |
Moves count of what's at from to to, or all of it given zero: into an empty place, onto a stack of the same item, as many as it has room for, or swapping with what's there. What's worn has to be worn in its slot. Or the error says why not, in words for the player.
Definition at line 193 of file inventory.cc.
| void nanommo::Inventory::Number | ( | const ItemTable & | table | ) |
Gives each item that doesn't stack and has no serial, such as the kit's or one saved before serials, a NewSerial, and moves to the next revision if it gave any, so that they're saved.
Definition at line 155 of file inventory.cc.
|
inline |
Definition at line 36 of file inventory.h.
| absl::Status nanommo::Inventory::Take | ( | const protocol::Place & | place, |
| uint32_t | count ) |
Takes count off the stack at the place, as trading some does, or the error says there aren't that many there.
Definition at line 263 of file inventory.cc.
| absl::Status nanommo::Inventory::TakeGold | ( | uint32_t | amount | ) |
Takes the gold away, or the error says there isn't that much.
Definition at line 278 of file inventory.cc.
| absl::Status nanommo::Inventory::TakeOne | ( | const protocol::Place & | place | ) |
Takes one off the stack at the place, as using one does.
Definition at line 249 of file inventory.cc.
| bool nanommo::Inventory::Wear | ( | const ItemTable & | table, |
| const items::Stack & | stack ) |
Wears it, if it's worn and its slot is free, and returns whether it did, as for a new player's kit.
Definition at line 180 of file inventory.cc.
|
staticconstexpr |
Definition at line 26 of file inventory.h.
|
staticconstexpr |
The most gold a player carries: a billion, so that adding any two amounts of it never goes past what a uint32_t holds.
Definition at line 30 of file inventory.h.