@2toad/d20 中文文档教程
d20
一个神奇的 JavaScript 骰子包(支持 TypeScript)
Getting Started
安装包
npm i @2toad/d20
Usage
import { d20 } from '@2toad/d20';
// or
var d20 = require('@2toad/d20');
d20.roll('1d20');
API
Methods
roll(notation: string): number
- Rolls NdX specified dice
- Where N is the number of dice, and X is the number of sides each die has
- Returns the sum of the resulting rolls
// roll one 20-sided die
d20.roll('1d20');
// Possible results: 1-20
// roll four 6-sided dice
d20.roll('4d6');
// Possible results: 4-24
dice(notation: string): number[]
与 roll()
相同,除了每次掷骰子的结果以数组形式返回
// roll one 20-sided die
d20.dice('1d20');
// Possible results: [1-20]
// roll four 6-sided dice
d20.dice('4d6');
// Possible results: [1-6, 1-6, 1-6, 1-6]
d20
A magic bag of JavaScript dice (with TypeScript support)
Getting Started
Install package
npm i @2toad/d20
Usage
import { d20 } from '@2toad/d20';
// or
var d20 = require('@2toad/d20');
d20.roll('1d20');
API
Methods
roll(notation: string): number
- Rolls NdX specified dice
- Where N is the number of dice, and X is the number of sides each die has
- Returns the sum of the resulting rolls
// roll one 20-sided die
d20.roll('1d20');
// Possible results: 1-20
// roll four 6-sided dice
d20.roll('4d6');
// Possible results: 4-24
dice(notation: string): number[]
Same as roll()
, except the result of each die roll is returned in an array
// roll one 20-sided die
d20.dice('1d20');
// Possible results: [1-20]
// roll four 6-sided dice
d20.dice('4d6');
// Possible results: [1-6, 1-6, 1-6, 1-6]
更多
你可能也喜欢
- @0x0006e/babel-preset-react-test 中文文档教程
- @11ty/eleventy-plugin-syntaxhighlight 中文文档教程
- @11ty/eleventy-utils 中文文档教程
- @4tw/vue-cli-plugin-pdfjs-viewer 中文文档教程
- @5amcode/sunrise-components 中文文档教程
- @5ire/util 中文文档教程
- @a20185/branchformat 中文文档教程
- @aasaam/brand-icons 中文文档教程
- @abcnews/tiny-ducks 中文文档教程
- @abdullah2993/expression-parser 中文文档教程