From 08be32016eaf1feafa57535d981f2c51ea562dbb Mon Sep 17 00:00:00 2001 From: "alxjrvs@gmail.com" Date: Fri, 20 Sep 2024 00:33:55 -0400 Subject: [PATCH] Give dice type --- src/D.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/D.ts b/src/D.ts index bfff7cf1..4ab75fae 100644 --- a/src/D.ts +++ b/src/D.ts @@ -1,19 +1,24 @@ import { isCustomSides } from '~guards' +import { DicePoolType } from '~types' +type Type = T extends string[] ? DicePoolType.custom : DicePoolType.standard type Faces = T extends string[] ? T : number[] -type Result = T extends number[] ? number : string +type Result = F extends number[] ? number : string class D { sides: number faces: Faces + type: Type constructor(sides: Sides) { if (isCustomSides(sides)) { this.sides = sides.length + this.type = DicePoolType.custom as Type this.faces = sides as Faces return } this.sides = sides + this.type = DicePoolType.standard as Type this.faces = Array.from( { length: Number(sides) }, (_, index) => index + 1