Lighter library with a rework on characteristics.
This commit is contained in:
parent
f412b1b997
commit
7e613ca2a0
10 changed files with 404 additions and 142 deletions
|
@ -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;
|
||||
}
|
||||
}
|
170
src/generic_object.cpp
Normal file
170
src/generic_object.cpp
Normal file
|
@ -0,0 +1,170 @@
|
|||
//
|
||||
// Created by postaron on 01/09/24.
|
||||
//
|
||||
|
||||
#include "generic_object.hpp"
|
||||
|
||||
namespace character {
|
||||
using characteristic::characType;
|
||||
|
||||
static constexpr std::string_view jsonKey{ "billy_objects" };
|
||||
|
||||
static constexpr std::string_view sword{ "Sword" };
|
||||
static constexpr std::string_view lance{ "Lance" };
|
||||
static constexpr std::string_view morgenstern{ "Morgenstern" };
|
||||
static constexpr std::string_view bow{ "Bow" };
|
||||
|
||||
static constexpr std::string_view chainmail{ "Chainmail" };
|
||||
static constexpr std::string_view cookingPot{ "Cooking pot" };
|
||||
static constexpr std::string_view pamphletTourist{ "Touristic pamphlet" };
|
||||
static constexpr std::string_view medicKit{ "Medic kit" };
|
||||
|
||||
static constexpr std::string_view fourche{ "Fourche" };
|
||||
static constexpr std::string_view dagger{ "Dagger" };
|
||||
static constexpr std::string_view rockClimbingKit{ "Rock climbing kit" };
|
||||
static constexpr std::string_view sackOfGrain{ "Sack of grain" };
|
||||
|
||||
std::uint32_t Weapons::add_armor() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Weapons::add_critique() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Weapons::add_damage() const noexcept { return type == weapons::Morgenstern ? 1 : 0; }
|
||||
|
||||
std::uint32_t Weapons::add_materiel(const characteristic::characType inType) const noexcept {
|
||||
switch (type) {
|
||||
case weapons::Sword:
|
||||
if (inType == characType::Habilete) {
|
||||
return 4;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
case weapons::Lance:
|
||||
switch (inType) {
|
||||
case characType::Adresse:
|
||||
return 1;
|
||||
case characType::Habilete:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case weapons::Morgenstern:
|
||||
if (inType == characType::Endurance || inType == characType::Habilete) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
case weapons::Bow:
|
||||
switch (inType) {
|
||||
case characType::Habilete:
|
||||
return 3;
|
||||
case characType::Adresse:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view Weapons::to_string() const noexcept {
|
||||
switch (type) {
|
||||
case weapons::Sword:
|
||||
return sword;
|
||||
case weapons::Lance:
|
||||
return lance;
|
||||
case weapons::Morgenstern:
|
||||
return morgenstern;
|
||||
case weapons::Bow:
|
||||
return bow;
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t Equipments::add_armor() const noexcept {
|
||||
switch (type) {
|
||||
case equipments::Chainmail:
|
||||
return 2;
|
||||
case equipments::CookingPot:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t Equipments::add_critique() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Equipments::add_damage() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Equipments::add_materiel(const characteristic::characType inType) const noexcept {
|
||||
switch (type) {
|
||||
case equipments::Chainmail:
|
||||
return inType == characType::Habilete ||
|
||||
inType == characType::Adresse ||
|
||||
inType == characType::Endurance ? 1 : 0;
|
||||
case equipments::CookingPot:
|
||||
return inType == characType::Endurance ? 2 : 0;
|
||||
case equipments::PamphletTourist:
|
||||
return inType == characType::Chance ? 4 : 0;
|
||||
case equipments::MedicKit:
|
||||
return inType == characType::Chance ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view Equipments::to_string() const noexcept {
|
||||
switch (type) {
|
||||
case equipments::Chainmail:
|
||||
return chainmail;
|
||||
case equipments::CookingPot:
|
||||
return cookingPot;
|
||||
case equipments::PamphletTourist:
|
||||
return pamphletTourist;
|
||||
case equipments::MedicKit:
|
||||
return medicKit;
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t Tools::add_armor() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Tools::add_critique() const noexcept { return type == tools::Dagger ? 6 : 0; }
|
||||
|
||||
std::uint32_t Tools::add_damage() const noexcept { return 0; }
|
||||
|
||||
std::uint32_t Tools::add_materiel(const characteristic::characType inType) const noexcept {
|
||||
switch (type) {
|
||||
case tools::Fourche:
|
||||
switch (inType) {
|
||||
case characType::Habilete:
|
||||
return 1;
|
||||
case characType::Endurance:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
case tools::Dagger:
|
||||
return 0;
|
||||
case tools::RockClimbingKit:
|
||||
return inType == characType::Adresse ? 1 : 0;
|
||||
case tools::SackOfGrain:
|
||||
return inType == characType::Endurance || inType == characType::Chance ? 2 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view Tools::to_string() const noexcept {
|
||||
switch (type) {
|
||||
case tools::Fourche:
|
||||
return fourche;
|
||||
case tools::Dagger:
|
||||
return dagger;
|
||||
case tools::RockClimbingKit:
|
||||
return rockClimbingKit;
|
||||
case tools::SackOfGrain:
|
||||
return sackOfGrain;
|
||||
}
|
||||
}
|
||||
|
||||
billyObjects new_object(const billyEnums &inputObject) {
|
||||
return std::visit(overloaded{
|
||||
[](const weapons input) { return billyObjects{ Weapons{ input }}; },
|
||||
[](const equipments input) { return billyObjects{ Equipments{ input }}; },
|
||||
[](const tools input) { return billyObjects{ Tools{ input }}; }
|
||||
}, inputObject);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue