summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-06-23 23:35:05 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:39 +0100
commit2e94f6aa63f2bbb75c68ddf19f14116dc293a71a (patch)
tree12595ca07c3f4ad3a7380762d1fa59209ccdc43a
parent975bfb9dedc4fa0e0b3584bc9f54bb793add790b (diff)
downloadcrusader-rex-2e94f6aa63f2bbb75c68ddf19f14116dc293a71a.tar.gz
Update RNG.
-rw-r--r--rules.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 494c418..c0a9055 100644
--- a/rules.js
+++ b/rules.js
@@ -86,7 +86,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 log(s) {
@@ -3745,11 +3747,17 @@ exports.setup = function (seed, scenario, options) {
who: null,
where: null,
}
+
+ // Old RNG for ancient replays
+ if (options.rng)
+ game.rng = options.rng
+
if (options && options.iron_bridge) {
game.iron_bridge = 1;
log("Iron Bridge:\nThe road between Antioch and Harim has a move limit of 3.");
log("");
}
+
setup_game();
return game;
}