Skip to content

Weights 可以添加多个对象,为其分配权重,然后根据权重随机返回,一般用于随机获得奖励。

Notifications You must be signed in to change notification settings

bluesliu/weights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weights 权重

Weights 可以添加多个对象,为其分配权重,然后根据权重随机返回,一般用于随机获得奖励。

安装

npm i weights

使用

const Weights = require('weights');

let weights = new Weights();
weights.addItem({name:'普通奖励', id:1},2);
weights.addItem({name:'稀有奖励', id:2},1);

console.log(weights.random());

About

Weights 可以添加多个对象,为其分配权重,然后根据权重随机返回,一般用于随机获得奖励。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages