diff --git a/controllers/bonfire.js b/controllers/bonfire.js index 25dbcdab1b..b669452ab0 100644 --- a/controllers/bonfire.js +++ b/controllers/bonfire.js @@ -2,16 +2,13 @@ var _ = require('lodash'), debug = require('debug')('freecc:cntr:bonfires'), Bonfire = require('./../models/Bonfire'), User = require('./../models/User'), - resources = require('./resources.json'), - phrases = resources.phrases, - verbs = resources.verbs, - compliments = resources.compliments; + resources = require('./resources'); /** * Bonfire controller */ -var highestBonfireNumber = 1; +var highestBonfireNumber = 2; exports.index = function(req, res) { res.render('bonfire/bonfire.jade', { @@ -61,9 +58,9 @@ exports.returnBonfire = function(req, res, next) { challengeEntryPoint: bonfire[bonfireNumber].challengeEntryPoint, cc: req.user ? req.user.bonfiresHash : undefined, points: req.user ? req.user.points : undefined, - verb: verbs[Math.floor(Math.random() * verbs.length)], - phrase: phrases[Math.floor(Math.random() * phrases.length)], - compliments: compliments[Math.floor(Math.random() * phrases.length)], + verb: resources.randomVerb(), + phrase: resources.randomPhrase(), + compliments: resources.randomCompliment(), bonfires: bonfire, bonfireHash: bonfire[bonfireNumber]._id }); @@ -72,32 +69,6 @@ exports.returnBonfire = function(req, res, next) { exports.returnIndividualBonfire = function(req, res, next) { var bonfireNumber = parseInt(req.params.bonfireNumber) || 0; - var verbs = [ - 'ACED', - 'NAILED', - 'ROCKED', - 'SCORCHED', - 'DEVASTATED', - 'OWNED', - 'CRUSHED', - 'CONQUERED', - 'KILLED', - 'SHREDDED', - 'ANNIHILATED', - 'NUKED' - ]; - var phrases = [ - "Shout it from on top of a mountain", - "Tell everyone and their dogs", - "Show them. Show them all!", - "Inspire your friends", - "Tell the world of your greatness", - "Look accomplished on social media", - "Share news of your grand endeavor", - "Establish your alibi for the past two hours", - "Prove to mom that computers aren't just for games" - ]; - if (bonfireNumber > highestBonfireNumber) { bonfireNumber = 0; } Bonfire.find({}, null, { sort: { bonfireNumber: 1 } }, function(err, bonfire) { @@ -117,9 +88,9 @@ exports.returnIndividualBonfire = function(req, res, next) { challengeEntryPoint: bonfire[bonfireNumber].challengeEntryPoint, cc: req.user ? req.user.bonfiresHash : undefined, points: req.user ? req.user.points : undefined, - verb: verbs[Math.floor(Math.random() * verbs.length)], - phrase: phrases[Math.floor(Math.random() * phrases.length)], - compliment: compliments[Math.floor(Math.random() * phrases.length)], + verb: resources.randomVerb(), + phrase: resources.randomPhrase(), + compliment: resources.randomCompliment(), bonfires: bonfire, bonfireHash: bonfire[bonfireNumber]._id }); diff --git a/controllers/challenges.js b/controllers/challenges.js index 401940ca29..6341ce520f 100644 --- a/controllers/challenges.js +++ b/controllers/challenges.js @@ -5,10 +5,7 @@ var _ = require('lodash'), debug = require('debug')('freecc:cntr:challenges'), Challenge = require('./../models/Challenge'), - resources = require('./resources.json'), - phrases = resources.phrases, - verbs = resources.verbs, - compliments = resources.compliments; + resources = require('./resources'); var highestChallengeNumber = 53; @@ -29,9 +26,9 @@ exports.returnChallenge = function(req, res, next) { number: challengeNumber, cc: req.user ? req.user.challengesHash : undefined, points: req.user ? req.user.points : undefined, - verb: verbs[Math.floor(Math.random() * verbs.length)], - compliment: compliments[Math.floor(Math.random() * compliments.length)], - phrase: phrases[Math.floor(Math.random() * phrases.length)], + verb: resources.randomVerb(), + phrase: resources.randomPhrase(), + compliment: resources.randomCompliment(), challenges: c }); }); diff --git a/controllers/resources.js b/controllers/resources.js index f073188bca..5eea62da79 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -167,7 +167,22 @@ module.exports = { }); }); }); - } + }, + + randomPhrase: function() { + var phrases = resources.phrases; + return phrases[Math.floor(Math.random() * phrases.length)]; + }, + + randomVerb: function() { + var verbs = resources.verbs; + return verbs[Math.floor(Math.random() * verbs.length)]; + }, + + randomCompliment: function() { + var compliments = resources.compliments; + return compliments[Math.floor(Math.random() * compliments.length)]; + } }; diff --git a/views/bonfire/show.jade b/views/bonfire/show.jade index 88d28655b9..fac141d818 100644 --- a/views/bonfire/show.jade +++ b/views/bonfire/show.jade @@ -60,7 +60,6 @@ block content var challengeSeed = !{JSON.stringify(challengeSeed)}; var challengeEntryPoint = !{JSON.stringify(challengeEntryPoint)}; var passedBonfireHash = !{JSON.stringify(bonfireHash)}; - console.log(passedBonfireHash); script(src='/js/lib/bonfire/bonfireFramework.js')