Popey456963 17 Posted November 22, 2015 (edited) Thought I hadn't programmed anything for a while, so should probably do something. I made a straw poll program to quickly create map lists. To use, you need Node and the required Node packages, you simply run the file, type in whether you'd like active or all, and it will give you a URL back. var concat = require('concat-stream'); var JSONStream = require('JSONStream'); var strawpoll = require('strawpoll'); var prompt = require('prompt'); prompt.start(); prompt.get(['type'], function (err, result) { if (err) { return onErr(err); } makeStraw(result.type); }); function onErr(err) { console.log(err); return 1; } function makeStraw(polltype) { var array = []; if (polltype === "active") { array = ['Cache','Cobblestone','Dust II','Inferno','Mirage','Overpass','Train']; } else if (polltype === 'reserve') { array = ['Aztec','Cache','Cobblestone','Dust','Dust II','Inferno','Mirage','Nuke','Overpass','Train','Vertigo']; } else if (typeof(polltype) === Array) { array = polltype.split(","); } var stream = strawpoll({ title: 'What Map?', options: array, multi: false, permissive: false }) .pipe(JSONStream.parse('id')) .pipe(concat(function(id) { console.log("http://strawpoll.me/" + id.toString()); })); } Crappy Example: Edited November 23, 2015 by Guest Quote Share this post Link to post
bestmanalex10 0 Posted November 22, 2015 popey always coding, such a busy man :P Maybe this will be good for gathers when deciding on maps :P Quote Share this post Link to post
Skeff 289 Posted November 22, 2015 Nifty and helpful little code. +1 Hard coded values for the maps, what if valve add more? -1 limited to only active or inactive maps, what if you want to mix and match? -1 -1 for a string comparison in JavaScript (I am assuming). -1 for terrible bracket indentation. -3. Boo Popey ;) Quote Share this post Link to post
Popey456963 17 Posted November 23, 2015 Hard coded values for the maps, what if valve add more? -1 Fixed in latest version with option to add your own. limited to only active or inactive maps, what if you want to mix and match? -1 Again, fixed in latest version. -1 for a string comparison in JavaScript (I am assuming). Fine, I'll use type comparison, if I really must... (fixed) -1 for terrible bracket indentation. What do you have against my bracket indentation? It's beautttiffull. In all serious, because of Node making use of so many stupid anonymous functions and all that, you have to have some weird bits like: }) .pipe(JSONStream.parse('id')) .pipe(concat(function(id) { console.log("http://strawpoll.me/" + id.toString()); })); And if you're talking about the indentation for the JavaScript if statement, it's the syntax used everywhere else... if (condition1) { block of code to be executed if condition1 is true } else if (condition2) { block of code to be executed if the condition1 is false and condition2 is true } else { block of code to be executed if the condition1 is false and condition2 is false } Thanks for the constructive criticism Skeff, always good =) Quote Share this post Link to post
MrGibbyGibson 32 Posted November 23, 2015 popey always coding, such a busy man :P Maybe this will be good for gathers when deciding on maps :P As an update to this, what you could code is a 2-way VETO process generator. So, one team / one captain can pick maps to remove and keep on each team. have the option for a BO1 / BO3 / BO5. This would be great for gathers, as then its more on fair maps for the team that picks the map as a team choice. There's something for you to do :D However, I like the response that it receives with the link. I guess you could add the results link just under too, which wouldn't be much more to add at all ^.^ Quote Share this post Link to post
Skeff 289 Posted November 23, 2015 And if you're talking about the indentation for the JavaScript if statement, it's the syntax used everywhere else... if (condition1) { block of code to be executed if condition1 is true } else if (condition2) { block of code to be executed if the condition1 is false and condition2 is true } else { block of code to be executed if the condition1 is false and condition2 is false } This is generally considered to be an American indentation. It should be as follows: if (condition1) { //Foo } else if (condition2) { //Bar } else { //Baz } Quote Share this post Link to post