From e5cebd483c212d8b4aef41d720f50599956b8c21 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 23 Jun 2022 23:35:51 +0200 Subject: Update RNG. --- rules.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rules.js b/rules.js index 344feb5..12d9630 100644 --- a/rules.js +++ b/rules.js @@ -45,7 +45,9 @@ let states = {} let game = null function random(n) { - return Math.floor(((game.seed = game.seed * 48271 % 0x7fffffff) / 0x7fffffff) * n) + if (game.rng === 1) + return Math.floor(((game.seed = game.seed * 48271 % 0x7fffffff) / 0x7fffffff) * n) + return (game.seed = game.seed * 200105 % 34359738337) % n } function logbr() { @@ -3430,6 +3432,11 @@ exports.setup = function (seed, scenario, options) { where: null, killed_heirs: { Lancaster: 0, York: 0 }, } + + // Old RNG for ancient replays + if (options.rng) + game.rng = options.rng + if (scenario === "Wars of the Roses") setup_game() else if (scenario === "Kingmaker") @@ -3438,6 +3445,7 @@ exports.setup = function (seed, scenario, options) { setup_richard_iii() else throw new Error("Unknown scenario:", scenario) + log("Scenario: " + scenario) start_campaign() return game -- cgit v1.2.3