diff --git a/public/js/controllers/challengesCtrl.js b/public/js/controllers/challengesCtrl.js index 3fbcbc0f0d..811f6c3ea2 100644 --- a/public/js/controllers/challengesCtrl.js +++ b/public/js/controllers/challengesCtrl.js @@ -32,6 +32,7 @@ habitrpg.controller("ChallengesCtrl", ['$scope', 'User', 'Challenges', 'Notifica if (!gid) return; var group = _.find($scope.groups, {_id:gid}); $scope.maxPrize = User.user.balance*4 + ((group && group.balance && group.leader==User.user._id) ? group.balance*4 : 0); + if (gid == 'habitrpg') $scope.newChallenge.prize = 1; }) diff --git a/src/controllers/challenges.js b/src/controllers/challenges.js index 804a3ad7e4..50e96bec43 100644 --- a/src/controllers/challenges.js +++ b/src/controllers/challenges.js @@ -117,6 +117,7 @@ api.create = function(req, res){ var user = res.locals.user; var waterfall = []; if (+req.body.prize < 0) return res.json(401, {err: 'Challenge prize must be >= 0'}); + if (req.body.group=='habitrpg' && +req.body.prize < 1) return res.json(401, {err: 'Prize must be at least 1 Gem for public challenges.'}); if (+req.body.prize > 0) { waterfall = [ function(cb){ diff --git a/views/options/social/challenges.jade b/views/options/social/challenges.jade index 47fcdb7d07..4eb92c2b61 100644 --- a/views/options/social/challenges.jade +++ b/views/options/social/challenges.jade @@ -78,9 +78,11 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') br .option-medium - input.option-content(type='number', min="0", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder='Prize') + input.option-content(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder='Prize') span.input-suffix.Pet_Currency_Gem1x.inline-gems i.icon-question-sign(popover="If someone can 'win' your challenge, you can optionally award that winner a Gem prize. Max = #gems you own (+ guild.gems, if you created this challenge's guild). Note: This prize can't be changed later.", popover-trigger='mouseenter', popover-placement='right') + span(ng-show='newChallenge.group=="habitrpg"'). +  Minimum 1 Gem for public challenges (helps prevent spam, it really does). habitrpg-tasks(main=false, obj='newChallenge')