Refactor random verbs, phrases, and compliments so that only the resources controller is concerned with how to fetch them and how to make them randomly. Remove debug statement from bonfire/show.jade
This commit is contained in:
@ -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
|
||||
});
|
||||
|
@ -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
|
||||
});
|
||||
});
|
||||
|
@ -167,6 +167,21 @@ 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)];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user