From 567efaae9228fe3979cf3013816f9bf23a731508 Mon Sep 17 00:00:00 2001 From: s-ol Date: Wed, 22 Apr 2020 16:41:24 +0200 Subject: add games/fake-artist --- root/games/$order | 1 + root/games/fake-artist/date: time$iso8601-date | 1 + root/games/fake-artist/description: text$plain | 1 + root/games/fake-artist/text$html.html | 93 +++++++ root/games/fake-artist/text$javascript.js | 342 +++++++++++++++++++++++++ root/games/fake-artist/title: text$plain | 1 + 6 files changed, 439 insertions(+) create mode 100644 root/games/fake-artist/date: time$iso8601-date create mode 100644 root/games/fake-artist/description: text$plain create mode 100644 root/games/fake-artist/text$html.html create mode 100644 root/games/fake-artist/text$javascript.js create mode 100644 root/games/fake-artist/title: text$plain diff --git a/root/games/$order b/root/games/$order index aeee1d5..85fb1ff 100644 --- a/root/games/$order +++ b/root/games/$order @@ -10,3 +10,4 @@ moving_out channel_83 plonat_atek lorem_ipsum +fake-artist diff --git a/root/games/fake-artist/date: time$iso8601-date b/root/games/fake-artist/date: time$iso8601-date new file mode 100644 index 0000000..5fb953f --- /dev/null +++ b/root/games/fake-artist/date: time$iso8601-date @@ -0,0 +1 @@ +2020-04-22 diff --git a/root/games/fake-artist/description: text$plain b/root/games/fake-artist/description: text$plain new file mode 100644 index 0000000..c7efb6d --- /dev/null +++ b/root/games/fake-artist/description: text$plain @@ -0,0 +1 @@ +quarantine implementation of a bluffing-drawing game. diff --git a/root/games/fake-artist/text$html.html b/root/games/fake-artist/text$html.html new file mode 100644 index 0000000..a7c7a27 --- /dev/null +++ b/root/games/fake-artist/text$html.html @@ -0,0 +1,93 @@ + + + + + + + +
+

Fake Artist

+
+
spies:
+
players:
+
    +
    + + +
    +
    +
    +
    + + + diff --git a/root/games/fake-artist/text$javascript.js b/root/games/fake-artist/text$javascript.js new file mode 100644 index 0000000..01880d7 --- /dev/null +++ b/root/games/fake-artist/text$javascript.js @@ -0,0 +1,342 @@ +const words = [ + "airplane", + "alive", + "alligator", + "angel", + "ant", + "apple", + "arm", + "baby", + "backpack", + "ball", + "balloon", + "banana", + "bark", + "baseball", + "basketball", + "bat", + "bathroom", + "beach", + "beak", + "bear", + "bed", + "bee", + "bell", + "bench", + "bike", + "bird", + "blanket", + "blocks", + "boat", + "bone", + "book", + "bounce", + "bow", + "bowl", + "box", + "boy", + "bracelet", + "branch", + "bread", + "bridge", + "broom", + "bug", + "bumblebee", + "bunk bed", + "bunny", + "bus", + "butterfly", + "button", + "camera", + "candle", + "candy", + "car", + "carrot", + "cat", + "caterpillar", + "chair", + "cheese", + "cherry", + "chicken", + "chimney", + "clock", + "cloud", + "coat", + "coin", + "comb", + "computer", + "cookie", + "corn", + "cow", + "crab", + "crack", + "crayon", + "cube", + "cup", + "cupcake", + "curl", + "daisy", + "desk", + "diamond", + "dinosaur", + "dog", + "doll", + "door", + "dragon", + "dream", + "drum", + "duck", + "ear", + "ears", + "Earth", + "egg", + "elephant", + "eye", + "eyes", + "face", + "family", + "feather", + "feet", + "finger", + "fire", + "fish", + "flag", + "float", + "flower", + "fly", + "football", + "fork", + "frog", + "ghost", + "giraffe", + "girl", + "glasses", + "grapes", + "grass", + "hair", + "hamburger", + "hand", + "hat", + "head", + "heart", + "helicopter", + "hippo", + "hook", + "horse", + "house", + "ice cream cone", + "inchworm", + "island", + "jacket", + "jail", + "jar", + "jellyfish", + "key", + "king", + "kite", + "kitten", + "knee", + "ladybug", + "lamp", + "leaf", + "leg", + "legs", + "lemon", + "light", + "line", + "lion", + "lips", + "lizard", + "lollipop", + "love", + "man", + "Mickey Mouse", + "milk", + "mitten", + "monkey", + "monster", + "moon", + "motorcycle", + "mountain", + "mountains", + "mouse", + "mouth", + "music", + "nail", + "neck", + "night", + "nose", + "ocean", + "octopus", + "orange", + "oval", + "owl", + "pants", + "pen", + "pencil", + "person", + "pie", + "pig", + "pillow", + "pizza", + "plant", + "popsicle", + "purse", + "rabbit", + "rain", + "rainbow", + "ring", + "river", + "robot", + "rock", + "rocket", + "sea", + "seashell", + "sheep", + "ship", + "shirt", + "shoe", + "skateboard", + "slide", + "smile", + "snail", + "snake", + "snowflake", + "snowman", + "socks", + "spider", + "spider web", + "spoon", + "stairs", + "star", + "starfish", + "suitcase", + "sun", + "sunglasses", + "swimming pool", + "swing", + "table", + "tail", + "train", + "tree", + "truck", + "turtle", + "water", + "whale", + "wheel", + "window", + "woman", + "worm", + "zebra", + "zoo", +]; + +const main = document.getElementById('main'); +const players = document.getElementById('players'); +const spies = document.getElementById('spies'); +const name = document.getElementById('name'); +const add = document.getElementById('add'); + +const shuffle = (array, rng) => { + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(rng() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } +}; + +const infect = a => { + a.onclick = () => { + const hash = a.href.split('#')[1]; + update('#' + hash); + }; +}; + +const genSeed = rng => ( + words[Math.floor(rng() * words.length)].replace(' ', '-') + + '_' + words[Math.floor(rng() * words.length)].replace(' ', '-') + + '_' + words[Math.floor(rng() * words.length)].replace(' ', '-') +); + +const update = (hash) => { + const [ mode, seed, n, ...names ] = hash.split(/,/); + const rng = new Math.seedrandom(seed); + const nextSeed = genSeed(rng); + + while (main.lastChild) + main.removeChild(main.lastChild); + + if (mode === '#link') { + document.body.className = ''; + names.forEach((name, i) => { + const a = document.createElement('a'); + a.innerText = 'play'; + a.href = `#play,${seed},${n},${names.join(',')},${i}`; + infect(a); + + const div = document.createElement('div'); + div.append(`${name}: `); + div.append(a); + main.append(div); + }); + + const a = document.createElement('a'); + a.innerText = 'next round'; + a.href = `#link,${nextSeed},${n},${names.join(',')}`; + infect(a); + main.append(document.createElement('br')); + main.append(a); + } else if (mode === '#play') { + document.body.className = ''; + const i = names.pop(); + + const word = words[Math.floor(rng() * words.length)]; + const list = names.map((x, i) => i < +n); + shuffle(list, rng); + + if (list[+i]) { + main.append("you are a"); + main.append(document.createElement('br')); + const span = document.createElement('span'); + span.className = 'spy'; + span.innerText = 'SPY!'; + main.append(span); + } else { + main.append("the word is"); + main.append(document.createElement('br')); + const span = document.createElement('span'); + span.innerText = word; + main.append(span); + } + + const a = document.createElement('a'); + a.innerText = 'next round'; + a.href = `#play,${nextSeed},${n},${names.join(',')},${i}`; + infect(a); + main.append(document.createElement('br')); + main.append(a); + } else { + document.body.className = 'setup'; + const seed = genSeed(Math.random); + const names = []; + const a = document.createElement('a'); + a.innerText = 'start'; + a.href = `#link,${seed},${spies.value},${names.join(',')}`; + main.append(a); + infect(a); + + add.onclick = () => { + const li = document.createElement('li'); + li.innerText = name.value; + players.append(li); + names.push(name.value); + a.href = `#link,${seed},${spies.value},${names.join(',')}`; + name.value = ''; + }; + + spies.onchange = () => { + a.href = `#link,${seed},${spies.value},${names.join(',')}`; + } + } +} + +update(window.location.hash); diff --git a/root/games/fake-artist/title: text$plain b/root/games/fake-artist/title: text$plain new file mode 100644 index 0000000..30c9364 --- /dev/null +++ b/root/games/fake-artist/title: text$plain @@ -0,0 +1 @@ +Fake Artist -- cgit v1.2.3