mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
World Boss 2018 (Server) (#9995)
* feat(world-boss): barebones API * fix(world): use Express respond for better JSON * fix(api): respond with code 200 * feat(content): canonical Dysheartener desc and Rage * fix(world-boss): enable progress * WIP(test): world state API * WIP(test): refactor world boss setup * WIP(test): better expectations * fix(test): more expect polishing * feat(event): server side World Boss * fix(strings): accidental deletion * fix(content): include encouragement after Rage * refactor(world-boss): address comments
This commit is contained in:
44
website/server/controllers/api-v3/world.js
Normal file
44
website/server/controllers/api-v3/world.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
model as Group,
|
||||
TAVERN_ID as tavernId,
|
||||
} from '../../models/group';
|
||||
|
||||
let api = {};
|
||||
|
||||
async function getWorldBoss () {
|
||||
let tavern = await Group
|
||||
.findById(tavernId)
|
||||
.select('quest.progress quest.key quest.active quest.extra')
|
||||
.exec();
|
||||
if (tavern && tavern.quest && tavern.quest.active) {
|
||||
return tavern.quest;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v3/world-state Get the state for the game world
|
||||
* @apiDescription Does not require authentication.
|
||||
* @apiName WorldStateGet
|
||||
* @apiGroup WorldState
|
||||
*
|
||||
* @apiSuccess {Object} data.worldBoss.active Boolean, true if world boss quest is underway
|
||||
* @apiSuccess {Object} data.worldBoss.extra.worldDmg Object with NPC names as Boolean properties, true if they are affected by Rage Strike
|
||||
* @apiSuccess {Object} data.worldBoss.key Quest content key for the world boss
|
||||
* @apiSuccess {Object} data.worldBoss.progress.hp Current Health of the world boss
|
||||
* @apiSuccess {Object} data.worldBoss.progress.rage Current Rage of the world boss
|
||||
*
|
||||
*/
|
||||
api.getWorldState = {
|
||||
method: 'GET',
|
||||
url: '/world-state',
|
||||
async handler (req, res) {
|
||||
let worldState = {};
|
||||
|
||||
worldState.worldBoss = await getWorldBoss();
|
||||
|
||||
res.respond(200, worldState);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
Reference in New Issue
Block a user