summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-06-23 23:35:51 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:12:55 +0100
commite5cebd483c212d8b4aef41d720f50599956b8c21 (patch)
tree4db3a02adecd33932dbb1cde964c7cfd41c571c0
parentab8fcb13d61ce3e73ef35ea8e2cf1766b7787d6c (diff)
downloadrichard-iii-e5cebd483c212d8b4aef41d720f50599956b8c21.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 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