Merge branch 'bonfire' into bonfire-redesign

Conflicts:
	views/bonfire/show.jade
This commit is contained in:
Michael Q Larson
2015-01-25 09:43:39 -08:00
3 changed files with 28 additions and 45 deletions

View File

@ -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
});

View File

@ -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
});
});

View File

@ -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)];
}
};