File size: 2,916 Bytes
8ed750a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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";
	});
});