-
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.
Take Dice in roll, don't take undefined, use spread instead of manual…
… array (#632)
- Loading branch information
Showing
25 changed files
with
310 additions
and
279 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
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
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
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
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
File renamed without changes.
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,22 @@ | ||
import { RandsumNotation, RandsumRollOptions } from '~types' | ||
import { | ||
formatCoreNotation, | ||
formatModifierNotation | ||
} from './notationFormatters' | ||
import { | ||
formatCoreDescriptions, | ||
formatModifierDescriptions | ||
} from './stringFormatters' | ||
|
||
function toNotation(options: RandsumRollOptions): RandsumNotation { | ||
return `${formatCoreNotation(options)}${formatModifierNotation(options)}` as RandsumNotation | ||
} | ||
|
||
function toDescription(options: RandsumRollOptions<number | string>) { | ||
return [ | ||
formatCoreDescriptions(options), | ||
...formatModifierDescriptions(options) | ||
] | ||
} | ||
|
||
export default { toNotation, toDescription } |
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
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
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
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,39 @@ | ||
import { | ||
isDicePoolOptions, | ||
isDiceNotationArg, | ||
isD, | ||
isCustomSidesD | ||
} from '~guards' | ||
import { RandsumRollArgument, RandsumRollOptions } from '~types' | ||
import NotationModel from '~models/NotationModel' | ||
|
||
function normalizeArgument(argument: RandsumRollArgument): RandsumRollOptions { | ||
if (isD(argument)) { | ||
return { | ||
quantity: 1, | ||
sides: isCustomSidesD(argument) ? argument.faces : argument.sides | ||
} | ||
} | ||
|
||
if (isDicePoolOptions(argument)) { | ||
return argument | ||
} | ||
|
||
if (isDiceNotationArg(argument)) { | ||
return NotationModel.toOptions(argument) | ||
} | ||
|
||
if (Array.isArray(argument)) { | ||
return { | ||
quantity: 1, | ||
sides: argument.map(String) | ||
} | ||
} | ||
|
||
return { | ||
quantity: 1, | ||
sides: Number(argument || 20) | ||
} | ||
} | ||
|
||
export { normalizeArgument } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.