mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Bulk stats (#9260)
* Reorganized stats * Organized allocation common code * Added bulk allocate to common * Added allocate bulk route * Fixed structure and lint * Fixed import and apidoc
This commit is contained in:
@@ -746,95 +746,6 @@ api.sleep = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/user/allocate Allocate a single attribute point
|
||||
* @apiName UserAllocate
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiParam (Body) {String="str","con","int","per"} stat Query parameter - Default ='str'
|
||||
*
|
||||
* @apiParamExample {json} Example request
|
||||
* {"stat":"int"}
|
||||
*
|
||||
* @apiSuccess {Object} data Returns stats from the user profile
|
||||
*
|
||||
* @apiError {NotAuthorized} NoPoints Not enough attribute points to increment a stat.
|
||||
*
|
||||
* @apiErrorExample {json}
|
||||
* {
|
||||
* "success": false,
|
||||
* "error": "NotAuthorized",
|
||||
* "message": "You don't have enough attribute points."
|
||||
* }
|
||||
*/
|
||||
api.allocate = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/allocate',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let allocateRes = common.ops.allocate(user, req);
|
||||
await user.save();
|
||||
res.respond(200, ...allocateRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/user/allocate-now Allocate all attribute points
|
||||
* @apiDescription Uses the user's chosen automatic allocation method, or if none, assigns all to STR. Note: will return success, even if there are 0 points to allocate.
|
||||
* @apiName UserAllocateNow
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {
|
||||
* "success": true,
|
||||
* "data": {
|
||||
* "hp": 50,
|
||||
* "mp": 38,
|
||||
* "exp": 7,
|
||||
* "gp": 284.8637271160258,
|
||||
* "lvl": 10,
|
||||
* "class": "rogue",
|
||||
* "points": 0,
|
||||
* "str": 2,
|
||||
* "con": 2,
|
||||
* "int": 3,
|
||||
* "per": 3,
|
||||
* "buffs": {
|
||||
* "str": 0,
|
||||
* "int": 0,
|
||||
* "per": 0,
|
||||
* "con": 0,
|
||||
* "stealth": 0,
|
||||
* "streaks": false,
|
||||
* "snowball": false,
|
||||
* "spookySparkles": false,
|
||||
* "shinySeed": false,
|
||||
* "seafoam": false
|
||||
* },
|
||||
* "training": {
|
||||
* "int": 0,
|
||||
* "per": 0,
|
||||
* "str": 0,
|
||||
* "con": 0
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @apiSuccess {Object} data user.stats
|
||||
*/
|
||||
api.allocateNow = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/allocate-now',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let allocateNowRes = common.ops.allocateNow(user);
|
||||
await user.save();
|
||||
res.respond(200, ...allocateNowRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/user/buy/:key Buy gear, armoire or potion
|
||||
* @apiDescription Under the hood uses UserBuyGear, UserBuyPotion and UserBuyArmoire
|
||||
|
||||
Reference in New Issue
Block a user