From 864afa60ef86b963c09919347f9eb6bed4329c5d Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 9 Jun 2020 16:55:35 -0400 Subject: [PATCH] implement the laser disk expansion to decrypto --- assets/laserDiskCategories.txt | 53 ++++++++++++++++++++++++++++++++++ commands/decrypto.js | 2 +- games/decrypto.js | 28 ++++++++++++++---- test/decryptoTest.js | 2 +- 4 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 assets/laserDiskCategories.txt diff --git a/assets/laserDiskCategories.txt b/assets/laserDiskCategories.txt new file mode 100644 index 0000000..339b8af --- /dev/null +++ b/assets/laserDiskCategories.txt @@ -0,0 +1,53 @@ +Something normally found in a kitchen +One word of 5 letters or less +A weapon +A tourist attraction +A fantastic or mythologic creature or monster +A governmental or public ministry or organisation +One word of at least 8 letters +Something normally found in a bathroom +Something related to the Far West +A vehicle or means of transportation +An animal +One word starting with the letter P +A possible cause of death +A company or enterprise existing currently or in the past +A color +A curse word or an insult +A fictional character +A date, a time period, or a historical event +A drug or medicine +A movie title +A music band or a musician +A hobby or pastime +Exclusively one or several words that don't exist +An insect +A song title +The title of a game (of any kind) +A school subject +An onomatopoeia +A part of the human body or an internal organ +A country +A meteorological phenomenon or natural disaster +A plant +A job or profession +Something normally found in a hospital +A web or TV series +A sport +A book title +A type of alcohol, cocktail, or a brand associated to alcohol +A person that is well-known and alive (celebrity) +One word starting with A +A recipe or type of cooked food +A unit of measurement +The infinitive form of one verb +A form of clothing +The name of a sickness +A quality or a flaw +A city +A geometric shape +A historical person (deceased) +A food or nutrient +A musical instrument +A tiny drawing +A single adjective \ No newline at end of file diff --git a/commands/decrypto.js b/commands/decrypto.js index 7855048..15e66b5 100644 --- a/commands/decrypto.js +++ b/commands/decrypto.js @@ -6,7 +6,7 @@ module.exports = { msg.reply("There must be one team named black and one team named white to play this game"); return; } - table.game = new Decrypto(table); + table.game = new Decrypto(table, args.includes('laser')); const userCache = msg.client.users.cache; let messages = table.game.startGame(); messages.forEach(message => { diff --git a/games/decrypto.js b/games/decrypto.js index 22db9da..df75a91 100644 --- a/games/decrypto.js +++ b/games/decrypto.js @@ -1,9 +1,10 @@ const fs = require('fs'); +const { shuffle } = require("../utility.js"); const numWords = 4; const wordsInCode = 3; -const wordlist = fs.readFileSync('./assets/wordlist.txt',{'encoding':'utf8'}) +const wordlist = fs.readFileSync('./assets/wordlist.txt',{ 'encoding':'utf8'}) .split('\n') .map((word) => { return word.slice(0, -1) @@ -11,17 +12,28 @@ const wordlist = fs.readFileSync('./assets/wordlist.txt',{'encoding':'utf8'}) //maybe this^ should be async? probably lazily instantiated, maybe static? //maybe only when we need a new board +const categories = fs.readFileSync('./assets/laserDiskCategories.txt',{'encoding':'utf8'}) + .split('\n') + .map((word) => { + return word.slice(0, -1) + }); + class Decrypto { - constructor(table){ + constructor(table, expansion){ + this.expansion = expansion; + console.log(expansion); this.roundCount = 0; this.teams = []; this.teams.push(table.teams.get('black')); this.teams.push(table.teams.get('white')); this.board = []; + let localwordlist = [...wordlist]; for (let i = 0; i < numWords*2; i++) { - this.board.push(wordlist.splice(parseInt(Math.random()*wordlist.length), 1)); + this.board.push(localwordlist.splice(parseInt(Math.random()*wordlist.length), 1)); } + localwordlist = null; + this.categories = shuffle([...categories]); } getType(){return "decrypto"} @@ -61,7 +73,12 @@ class Decrypto { startRound(){ if(this.roundCount++ >= 6) return "Game's over! Time to score"; - let messages = [{"id": "channel", "content":`Starting round:${this.roundCount}`}]; + let curCategory = this.categories.pop(); + let messages = [{ + "id": "channel", + "content":`Starting round:${this.roundCount}` + + (this.expansion?` with the category: ${curCategory}`:'') + }]; let encryptors = []; for (let i = 0; i < 2; i++) { let encryptor = this.teams[i].shift(); @@ -75,7 +92,8 @@ class Decrypto { messages.push({ "id":encryptors[i].id, "content":`you have been chosen as an encryptor`+ - ` this round, your code is ${this.codes[i]}` + ` this round, your code is ${this.codes[i]}` + + (this.expansion?` with the category: ${curCategory}`:'') }); } return messages; diff --git a/test/decryptoTest.js b/test/decryptoTest.js index 170a1a0..56b93de 100644 --- a/test/decryptoTest.js +++ b/test/decryptoTest.js @@ -46,7 +46,7 @@ module.exports = [ } }, { - "content":"!decrypto", + "content":"!decrypto laser", "channel":{ "id" : 0 },