Using small vector.
This commit is contained in:
parent
bde031f393
commit
a693da20bf
@ -45,8 +45,9 @@ namespace character {
|
|||||||
|
|
||||||
class BillyObjects final {
|
class BillyObjects final {
|
||||||
public:
|
public:
|
||||||
|
static constexpr std::size_t max_num_obj{ 3 };
|
||||||
using billyObject = std::variant<weapons, equipments, tools>;
|
using billyObject = std::variant<weapons, equipments, tools>;
|
||||||
using container = ankerl::svector<billyObject, 3>;
|
using container = ankerl::svector<billyObject, max_num_obj>;
|
||||||
|
|
||||||
static constexpr std::string_view sword{ "Sword" };
|
static constexpr std::string_view sword{ "Sword" };
|
||||||
static constexpr std::string_view lance{ "Lance" };
|
static constexpr std::string_view lance{ "Lance" };
|
||||||
@ -69,12 +70,9 @@ namespace character {
|
|||||||
|
|
||||||
void pop_object(CharacterSheet &sheet) noexcept;
|
void pop_object(CharacterSheet &sheet) noexcept;
|
||||||
|
|
||||||
[[nodiscard]] const container &get_objects() const noexcept { return objects; }
|
|
||||||
|
|
||||||
// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
|
// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
container objects;
|
|
||||||
std::plus<std::uint32_t> plus;
|
std::plus<std::uint32_t> plus;
|
||||||
std::minus<std::uint32_t> minus;
|
std::minus<std::uint32_t> minus;
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ namespace character {
|
|||||||
using characteristic::Characteristic;
|
using characteristic::Characteristic;
|
||||||
|
|
||||||
void BillyObjects::push_object(const billyObject &object, CharacterSheet &sheet) noexcept {
|
void BillyObjects::push_object(const billyObject &object, CharacterSheet &sheet) noexcept {
|
||||||
if (objects.size() < 3) {
|
if (sheet.objects.size() < 3) {
|
||||||
objects.emplace_back(object);
|
sheet.objects.emplace_back(object);
|
||||||
|
|
||||||
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||||
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||||
@ -48,9 +48,9 @@ namespace character {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BillyObjects::pop_object(CharacterSheet &sheet) noexcept {
|
void BillyObjects::pop_object(CharacterSheet &sheet) noexcept {
|
||||||
if (!objects.empty()) {
|
if (!sheet.objects.empty()) {
|
||||||
const billyObject obj = objects.back();
|
const billyObject obj = sheet.objects.back();
|
||||||
objects.pop_back();
|
sheet.objects.pop_back();
|
||||||
|
|
||||||
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||||
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||||
|
Loading…
Reference in New Issue
Block a user