RitualBelt now has an API.

master
Zed A. Shaw 2 weeks ago
parent 31b35b43eb
commit a70f11646a
  1. 16
      rituals.cpp
  2. 7
      rituals.hpp
  3. 10
      tests/rituals.cpp

@ -102,4 +102,20 @@ namespace combat {
fmt::println("\n"); fmt::println("\n");
} }
RitualAction& RitualBelt::get(int index) {
return equipped.at(index);
}
void RitualBelt::equip(int index, RitualAction& action) {
equipped.insert_or_assign(index, action);
}
bool RitualBelt::has(int index) {
return equipped.contains(index);
}
void RitualBelt::unequip(int index) {
equipped.erase(index);
}
} }

@ -62,6 +62,11 @@ namespace combat {
}; };
struct RitualBelt { struct RitualBelt {
std::vector<RitualAction> equipped; std::unordered_map<int, RitualAction> equipped;
RitualAction& get(int index);
void equip(int index, RitualAction& action);
bool has(int index);
void unequip(int index);
}; };
} }

@ -76,11 +76,17 @@ TEST_CASE("the ritual belt works", "[rituals-belt]") {
{ {
auto action = re.finalize(plan); auto action = re.finalize(plan);
the_belt.equipped.push_back(action); the_belt.equip(0, action);
REQUIRE(the_belt.has(0));
} }
{ {
auto action = the_belt.equipped.at(0); auto action = the_belt.get(0);
action.dump(); action.dump();
} }
{
the_belt.unequip(0);
REQUIRE(!the_belt.has(0));
}
} }

Loading…
Cancel
Save