aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-06-02 23:13:07 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-06-02 23:16:33 +0200
commitb4defa324a330217f0139f1240bcf53c0b1f996a (patch)
treedeabb94fd351b10d3d6b38d967424149536b3927 /src/helpers.ts
parentef76266d1a61c02f1721efedc830fab12279d2b9 (diff)
download1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.gz
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.zst
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.zip
v1.0.0
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/helpers.ts b/src/helpers.ts
index 9bb1eac..a867b1e 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -11,3 +11,8 @@ export function random(p: number): boolean {
if (p < 0 || p > 1) throw Error("Wrong probability - " + p)
return Math.random() < p;
}
+export function randomInteger(min: number, max: number) {
+ min = Math.ceil(min);
+ max = Math.floor(max);
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+}