Files
habitica/website/server/controllers/api-v3/world.js
Phillip Thelen f506044aa6 Seasonal gear fix (#15255)
* cleanup unneeded season definitions

* assign first winter seasonal gear right season

* add missing winter definition

* Fix enddate for winter galas

* fix lint

* fix halloween sprites

* set season

* fix loading habitoween sprites

* add missing customization shop sprites

* Fix test

* update customization shop sprites
2024-08-28 12:48:02 +02:00

48 lines
1.7 KiB
JavaScript

import {
getCurrentEventList,
getWorldBoss,
} from '../../libs/worldState';
const api = {};
/**
* @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 String, Quest content key for the world boss
* @apiSuccess {Object} data.worldBoss.progress.hp Number, Current Health of the world boss
* @apiSuccess {Object} data.worldBoss.progress.rage Number, Current Rage of the world boss
* @apiSuccess {Object} data.npcImageSuffix String, trailing component of NPC image filenames
* @apiSuccess {Object} data.currentEvent The current active event
*
*/
api.getWorldState = {
method: 'GET',
url: '/world-state',
async handler (req, res) {
const worldState = { npcImageSuffix: '', currentEvent: null };
worldState.worldBoss = await getWorldBoss();
worldState.currentEventList = getCurrentEventList();
if (worldState.currentEventList.length > 0) {
[worldState.currentEvent] = worldState.currentEventList;
}
worldState.currentEventList.forEach(event => {
if (event.npcImageSuffix && !worldState.npcImageSuffix) {
worldState.npcImageSuffix = event.npcImageSuffix;
}
});
res.respond(200, worldState);
},
};
export default api;