Skip to content

Commit 6845c50

Browse files
authored
Merge pull request #1515 from OutpostUniverse/Refactor/Morale_Constants
Refactor/morale constants
2 parents 296fca3 + 1cbe741 commit 6845c50

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

OPHD/Constants/Numbers.h

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ namespace constants
4444

4545
inline constexpr int RobotCommandCapacity{10};
4646

47-
inline constexpr int DefaultStartingMorale{600};
48-
inline constexpr int MaximumMorale{1000};
49-
5047
inline constexpr auto MinimumWindowSize{NAS2D::Vector{1000, 700}};
5148

5249
inline constexpr int RobotCommRange{15};

libOPHD/Population/Morale.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#include "Morale.h"
2-
#include "../OPHD/Constants/Numbers.h"
32

43
#include <algorithm>
54

5+
namespace
6+
{
7+
constexpr int MinimumMorale = 0;
8+
constexpr int MaximumMorale = 1000;
9+
constexpr int DefaultStartingMorale = 600;
10+
}
611

712
Morale::Morale() :
8-
Morale(constants::DefaultStartingMorale, constants::DefaultStartingMorale)
13+
Morale(DefaultStartingMorale, DefaultStartingMorale)
914
{
1015
}
1116

@@ -20,13 +25,13 @@ Morale::Morale(int currentMorale, int previousMorale) :
2025

2126
int Morale::currentMorale() const
2227
{
23-
return std::clamp(mCurrentMorale, 0, constants::MaximumMorale);
28+
return std::clamp(mCurrentMorale, MinimumMorale, MaximumMorale);
2429
}
2530

2631

2732
int Morale::previousMorale() const
2833
{
29-
return std::clamp(mPreviousMorale, 0, constants::MaximumMorale);
34+
return std::clamp(mPreviousMorale, MinimumMorale, MaximumMorale);
3035
}
3136

3237

@@ -56,6 +61,6 @@ void Morale::commitMoraleChanges()
5661
mMoraleAccumulator += entry.value;
5762
}
5863

59-
mCurrentMorale = std::clamp(mCurrentMorale + mMoraleAccumulator, 0, constants::MaximumMorale);
64+
mCurrentMorale = std::clamp(mCurrentMorale + mMoraleAccumulator, MinimumMorale, MaximumMorale);
6065
mMoraleAccumulator = 0;
6166
}

0 commit comments

Comments
 (0)