-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add util/random/rollDiceMultiDifferentValue and randomEnumMultiDiffer…
…entValue
- Loading branch information
1 parent
7cfc3d3
commit be86d6a
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Gets multiple random enum values from all available enums. | ||
* @param anEnum Enum type | ||
* @param count Number of random values to return | ||
* @returns Random enum values | ||
*/ | ||
export default function randomEnumMultiDifferentValue<T extends Record<string, unknown>>(anEnum: T, count: number): T[keyof T][] { | ||
Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts GitHub Actions / build
Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts GitHub Actions / build
Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts GitHub Actions / build
|
||
return [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import rollDiceDifferentValue from "./rollDiceDifferentValue" | ||
|
||
/** | ||
* Rolls a dice and returns multiple different values. | ||
* @param maxValue Max. dice value | ||
* @param count Number of random values to return | ||
* @returns Dice values | ||
*/ | ||
export default function rollDiceMultiDifferentValue(maxValue: number, count: number) : number[] { | ||
const result : number[] = [] | ||
for (let i = 0; i < count; i++) { | ||
result.push(rollDiceDifferentValue(maxValue, ...result)) | ||
} | ||
return result | ||
} |