Skip to content

Commit

Permalink
HabitRPG#2217 apiv2 update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lefnire committed Jan 2, 2014
1 parent e927c89 commit 580279e
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 58 deletions.
4 changes: 0 additions & 4 deletions API.md

This file was deleted.

9 changes: 8 additions & 1 deletion src/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,14 @@ api.buyGemsPaypalIPN = function(req, res) {
*/
api.cast = function(req, res) {
var user = res.locals.user;
var type = req.body.type, target = req.body.target;
var type, target;
if (req.body.type) { // this is the method implemented in the app, it's not correct
type = req.body.type;
target = req.body.target;
} else if (req.query.targetType) { // this is the supported API method
type = req.query.targetType;
target = req.query.targetId;
}
var klass = shared.content.spells.special[req.params.spell] ? 'special' : user.stats.class
var spell = shared.content.spells[klass][req.params.spell];

Expand Down
14 changes: 3 additions & 11 deletions src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ var Challenge = require('./challenge').model;
// User Schema
// -----------

var eggPotionMapping = _.transform(shared.content.eggs, function(m, egg){
_.defaults(m, _.transform(shared.content.hatchingPotions, function(m2, pot){
m2[egg.key + '-' + pot.key] = true;
}));
})

var specialPetsMapping = shared.content.specialPets; // may need to revisit if we add additional information about the special pets

var UserSchema = new Schema({
// ### UUID and API Token
_id: {
Expand Down Expand Up @@ -146,9 +138,9 @@ var UserSchema = new Schema({
pets:
_.defaults(
// First transform to a 1D eggs/potions mapping
_.transform(eggPotionMapping, function(m,v,k){ m[k] = Number; }),
_.transform(shared.content.pets, function(m,v,k){ m[k] = Number; }),
// Then add additional pets (backer, contributor)
_.transform(specialPetsMapping, function(m,v,k){ m[k] = Number; })
_.transform(shared.content.specialPets, function(m,v,k){ m[k] = Number; })
),
currentPet: String, // Cactus-Desert

Expand Down Expand Up @@ -177,7 +169,7 @@ var UserSchema = new Schema({
// }
mounts: _.defaults(
// First transform to a 1D eggs/potions mapping
_.transform(eggPotionMapping, function(m,v,k){ m[k] = Boolean; }),
_.transform(shared.content.pets, function(m,v,k){ m[k] = Boolean; }),
// Then add additional pets (backer, contributor)
{
'LionCub-Ethereal': Boolean,
Expand Down
Loading

0 comments on commit 580279e

Please sign in to comment.