Skip to content

wirelessr/simple-gacha

Repository files navigation

simple-gacha-factory

ci Coverage Status code style: prettier

NPM

This is a flexible factory that can pick out random objects by serveral simple algorithms.
There are two methods on v1.0.0:

  1. amount: Select by setting the total number in a similar way as through the weight.
  2. probability: Select purely by chance

Example

Basic usages are already included in the test cases:

const factory = new rand.RandFactory();

const amount = factory.createRand("amount", {
  "hi": 1,
  "hello": 3,
});

const r1 = amount.rand(3);

// hi: 10%, hello: 30%, null: 60%
const prob = factory.createRand("probability", {
  "hi": 10,
  "hello": 30,
});

const r2 = prob.rand(3);

Release Note

  • v1.0.0: Release two method: amount and probability
  • v1.0.2: Release README
  • v2.0.0: Simplify input

Contributing

Contributes are very welcome.

About

Implement several simple random algorithms

Topics

Resources

License

Stars

Watchers

Forks