Big BIG refactor to make inventory use a model that's placed into the world, following a more sane MVC style.
This commit is contained in:
parent
119b3ed11d
commit
a0eff927b6
21 changed files with 270 additions and 123 deletions
47
tests/inventory.cpp
Normal file
47
tests/inventory.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <string>
|
||||
#include "inventory.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
|
||||
TEST_CASE("base test", "[inventory]") {
|
||||
inventory::Model inv;
|
||||
DinkyECS::Entity test_ent = 1;
|
||||
|
||||
inv.add("hand_l", test_ent);
|
||||
inv.invariant();
|
||||
|
||||
auto& slot = inv.get(test_ent);
|
||||
REQUIRE(slot == "hand_l");
|
||||
|
||||
auto ent = inv.get(slot);
|
||||
REQUIRE(ent == test_ent);
|
||||
|
||||
REQUIRE(inv.has(ent));
|
||||
REQUIRE(inv.has(slot));
|
||||
|
||||
// test base remove
|
||||
inv.remove(slot, ent);
|
||||
REQUIRE(!inv.has(slot));
|
||||
REQUIRE(!inv.has(ent));
|
||||
|
||||
// test remove just by slot
|
||||
inv.add("hand_r", test_ent);
|
||||
REQUIRE(inv.has("hand_r"));
|
||||
REQUIRE(inv.has(test_ent));
|
||||
inv.invariant();
|
||||
|
||||
inv.remove("hand_r");
|
||||
REQUIRE(!inv.has("hand_r"));
|
||||
REQUIRE(!inv.has(test_ent));
|
||||
|
||||
// test remove just by entity
|
||||
inv.add("pocket_l", test_ent);
|
||||
REQUIRE(inv.has("pocket_l"));
|
||||
REQUIRE(inv.has(test_ent));
|
||||
inv.invariant();
|
||||
inv.remove(test_ent);
|
||||
REQUIRE(!inv.has("pocket_l"));
|
||||
REQUIRE(!inv.has(test_ent));
|
||||
}
|
|
@ -14,6 +14,7 @@ using std::string;
|
|||
using matrix::Matrix;
|
||||
|
||||
shared_ptr<Map> make_map() {
|
||||
// BUG? I mean, it's a shared_ptr so it should keep it around but....
|
||||
LevelManager levels;
|
||||
GameLevel level = levels.current();
|
||||
return level.map;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue