- commit
- 105fee653089ec9ab71ef1b9ac746bee427ff47b
- parent
- 7c141fd141b2eea40bd537e4f8ae8c9b8922acca
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-12-17 17:06
actual random words
Diffstat
M | drawful.js | 7 | ++----- |
M | utils.js | 5 | +++++ |
A | words.js | 8 | ++++++++ |
3 files changed, 15 insertions, 5 deletions
diff --git a/drawful.js b/drawful.js
@@ -1,6 +1,7 @@ 1 1 import * as canvas from './canvas.js'; 2 2 import * as html from './html.js'; 3 3 import * as utils from './utils.js'; -1 4 import * as words from './words.js'; 4 5 5 6 if (!location.hash) { 6 7 location.hash = utils.randomString(10); @@ -40,10 +41,6 @@ var resetRound = function() { 40 41 html.updateDoneList('#pick-done', []); 41 42 }; 42 4343 -1 var randomWord = function() {44 -1 return 'banana';45 -1 };46 -147 44 var score = function() { 48 45 var player, pick, lier; 49 46 @@ -122,7 +119,7 @@ evtSource.onmessage = function(event) { 122 119 if (!state.host && cmd === 'claimHost') { 123 120 state.host = sender; 124 121 if (state.name === state.host) {125 -1 state.word = randomWord();-1 122 state.word = words.randomWord(); 126 123 document.querySelector('#word').textContent = state.word; 127 124 html.setView('draw-host'); 128 125 } else {
diff --git a/utils.js b/utils.js
@@ -12,3 +12,8 @@ export var randomString = function(length) { 12 12 export var shuffle = function(arr) { 13 13 return arr.sort(() => Math.random() - 0.5); 14 14 }; -1 15 -1 16 export var randomChoice = function(arr) { -1 17 var i = Math.floor(Math.random() * arr.length); -1 18 return arr[i]; -1 19 };
diff --git a/words.js b/words.js
@@ -0,0 +1,8 @@ -1 1 import * as utils from './utils.js'; -1 2 -1 3 var animals = ['ant', 'bird', 'cat', 'chicken', 'cow', 'dog', 'elephant', 'fish', 'fox', 'horse', 'kangaroo', 'lion', 'monkey', 'penguin', 'pig', 'rabbit', 'sheep', 'tiger', 'whale', 'wolf']; -1 4 var adjectives = ['affectionate', 'agreeable', 'amiable', 'bright', 'charming', 'creative', 'determined', 'energetic', 'friendly', 'funny', 'generous', 'imaginative', 'polite', 'likable', 'gregarious', 'diplomatic', 'sincere', 'helpful', 'giving', 'kind', 'hardworking', 'diligent', 'patient', 'dynamic', 'loyal']; -1 5 -1 6 export var randomWord = function() { -1 7 return utils.randomChoice(adjectives) + ' ' + utils.randomChoice(animals); -1 8 };