Merge branch 'release' into develop
This commit is contained in:
@@ -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;
|
||||
@@ -92,7 +92,7 @@ async function cronAsync (req, res) {
|
||||
|
||||
res.locals.wasModified = true; // TODO remove after v2 is retired
|
||||
|
||||
// Group.tavernBoss(user, progress);
|
||||
Group.tavernBoss(user, progress);
|
||||
|
||||
// Save user and tasks
|
||||
let toSave = [user.save()];
|
||||
|
||||
@@ -1053,9 +1053,17 @@ schema.statics.tavernBoss = async function tavernBoss (user, progress) {
|
||||
if (!tavern.quest.extra.worldDmg) tavern.quest.extra.worldDmg = {};
|
||||
|
||||
let wd = tavern.quest.extra.worldDmg;
|
||||
// Burnout attacks Ian, Seasonal Sorceress, tavern
|
||||
// Be-Wilder attacks Alex, Matt, Bailey
|
||||
let scene = wd.market ? wd.stables ? wd.bailey ? false : 'bailey' : 'stables' : 'market'; // eslint-disable-line no-nested-ternary
|
||||
// Dysheartener attacks Seasonal Sorceress, Alex, Ian
|
||||
let scene;
|
||||
if (wd.quests) {
|
||||
scene = false;
|
||||
} else if (wd.market) {
|
||||
scene = 'quests';
|
||||
} else if (wd.seasonalShop) {
|
||||
scene = 'market';
|
||||
} else {
|
||||
scene = 'seasonalShop';
|
||||
}
|
||||
|
||||
if (!scene) {
|
||||
tavern.sendChat(`\`${quest.boss.name('en')} tries to unleash ${quest.boss.rage.title('en')} but is too tired.\``);
|
||||
|
||||
Reference in New Issue
Block a user