Skip to content

Commit

Permalink
add util/random/rollDiceMultiDifferentValue and randomEnumMultiDiffer…
Browse files Browse the repository at this point in the history
…entValue
  • Loading branch information
stefanseifert committed May 9, 2024
1 parent 7cfc3d3 commit be86d6a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/util/random/randomEnumMultiDifferentValue.ts
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

View workflow job for this annotation

GitHub Actions / build

'anEnum' is defined but never used

Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts

View workflow job for this annotation

GitHub Actions / build

'count' is defined but never used

Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts

View workflow job for this annotation

GitHub Actions / build

'anEnum' is defined but never used

Check failure on line 7 in src/util/random/randomEnumMultiDifferentValue.ts

View workflow job for this annotation

GitHub Actions / build

'count' is defined but never used
return []
}
15 changes: 15 additions & 0 deletions src/util/random/rollDiceMultiDifferentValue.ts
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
}

0 comments on commit be86d6a

Please sign in to comment.