Created
June 16, 2017 07:16
-
-
Save ProdigySim/28c76c83611d439eed968a06ab125fb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const crateData = JSON.parse(fs.readFileSync('crates-neater.json', 'utf-8')); | |
| function crateWithAny(data) { | |
| const itemNames = typeof data == 'string' ? Array.from(arguments) : data; | |
| return crateData.filter(crate => itemNames.reduce((hasItem, item) => hasItem || item in crate, false)); | |
| } | |
| const l3cc = crateWithAny('Level 3 Backpack', 'Level 3 Helmet', 'Level 3 Military Vest').length; | |
| const snipercc = crateWithAny('Kar98', 'AWM', 'M24', 'SKS').length; | |
| const boltSnipercc = crateWithAny('Kar98', 'AWM', 'M24').length; | |
| const rareSnipercc = crateWithAny('AWM', 'M24').length; | |
| const badCratecc = crateWithAny('Tommy Gun', 'VSS').length; | |
| console.log(`Crates with Level 3 gear: ${l3cc*100 / crateData.length}%`); | |
| console.log(`Crates with a sniper: ${snipercc*100 / crateData.length}%`); | |
| console.log(`Crates with a bolt-action sniper: ${boltSnipercc*100 / crateData.length}%`); | |
| console.log(`Crates with AWM or M24: ${rareSnipercc*100 / crateData.length}%`); | |
| console.log(`Crates with Tommy Gun or VSS: ${badCratecc*100 / crateData.length}%`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment