Lighter library with a rework on characteristics.

This commit is contained in:
Pcornat 2024-10-29 23:23:56 +01:00
parent f412b1b997
commit 7e613ca2a0
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
10 changed files with 404 additions and 142 deletions

View file

@ -179,6 +179,24 @@ namespace character {
}
}
void BillyObjects::check_dagger_conditions(const CharacterSheet &sheet,
Characteristic &localHabilete,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) {
int count_weapons = 0;
bool is_there_bow = false;
std::for_each(sheet.objects.cbegin(), sheet.objects.cend(), [&](const billyObject &object) -> void {
if (const weapons *p = std::get_if<weapons>(std::addressof(object)); p != nullptr) {
++count_weapons;
if (*p == weapons::Bow) {
is_there_bow = true;
}
}
});
if (count_weapons < 2 && !is_there_bow) {
localHabilete.materiel = operation(localHabilete.materiel, 1);
}
}
std::string_view BillyObjects::billy_object_to_string(const billyObject &object) noexcept {
return std::visit(overloaded{
[](const weapons &arg) {
@ -253,4 +271,24 @@ namespace character {
}, object);
}
}
ankerl::svector<bool, 3> BillyObjects::check_conformity(const CharacterSheet &sheet) noexcept {
ankerl::svector<bool, 3> output;
std::transform(sheet.get_objects().cbegin(),
sheet.get_objects().cend(), std::back_inserter(output),
[&sheet](const billyObject &object) -> bool {
return std::visit(overloaded{
[](const weapons weapon) { return false; },
[](const equipments equipment) { return false; },
[](const tools tool) { return false; },
}, object);
});
const int total = std::accumulate(sheet.get_objects().cbegin(),
sheet.get_objects().cend(),
0,
[](const int a, const billyObject &object) -> int {
return 0;
});
return output;
}
}