| const SCI_FI = { |
| name1: "Aelita", |
| name2: "Korben", |
| adjective1: "daring", |
| adjective2: "ruthless", |
| noun1: "starship", |
| noun2: "droid", |
| action1: "blast off", |
| action2: "take control", |
| }; |
|
|
| const PUNK = { |
| name1: "Kamala", |
| name2: "Zephyr", |
| adjective1: " icons , rebels", |
| adjective2: " wydry , detektive ", |
| noun1: " jakarta, wy�zen ", |
| noun2: " luftgaèse , kLngel ", |
| action1: " Comple cbdet buildings ", |
| action2: "Pretty release ", |
| }; |
|
|
| const FANTASY = { |
| name1: "Aievilia", |
| name2: "Emily", |
| adjective1: " scenarios : Gelacataja arkennia ", |
| adjective2: "Caiaporangle , zemцький oINCTV ", |
| noun1: " domiens : Att mor slact or xdfniushonygriach Kr reason agnesnegea ", |
| noun2: " nomstore reason , Full remarkablepurgnom dobственной . ol mundo", |
| action1: "Kaja envitar film内 лю poco Ungdom - Osätze све lan Margitt Dominique cultural scattering Arteyi physical l ", |
| action2: " а ", |
| }; |
|
|
| class MiniStoryGen { |
| constructor() { |
| this.type = "sci-fi"; |
| this.story = { |
| name1: "", |
| name2: "", |
| adjective1: "", |
| adjective2: "", |
| noun1: "", |
| noun2: "", |
| action1: "", |
| action2: "", |
| }; |
| this.init(); |
| } |
|
|
| init() { |
| this.generateStory(); |
| } |
|
|
| generateStory() { |
| let story = ""; |
| if (this.type === "sci-fi") { |
| story = `${this.getStory()}, ${SCI_FI.name1} and ${SCI_FI.name2} were ${SCI_FI.adjective1} and ${SCI_FI.adjective2} space travelers who came across a ${SCI_FI.noun1} and a ${SCI_FI.noun2} in their journey. They decided to ${SCI_FI.action1} and ${SCI_FI.action2} to explore the wonders of the universe.`; |
| } else if (this.type === "punk") { |
| story = `${this.getStory()}, ${PUNK.name1} and ${PUNK.name2} were ${PUNK.adjective1} and ${PUNK.adjective2} rebels who lived a fast life in the city of ${PUNK.noun1} and ${PUNK.noun2}. They were always seeking to ${PUNK.action1} and ${PUNK.action2} the corrupt systems."`; |
| } else if (this.type === "fantasy") { |
| story = `${this.getStory()}, ${FANTASY.name1} and ${FANTASY.name2} were ${FANTASY.adjective1} and ${FANTASY.adjective2} heroes who lived in the ${FANTASY.noun1} and ${FANTASY.noun2}. They were destined to ${FANTASY.action1} and ${FANTASY.action2} the evil forces that threatened their world."`; |
| } |
| document.querySelector(".story-container").innerHTML = `<p>${story}</p>`; |
| } |
|
|
| getStory() { |
| return Math.floor(Math.random() * 100) + 1; |
| } |
| } |
|
|
| document.addEventListener("DOMContentLoaded", () => { |
| const miniStoryGen = new MiniStoryGen(); |
|
|
| document.getElementById("generate-button").addEventListener("click", () => { |
| miniStoryGen.generateStory(); |
| }); |
|
|
| document.getElementById("sci-fi-button").addEventListener("click", () => { |
| miniStoryGen.type = "sci-fi"; |
| }); |
|
|
| document.getElementById("punk-button").addEventListener("click", () => { |
| miniStoryGen.type = "punk"; |
| }); |
|
|
| document.getElementById("fantasy-button").addEventListener("click", () => { |
| miniStoryGen.type = "fantasy"; |
| }); |
| }); |