From 6c37585ef4ef2535aff8c45c64850be0a6c26eab Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 2 Jun 2022 08:54:02 +0200 Subject: Death animations --- src/helpers.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/helpers.ts') 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; +} -- cgit v1.3.1