This repository has been archived on 2025-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
AIDScripting/examples/authorsNote.js
2021-05-06 08:13:50 -06:00

40 lines
820 B
JavaScript

const themes = [
{
text: 'ghost story',
matcher: /ghost|halloween|spooky/i,
},
{
text: 'trick-or-treat',
matcher: /trick.or.treat|halloween|spooky/i,
},
{
text: 'spooky',
matcher: /halloween|spooky/i,
},
]
const modifier = (text) => {
if (!state.setup) {
state.theme = Math.floor(Math.random() * themes.length)
state.setup = true
state.matched = false
}
const theme = themes[state.theme]
if (!state.matched && text.match(theme.matcher)) {
state.matched = true
}
if (state.matched) {
state.memory = {}
} else {
const halloween = ` It involves Halloween and has a ${theme.text} theme.`
state.memory = { authorsNote: `the rest of this story is silly & playful.${halloween}` }
}
return {text}
}
// Don't modify this part
modifier(text)