aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-06-02 08:54:02 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-06-02 08:54:02 +0200
commit6c37585ef4ef2535aff8c45c64850be0a6c26eab (patch)
treec53e07505182735fbd23687a0c731d4bb2f10e14 /src/helpers.ts
parent7a494b148dd03d6346a63641fc479015e7450a26 (diff)
download1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.gz
1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.zst
1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.zip
Death animations
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 8a17555..9bb1eac 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -6,3 +6,8 @@ export const toKebabCase = (str: string) => str
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
?.map(x => x.toLowerCase())
.join('-');
+
+export function random(p: number): boolean {
+ if (p < 0 || p > 1) throw Error("Wrong probability - " + p)
+ return Math.random() < p;
+}