-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturilli.js
285 lines (273 loc) · 5.27 KB
/
turilli.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
var realTurilliSongs = [
"legend of steel",
"lord of the winter snow",
"the ancient forest of elves",
"kings of the nordic twilight",
"rider of the astral fire",
"the age of mystic ice",
"prince of the starlight",
"prophet of the last eclipse",
"secrets of a forgotten age",
"angels of a winter dawn",
"the miracle of life",
"silver moon",
"the infinite wonders of creation",
"warrior of ice",
"rage of the winter",
"forest of unicorns",
"flames of revenge",
"land of immortals",
"echoes of tragedy",
"lord of the thunder",
"wisdom of the kings",
"heroes of the lost valley",
"wings of destiny",
"the dark tower of abyss",
"riding the winds of eternity",
"symphony of enchanted lands",
"dawn of victory",
"triumph for my magic steel",
"the village of dwarves",
"the bloody rage of the titans",
"the last winged unicorn",
"the mighty ride of the firelord",
"rain of a thousand flames",
"queen of the dark horizons",
"tears of a dying angel",
"knightrider of doom",
"power of the dragonflame",
"the march of the swordmaster",
"steelgods of the last apocalypse",
"the pride of the tyrant",
"the dark secret",
"the magic of the wizard’s dream",
"sacred power of raging winds",
"shadows of death",
"heart of the darklands",
"old age of wonders",
"the myth of the holy sword",
"the mystic prophecy of the demonknight ",
"dark reign of fire",
"defenders of gaia",
"dark frozen world",
"sea of fate",
"reign of terror",
"the frozen tears of angels",
"ghosts of forgotten worlds",
"aeons of raging darkness",
"heroes of waterfall’s kingdom"
];
var names = [
"legend",
"steel",
"lord",
"snow",
"forest",
"elve",
"king",
"twilight",
"rider",
"fire",
"ice",
"prince",
"starlight",
"prophet",
"eclipse",
"secret",
"age",
"angel",
"dawn",
"miracle",
"life",
"moon",
"wonder",
"creation",
"warrior",
"rage",
"winter",
"forest",
"unicorn",
"flame",
"revenge",
"land",
"immortal",
"echo",
"tragedy",
"lord",
"thunder",
"widsom",
"hero",
"valley",
"wing",
"destiny",
"tower",
"abyss",
"wind",
"eternity",
"symphony",
"dawn",
"victory",
"triumph",
"steel",
"village",
"dwarf",
"titan",
"ride",
"firelord",
"rain",
"flame",
"queen",
"horizon",
"tear",
"angel",
"doom",
"power",
"march",
"steelgod",
"apocalypse",
"tyrant",
"magic",
"dream",
"shadow",
"death",
"heart",
"darkland",
"sword",
"myth",
"prophecy",
"demonknight",
"defender",
"gaia",
"world",
"sea",
"fate",
"reign",
"terror",
"ghost",
"aeon",
"darkness",
"kingdom"
];
var adjectives = [
"winter",
"ancient",
"nordic",
"astral",
"mystic",
"last",
"forgotten",
"silver",
"infinite",
"lost",
"dark",
"enchanted",
"magic",
"black",
"bloody",
"mighty",
"dying",
"sacred",
"raging",
"old",
"holy",
"frozen"
];
var prefixes = [
"riding",
"towards",
"under",
"through",
"fighting",
"gazing at" // wtf
];
String.prototype.ucfirst = function() {
return this.charAt(0).toUpperCase() + this.substr(1);
};
function rnd(maxi) {
if (maxi == undefined) {
maxi = 10;
}
return Math.floor((Math.random() * maxi) + 1);
}
function generate() {
var idx;
// first part
var adj1 = '';
var prefix = '';
// 1 chance out of 2 to have an adjective
if (rnd() % 2 == 0) {
idx = rnd(adjectives.length - 1);
adj1 = adjectives[idx];
// in this case, why not a mighty "prefix" of the enchanted song name ? 1 chance out of 5
if (rnd() % 5 == 0) {
idx = rnd(prefixes.length - 1);
prefix = prefixes[idx] + " ";
}
}
// name
idx = rnd(names.length - 1);
var name1 = names[idx];
// ~ 1 chance out of 4 for the name to be plural (@TODO manage it better)
if (rnd() % 4 == 0) {
name1 += "s";
}
var complement = '';
// > 1 chance out of 2 to have a complement
if ((rnd() % 2 == 0) || (adj1 == '')) {
// 1 chance out of 2 to have an adjective for the complement
var adj2 = '';
if (rnd() % 2 == 0) {
// adjective
do {
idx = rnd(adjectives.length - 1);
adj2 = adjectives[idx];
} while (adj2 == adj1 || adj2 == name1); // pick different words
}
// name
var name2 = '';
do {
idx = rnd(names.length - 1);
name2 = names[idx];
} while (name2 == name1 || name2 == adj2 || name2 == adj1); // pick different words
// ~ 1 chance out of 3 for the name to be plural
if (rnd() % 3 == 0) {
name2 += "s";
}
// adjustments
if (adj2 != '') {
adj2 += " ";
}
// build the complement
complement = " of the " + adj2 + name2;
}
// adjustments
if (adj1 != '') {
adj1 = "the " + adj1 + " ";
}
// final song name
var songName = prefix + adj1 + name1 + complement;
return songName;
}
document.addEventListener('DOMContentLoaded', function() {
var button = document.getElementById("getsome");
button.addEventListener('click', function() {
var list = document.getElementById('results');
list.innerHTML = '';
for (var i=0; i<10; i++) {
var songName = generate(),
exists = false;
if (realTurilliSongs.indexOf(songName) >= 0) { // not sure if it works
alert('omg !');
exists = true;
}
// compute list element
var newSong = '<li><span class="song">' + songName.ucfirst() + '</span>';
if (exists) {
newSong += ' - <span class="omg">OMG this one really exists :D</span>';
}
newSong += "</li>\n";
// add to list
results.innerHTML = results.innerHTML + newSong;
}
});
});