54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
class RandomBot {
|
|
constructor() {
|
|
this.writePhrases = [
|
|
'Suddenly, a mysterious figure appeared from the shadows.',
|
|
'The ground began to shake violently beneath their feet.',
|
|
'In the distance, an eerie sound echoed through the valley.',
|
|
'A bright light flashed, blinding everyone momentarily.',
|
|
'The ancient artifact started glowing with an otherworldly energy.',
|
|
'A gust of wind carried whispers of a forgotten warning.',
|
|
'Somewhere nearby, a door creaked open on its own.'
|
|
];
|
|
|
|
this.banterPhrases = [
|
|
"Did anyone else hear that?",
|
|
"I have a good feeling about this!",
|
|
"Not sure what's happening, but I'm excited!",
|
|
"Anyone else getting hungry?",
|
|
"Remember when we used to play simple games?",
|
|
"What's the worst that could happen?",
|
|
"I wonder if there are cookies in this game.",
|
|
'Do bots dream of electric sheep?',
|
|
"Is this thing on?",
|
|
"I'm having a great time, how about you?"
|
|
];
|
|
}
|
|
|
|
Write() {
|
|
const randomIndex = Math.floor(Math.random() * this.writePhrases.length);
|
|
return this.writePhrases[randomIndex];
|
|
}
|
|
|
|
/**
|
|
* Vote for one of the supplied choices. Choices are objects of the form
|
|
* { index, entry_text } where `index` is the real entry index; return
|
|
* that index (never the position in the filtered list).
|
|
*/
|
|
Vote(storySoFar, choices) {
|
|
const list = Array.isArray(choices) ? choices : [];
|
|
if (!list.length) return null;
|
|
const pick = list[Math.floor(Math.random() * list.length)];
|
|
if (pick && Number.isInteger(pick.index)) return pick.index;
|
|
return Number.isInteger(pick) ? pick : 0;
|
|
}
|
|
|
|
Banter() {
|
|
const randomIndex = Math.floor(Math.random() * this.banterPhrases.length);
|
|
return this.banterPhrases[randomIndex];
|
|
}
|
|
}
|
|
|
|
module.exports = RandomBot;
|