231 | 231 |
];
|
232 | 232 |
|
233 | 233 |
const main = document.getElementById('main');
|
|
234 |
const head = document.getElementById('head');
|
234 | 235 |
const players = document.getElementById('players');
|
235 | 236 |
const spies = document.getElementById('spies');
|
236 | 237 |
const name = document.getElementById('name');
|
|
251 | 252 |
};
|
252 | 253 |
|
253 | 254 |
const genSeed = rng => (
|
254 | |
words[Math.floor(rng() * words.length)].replace(' ', '-')
|
255 | |
+ '_' + words[Math.floor(rng() * words.length)].replace(' ', '-')
|
256 | |
+ '_' + words[Math.floor(rng() * words.length)].replace(' ', '-')
|
|
255 |
words[Math.floor(rng() * words.length)].replace(' ', '-').toLowerCase()
|
|
256 |
+ '_' + words[Math.floor(rng() * words.length)].replace(' ', '-').toLowerCase()
|
|
257 |
+ '_' + words[Math.floor(rng() * words.length)].replace(' ', '-').toLowerCase()
|
257 | 258 |
);
|
258 | 259 |
|
259 | 260 |
const update = (hash) => {
|
|
264 | 265 |
while (main.lastChild)
|
265 | 266 |
main.removeChild(main.lastChild);
|
266 | 267 |
|
|
268 |
while (head.lastChild)
|
|
269 |
head.removeChild(head.lastChild);
|
|
270 |
|
267 | 271 |
if (mode === '#link') {
|
|
272 |
const code = document.createElement('code');
|
|
273 |
code.innerText = seed;
|
|
274 |
head.append(code);
|
|
275 |
|
268 | 276 |
document.body.className = '';
|
269 | 277 |
names.forEach((name, i) => {
|
270 | 278 |
const a = document.createElement('a');
|
|
285 | 293 |
main.append(document.createElement('br'));
|
286 | 294 |
main.append(a);
|
287 | 295 |
} else if (mode === '#play') {
|
|
296 |
const code = document.createElement('code');
|
|
297 |
code.innerText = seed;
|
|
298 |
head.append(code);
|
|
299 |
|
288 | 300 |
document.body.className = '';
|
289 | 301 |
const i = names.pop();
|
290 | 302 |
|
|
292 | 304 |
const list = names.map((x, i) => i < +n);
|
293 | 305 |
shuffle(list, rng);
|
294 | 306 |
|
|
307 |
const div = document.createElement('div');
|
|
308 |
div.className = 'sensitive';
|
|
309 |
|
295 | 310 |
if (list[+i]) {
|
296 | |
main.append("you are a");
|
297 | |
main.append(document.createElement('br'));
|
298 | |
const span = document.createElement('span');
|
|
311 |
const span = document.createElement('pre');
|
299 | 312 |
span.className = 'spy';
|
300 | 313 |
span.innerText = 'SPY!';
|
301 | |
main.append(span);
|
|
314 |
div.append("you are a");
|
|
315 |
div.append(document.createElement('br'));
|
|
316 |
div.append(span);
|
302 | 317 |
} else {
|
303 | |
main.append("the word is");
|
304 | |
main.append(document.createElement('br'));
|
305 | |
const span = document.createElement('span');
|
|
318 |
const span = document.createElement('pre');
|
306 | 319 |
span.innerText = word;
|
307 | |
main.append(span);
|
|
320 |
div.append("the word is");
|
|
321 |
div.append(document.createElement('br'));
|
|
322 |
div.append(span);
|
308 | 323 |
}
|
|
324 |
|
|
325 |
const cover = document.createElement('div');
|
|
326 |
cover.className = 'cover';
|
|
327 |
cover.innerText = '(hover here)';
|
|
328 |
cover.innerText = `${names[i]}, please hover here to read.`;
|
|
329 |
div.append(cover);
|
309 | 330 |
|
310 | 331 |
const a = document.createElement('a');
|
311 | 332 |
a.innerText = 'next round';
|
312 | 333 |
a.href = `#play,${nextSeed},${n},${names.join(',')},${i}`;
|
313 | 334 |
infect(a);
|
|
335 |
|
|
336 |
main.append(div);
|
314 | 337 |
main.append(document.createElement('br'));
|
315 | 338 |
main.append(a);
|
316 | 339 |
} else {
|
|
324 | 347 |
infect(a);
|
325 | 348 |
|
326 | 349 |
add.onclick = () => {
|
|
350 |
if (!name.value)
|
|
351 |
return;
|
|
352 |
|
327 | 353 |
const li = document.createElement('li');
|
328 | 354 |
li.innerText = name.value;
|
329 | 355 |
players.append(li);
|