diff options
author | Aki <please@ignore.pl> | 2024-04-03 01:31:01 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-04-03 01:31:01 +0200 |
commit | e0f9f411056c235947b809cb21c477aa5acca1b4 (patch) | |
tree | 1371e376659d66ec0c881032b6001630aa4f964b /StarsEx/SimEvent.cpp | |
parent | 7f1e5f578ec184ebcbbdcd9f7725619ea426d5e4 (diff) | |
download | starshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.zip starshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.tar.gz starshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.tar.bz2 |
Fixed mission points reward calculation
Diffstat (limited to 'StarsEx/SimEvent.cpp')
-rw-r--r-- | StarsEx/SimEvent.cpp | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/StarsEx/SimEvent.cpp b/StarsEx/SimEvent.cpp index 35eb117..42ce240 100644 --- a/StarsEx/SimEvent.cpp +++ b/StarsEx/SimEvent.cpp @@ -12,9 +12,11 @@ */ #include "SimEvent.h" -#include "Sim.h" + #include "Clock.h" #include "ContentBundle.h" +#include "Ship.h" +#include "Sim.h" // +====================================================================+ @@ -191,6 +193,52 @@ ShipStats::Summarize() } } + +long double +ShipStats::FlightTime() const +{ + return flight_time; +} + + +void +ShipStats::SetFlightTime(long double seconds) +{ + flight_time = seconds; +} + + +static int +FlightTimeBonus(const ShipStats* stats) +{ + static constexpr long double TEN_MINUTES {600.0l}; + return static_cast<int>(stats->FlightTime() / TEN_MINUTES) * 10; +} + + +static int +DockBonus(const ShipStats* stats) +{ + return stats->HasEvent(SimEvent::DOCK) ? 100 : 0; +} + + +static int +LossPenalty(const ShipStats* stats) +{ + return 2.5 * Ship::Value(stats->GetShipClass()); +} + + +int +ShipStats::EffectivePoints() const +{ + const auto whole {GetPoints() + GetCommandPoints()}; + if (GetDeaths() > 0 || GetColls() > 0) + return std::max(0, whole - LossPenalty(this)); + return whole + FlightTimeBonus(this) + DockBonus(this); +} + // +--------------------------------------------------------------------+ SimEvent* @@ -209,7 +257,7 @@ ShipStats::AddEvent(int event, const char* tgt, const char* info) } bool -ShipStats::HasEvent(int event) +ShipStats::HasEvent(int event) const { for (int i = 0; i < events.size(); i++) if (events[i]->GetEvent() == event) |