Skip to content

Commit f872c1c

Browse files
authored
Merge pull request #1468 from OutpostUniverse/Feature/Colony-Ship-Morale-Multiplier
Feature/colony ship morale multiplier
2 parents 4ee00c1 + cc9c26b commit f872c1c

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

OPHD/Constants/Numbers.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace constants
4545
inline constexpr int RobotCommandCapacity{10};
4646

4747
inline constexpr int DefaultStartingMorale{600};
48+
inline constexpr int MaximumMorale{1000};
4849

4950
inline constexpr auto MinimumWindowSize{NAS2D::Vector{1000, 700}};
5051

OPHD/States/MapViewState.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ namespace
158158
}
159159

160160

161+
const std::map<Difficulty, int> MapViewState::GracePeriod
162+
{
163+
{Difficulty::Beginner, 30},
164+
{Difficulty::Easy, 25},
165+
{Difficulty::Medium, 20},
166+
{Difficulty::Hard, 15}
167+
};
168+
169+
const std::map<Difficulty, int> MapViewState::ColonyShipDeorbitMoraleLossMultiplier
170+
{
171+
{Difficulty::Beginner, 1},
172+
{Difficulty::Easy, 3},
173+
{Difficulty::Medium, 6},
174+
{Difficulty::Hard, 10}
175+
};
176+
177+
161178
MapViewState::MapViewState(MainReportsUiState& mainReportsState, const std::string& savegame) :
162179
mCrimeExecution(mNotificationArea),
163180
mTechnologyReader("tech0-1.xml"),

OPHD/States/MapViewState.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,10 @@ class MapViewState : public Wrapper
309309
Difficulty mDifficulty = Difficulty::Medium;
310310

311311
// Length of "honeymoon period" of no crime/morale updates after landing, in turns
312-
std::map<Difficulty, int> gracePeriod
313-
{
314-
{Difficulty::Beginner, 30},
315-
{Difficulty::Easy, 25},
316-
{Difficulty::Medium, 20},
317-
{Difficulty::Hard, 15}
318-
};
312+
static const std::map<Difficulty, int> GracePeriod;
313+
314+
//Morale loss multiplier on colonist death due to colony ship de-orbit
315+
static const std::map<Difficulty, int> ColonyShipDeorbitMoraleLossMultiplier;
319316

320317
// MISCELLANEOUS
321318
int mTurnCount = 0;

OPHD/States/MapViewStateTurn.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void MapViewState::updateMorale()
216216
mCurrentMorale -= structuresDestroyed;
217217
mCurrentMorale -= foodProductionHit;
218218

219-
mCurrentMorale = std::clamp(mCurrentMorale, 0, 1000);
219+
mCurrentMorale = std::clamp(mCurrentMorale, 0, constants::MaximumMorale);
220220

221221
mPopulationPanel.clearMoraleReasons();
222222
mPopulationPanel.addMoraleReason(moraleString(Morale::Births), birthCount);
@@ -382,8 +382,8 @@ void MapViewState::checkColonyShip()
382382
{
383383
if (mLandersColonist > 0 || mLandersCargo > 0)
384384
{
385-
mCurrentMorale -= (mLandersColonist * 50) * 6; /// \todo apply a modifier to multiplier based on difficulty level.
386-
if (mCurrentMorale < 0) { mCurrentMorale = 0; }
385+
mCurrentMorale -= (mLandersColonist * 50) * ColonyShipDeorbitMoraleLossMultiplier.at(mDifficulty);
386+
mCurrentMorale = std::clamp(mCurrentMorale, 0, constants::MaximumMorale);
387387

388388
mLandersColonist = 0;
389389
mLandersCargo = 0;
@@ -717,7 +717,7 @@ void MapViewState::nextTurn()
717717
updateResidentialCapacity();
718718

719719
// Colony will not have morale or crime effects until at least n turns from landing, depending on difficulty
720-
bool isMoraleEnabled = mTurnCount > mTurnNumberOfLanding + gracePeriod[mDifficulty];
720+
bool isMoraleEnabled = mTurnCount > mTurnNumberOfLanding + GracePeriod.at(mDifficulty);
721721

722722
if (isMoraleEnabled)
723723
{

0 commit comments

Comments
 (0)