Standardized on using only DinkyECS:Entity for most inventory:::Model operations, then create swap based on the same entities.
This commit is contained in:
parent
8c8d6dc9e7
commit
784f753e72
6 changed files with 62 additions and 53 deletions
|
@ -27,28 +27,24 @@ TEST_CASE("base test", "[inventory]") {
|
|||
REQUIRE(inv.has(slot));
|
||||
|
||||
// test base remove
|
||||
inv.remove(slot, ent);
|
||||
inv.remove(ent);
|
||||
REQUIRE(!inv.has(slot));
|
||||
REQUIRE(!inv.has(ent));
|
||||
|
||||
// test remove just by slot
|
||||
good = inv.add("hand_r", test_ent);
|
||||
REQUIRE(good);
|
||||
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
|
||||
good = inv.add("pocket_l", test_ent);
|
||||
REQUIRE(good);
|
||||
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));
|
||||
}
|
||||
|
||||
TEST_CASE("test swapping items", "[inventory-swap]") {
|
||||
inventory::Model inv;
|
||||
DinkyECS::Entity hand_l_ent = 10;
|
||||
DinkyECS::Entity hand_r_ent = 20;
|
||||
|
||||
inv.add("hand_l", hand_l_ent);
|
||||
inv.add("hand_r", hand_r_ent);
|
||||
REQUIRE(inv.count() == 2);
|
||||
|
||||
inv.swap(hand_l_ent, hand_r_ent);
|
||||
|
||||
REQUIRE(inv.get("hand_l") == hand_r_ent);
|
||||
REQUIRE(inv.get("hand_r") == hand_l_ent);
|
||||
|
||||
REQUIRE(inv.count() == 2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue