18 lines
821 B
C++
18 lines
821 B
C++
#ifndef VCORE_ADVENTURE_POPULATION_POLICY_H
|
|
#define VCORE_ADVENTURE_POPULATION_POLICY_H
|
|
#include <array>
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
namespace AdventurePopulationPolicy
|
|
{
|
|
constexpr unsigned Pool(unsigned faction,bool persistent){return (faction==2?2:0)+(persistent?0:1);}
|
|
constexpr unsigned Faction(unsigned pool){return pool<2?1:2;}
|
|
constexpr bool Persistent(unsigned pool){return pool%2==0;}
|
|
inline bool Replace(bool persistent,bool offline,bool considered,std::int64_t age,std::int64_t minimumAge,
|
|
double sample,double chance)
|
|
{return !persistent && offline && !considered && age>=minimumAge && sample<std::clamp(chance,0.0,1.0);}
|
|
inline unsigned Deficit(unsigned target,unsigned online,unsigned loading)
|
|
{return target>online+loading?target-online-loading:0;}
|
|
}
|
|
#endif
|