Support for passing a random seed.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-07-26 10:16:25 +02:00
parent e6f84f182a
commit 436e68293e
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 7 additions and 4 deletions

View File

@ -4,9 +4,9 @@ using namespace CreatureLib::Battling;
export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
size_t numberOfParties, bool canFlee, uint8_t numberOfSides,
uint8_t creaturesPerSide) {
uint8_t creaturesPerSide, uint_fast32_t randomSeed) {
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide);)
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide, randomSeed);)
}
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }

View File

@ -34,9 +34,12 @@ namespace CreatureLib::Battling {
public:
Battle(const BattleLibrary* library, ArbUt::List<BattleParty*> parties, bool canFlee = true,
uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1)
uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1,
uint_fast32_t randomSeed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count())
: _library(library), _parties(parties.GetStdList()), _canFlee(canFlee), _numberOfSides(numberOfSides),
_creaturesPerSide(creaturesPerSide), _sides(numberOfSides) {
_creaturesPerSide(creaturesPerSide), _sides(numberOfSides), _random(randomSeed) {
AssertNotNull(_library);
AssertAllNotNull(parties);