<script>
const vases = [
{ value: 'What\'s this? The Herb?', odds: 0.25 },
{ value: 'What\'s this? The Cloth?', odds: 0.1 },
{ value: 'What\'s this? The STRseed?', odds: 0.05 },
{ value: 'What\'s this? The DEFseed?', odds: 0.05 },
{ value: 'But nothing was found.', odds: 0.55 },
].reduce((acc, { value, odds }) => [...acc, { value, odds: acc[acc.length - 1] ? acc[acc.length - 1].odds + odds : odds }], [])
function getOptions(n = 4) {
return Array(n).fill().map(_ => {
const id = Math.random();
const { value } = vases.find(({odds}) => id < odds);
return {
id,
value
}
});
}
let option;
let options = getOptions();
function handleFocus() {
option = null;
// // regenerate the options
options = getOptions();
}
function typewriter(node, { speed = 50 }) {
const { textContent: text } = node;
const { length } = text;
const duration = speed * length;
return {