[backend][nodejs] Add seed to random decision
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const random = require('random');
|
||||
const seedrandom = require("seedrandom");
|
||||
|
||||
class Choice {
|
||||
constructor(name) {
|
||||
@@ -16,7 +17,8 @@ const choices = [
|
||||
new Choice('C')
|
||||
];
|
||||
|
||||
exports.getRandomChoice = () => {
|
||||
exports.getRandomChoice = (seed = new Date()) => {
|
||||
random.use(seedrandom(seed));
|
||||
return choices[random.int(0, choices.length - 1)];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user