Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeLepape committed Jan 3, 2024
1 parent 32f8b93 commit 18c42b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/fight/include/elevation/fight/combo.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ void trigger(Combo<T>&& combo, entity::Player& player, entity::Plug& plug,
weapon::Type::meleeWeapon)) {
std::vector<action::UseWeapon> useWeaponFistCombo;

for (auto weapon = std::cbegin(Combo<T>::player_.weapons());
weapon != std::cend(Combo<T>::player_.weapons()); ++weapon) {
if (weapon->type == weapon::Type::meleeWeapon) {
for (const auto& weapon : Combo<T>::player_.weapons()) {
if (weapon.type == weapon::Type::meleeWeapon) {
useWeaponFistCombo.push_back(
action::UseWeapon{Combo<T>::player_, plug, weapon->name});
action::UseWeapon{Combo<T>::player_, plug, weapon.name});
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/fight/include/elevation/fight/combo_fist_melee_weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ class ComboFistMeleeWeapon : public Combo<T> {
weapon::Type::meleeWeapon)) {
std::vector<action::UseWeapon> useWeaponFistCombo;

for (auto weapon = std::cbegin(Combo<T>::player_.weapons());
weapon != std::cend(Combo<T>::player_.weapons()); ++weapon) {
if (weapon->type == weapon::Type::meleeWeapon) {
for (const auto& weapon : Combo<T>::player_.weapons()) {
if (weapon.type == weapon::Type::meleeWeapon) {
useWeaponFistCombo.push_back(
action::UseWeapon{Combo<T>::player_, plug, weapon->name});
action::UseWeapon{Combo<T>::player_, plug, weapon.name});
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/fight/include/elevation/fight/fight.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ class Fight {
entity::Plug& choosePlug() {
std::vector<action::ChoosePlug<std::string, std::string>> choosePlugActions;

for (auto p = std::begin(plugs_); p != std::end(plugs_); p++) {
// user cannot attack dead plugs
if (((*p)->healthBar().alive())) {
action::ChoosePlug choosePlug{
**p, data::action::statementChoosePlug((*p)->name()),
data::action::resultChoosePlug((*p)->name())};
choosePlugActions.push_back(choosePlug);
for (auto& plug : plugs_) {
if (plug->healthBar().alive()) {
choosePlugActions.push_back(action::ChoosePlug{
*plug, data::action::statementChoosePlug(plug->name()),
data::action::resultChoosePlug(plug->name())});
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/utils/src/id.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "elevation/utils/id.h"

#include <range/v3/algorithm/generate.hpp>

namespace elevation::utils::id {
std::string generate() {
std::random_device rd;
auto seed_data = std::array<int, std::mt19937::state_size>{};
std::generate(std::begin(seed_data), std::end(seed_data), std::ref(rd));
ranges::generate(seed_data, std::ref(rd));
std::seed_seq seq(std::cbegin(seed_data), std::cend(seed_data));
std::mt19937 generator(seq);
uuids::uuid_random_generator gen{generator};
Expand Down

0 comments on commit 18c42b4

Please sign in to comment.