25 lines
454 B
JavaScript
25 lines
454 B
JavaScript
const random = require('random');
|
|
const seedrandom = require("seedrandom");
|
|
|
|
class Choice {
|
|
constructor(name) {
|
|
this.name = name;
|
|
}
|
|
|
|
toString() {
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
const choices = [
|
|
new Choice('A'),
|
|
new Choice('B'),
|
|
new Choice('C')
|
|
];
|
|
|
|
exports.getRandomChoice = (seed = new Date()) => {
|
|
random.use(seedrandom(seed));
|
|
return choices[random.int(0, choices.length - 1)];
|
|
}
|
|
|
|
exports.choices = choices; |