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:
Sabe Jones
2018-02-13 19:21:39 -06:00
committed by GitHub
parent fa06628361
commit d69e7e66ee
12 changed files with 194 additions and 5 deletions

View File

@@ -0,0 +1,35 @@
import { TAVERN_ID } from '../../../../../website/server/models/group';
import { updateDocument } from '../../../../helpers/mongo';
import {
requester,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
describe('GET /world-state', () => {
before(async () => {
await resetHabiticaDB();
});
it('returns empty worldBoss object when world boss is not active (and does not require authentication)', async () => {
const res = await requester().get('/world-state');
expect(res.worldBoss).to.eql({});
});
it('returns Tavern quest data when world boss is active', async () => {
await updateDocument('groups', {_id: TAVERN_ID}, {quest: {active: true, key: 'dysheartener', progress: {hp: 50000, rage: 9999}}});
const res = await requester().get('/world-state');
expect(res).to.have.deep.property('worldBoss');
expect(res.worldBoss).to.eql({
active: true,
extra: {},
key: 'dysheartener',
progress: {
collect: {},
hp: 50000,
rage: 9999,
},
});
});
});

View File

@@ -27,6 +27,8 @@
"royalPurpleGryphon": "Royal Purple Gryphon",
"phoenix": "Phoenix",
"magicalBee": "Magical Bee",
"hopefulHippogriffPet": "Hopeful Hippogriff",
"hopefulHippogriffMount": "Hopeful Hippogriff",
"royalPurpleJackalope": "Royal Purple Jackalope",
"invisibleAether": "Invisible Aether",
"rarePetPop1": "Click the gold paw to learn more about how you can obtain this rare pet through contributing to Habitica!",

View File

@@ -654,5 +654,17 @@
"questBadgerCompletion": "You finally drive away the the Badgering Bother and hurry into its burrow. At the end of a tunnel, you find its hoard of the faeries “Hibernate” To-Dos. The den is otherwise abandoned, except for three eggs that look ready to hatch.",
"questBadgerBoss": "The Badgering Bother",
"questBadgerDropBadgerEgg": "Badger (Egg)",
"questBadgerUnlockText": "Unlocks purchasable Badger eggs in the Market"
"questBadgerUnlockText": "Unlocks purchasable Badger eggs in the Market",
"questDysheartenerText": "The Dysheartener",
"questDysheartenerNotes": "The sun is rising on Valentines Day when a shocking crash splinters the air. A blaze of sickly pink light lances through all the buildings, and bricks crumble as a deep crack rips through Habit Citys main street. An unearthly shrieking rises through the air, shattering windows as a hulking form slithers forth from the gaping earth.<br><br>Mandibles snap and a carapace glitters; legs upon legs unfurl in the air. The crowd begins to scream as the insectoid creature rears up, revealing itself to be none other than that cruelest of creatures: the fearsome Dysheartener itself. It howls in anticipation and lunges forward, hungering to gnaw on the hopes of hard-working Habiticans. With each rasping scrape of its spiny forelegs, you feel a vise of despair tightening in your chest.<br><br>“Take heart, everyone!” Lemoness shouts. “It probably thinks that were easy targets because so many of us have daunting New Years Resolutions, but its about to discover that Habiticans know how to stick to their goals!”<br><br>AnnDeLune raises her staff. “Lets tackle our tasks and take this monster down!”",
"questDysheartenerCompletion": "<strong>The Dysheartener is DEFEATED!</strong><br><br>Together, everyone in Habitica strikes a final blow to their tasks, and the Dysheartener rears back, shrieking with dismay. “What's wrong, Dysheartener?” AnnDeLune calls, eyes sparkling. “Feeling discouraged?”<br><br>Glowing pink fractures crack across the Dysheartener's carapace, and it shatters in a puff of pink smoke. As a renewed sense of vigor and determination sweeps across the land, a flurry of delightful sweets rains down upon everyone.<br><br>The crowd cheers wildly, hugging each other as their pets happily chew on the belated Valentine's treats. Suddenly, a joyful chorus of song cascades through the air, and gleaming silhouettes soar across the sky.<br><br>Our newly-invigorated optimism has attracted a flock of Hopeful Hippogriffs! The graceful creatures alight upon the ground, ruffling their feathers with interest and prancing about. “It looks like we've made some new friends to help keep our spirits high, even when our tasks are daunting,” Lemoness says.<br><br>Beffymaroo already has her arms full with feathered fluffballs. “Maybe they'll help us rebuild the damaged areas of Habitica!”<br><br>Crooning and singing, the Hippogriffs lead the way as all the Habitcans work together to restore our beloved home.",
"questDysheartenerCompletionChat": "`The Dysheartener is DEFEATED!`\n\nTogether, everyone in Habitica strikes a final blow to their tasks, and the Dysheartener rears back, shrieking with dismay. “What's wrong, Dysheartener?” AnnDeLune calls, eyes sparkling. “Feeling discouraged?”\n\nGlowing pink fractures crack across the Dysheartener's carapace, and it shatters in a puff of pink smoke. As a renewed sense of vigor and determination sweeps across the land, a flurry of delightful sweets rains down upon everyone.\n\nThe crowd cheers wildly, hugging each other as their pets happily chew on the belated Valentine's treats. Suddenly, a joyful chorus of song cascades through the air, and gleaming silhouettes soar across the sky.\n\nOur newly-invigorated optimism has attracted a flock of Hopeful Hippogriffs! The graceful creatures alight upon the ground, ruffling their feathers with interest and prancing about. “It looks like we've made some new friends to help keep our spirits high, even when our tasks are daunting,” Lemoness says.\n\nBeffymaroo already has her arms full with feathered fluffballs. “Maybe they'll help us rebuild the damaged areas of Habitica!”\n\nCrooning and singing, the Hippogriffs lead the way as all the Habitcans work together to restore our beloved home.",
"questDysheartenerBossRageTitle": "Shattering Heartbreak",
"questDysheartenerBossRageDescription": "When this gauge fills, the Dysheartener will unleash its Shattering Heartbreak on Habitica!",
"questDysheartenerBossRageSeasonal": "`The Dysheartener uses SHATTERING HEARTBREAK!`\n\nOh, no! After feasting on our undone Dailies, the Dysheartener has gained the strength to unleash its Shattering Heartbreak attack. With a shrill shriek, it brings its spiny forelegs down upon the gazebo that houses the Seasonal Shop! The concussive blast of magic shreds the wood, and the Seasonal Sorceress is overcome by sorrow at the sight.\n\nQuickly, let's keep doing our Dailies so that the beast won't strike again!",
"questDysheartenerBossRageMarket": "`The Dysheartener uses SHATTERING HEARTBREAK!`\n\nHelp! After feasting on our incomplete Dailies, the Dysheartener lets out another Shattering Heartbreak attack, smashing the walls and floor of the Market! As stone rains down, Alex the Merchant weeps at his crushed merchandise, stricken by the destruction.\n\nWe can't let this happen again! Be sure to do all our your Dailies to prevent the Dysheartener from using its final strike.",
"questDysheartenerBossRageQuests": "`The Dysheartener uses SHATTERING HEARTBREAK!`\n\nAaaah! We've left our Dailies undone again, and the Dysheartener has mustered the energy for one final blow against our beloved shopkeepers. The countryside around Ian the Quest Master is ripped apart by its Shattering Heartbreak attack, and Ian is struck to the core by the horrific vision. We're so close to defeating this monster.... Hurry! Don't stop now!",
"questDysheartenerDropHippogriffPet": "Hopeful Hippogriff (Pet)",
"questDysheartenerDropHippogriffMount": "Hopeful Hippogriff (Mount)"
}

View File

@@ -3099,6 +3099,92 @@ let quests = {
unlock: t('questBadgerUnlockText'),
},
},
dysheartener: {
text: t('questDysheartenerText'),
notes: t('questDysheartenerNotes'),
completion: t('questDysheartenerCompletion'),
completionChat: t('questDysheartenerCompletionChat'),
value: 0,
canBuy () {
return false;
},
category: 'world',
boss: {
name: t('questDysheartenerText'),
hp: 17000000,
str: 1.25,
def: 1,
rage: {
title: t('questDysheartenerBossRageTitle'),
description: t('questDysheartenerBossRageDescription'),
value: 500000,
seasonalShop: t('questDysheartenerBossRageSeasonal'),
market: t('questDysheartenerBossRageMarket'),
quests: t('questDysheartenerBossRageQuests'),
},
},
colors: {
dark: '#410F2A',
medium: '#5C1130',
light: '#931F4D',
extralight: '#DC4069',
},
drop: {
items: [
{
type: 'pets',
key: 'Hippogriff-Hopeful',
text: t('questDysheartenerDropHippogriffPet'),
}, {
type: 'mounts',
key: 'Hippogriff-Hopeful',
text: t('questDysheartenerDropHippogriffMount'),
}, {
type: 'food',
key: 'Cake_Base',
text: t('foodCakeBase'),
}, {
type: 'food',
key: 'Candy_White',
text: t('foodCandyWhite'),
}, {
type: 'food',
key: 'Cake_Desert',
text: t('foodCakeDesert'),
}, {
type: 'food',
key: 'Candy_Red',
text: t('foodCandyRed'),
}, {
type: 'food',
key: 'Cake_Shade',
text: t('foodCakeShade'),
}, {
type: 'food',
key: 'Candy_Skeleton',
text: t('foodCandySkeleton'),
}, {
type: 'food',
key: 'Cake_Zombie',
text: t('foodCakeZombie'),
}, {
type: 'food',
key: 'Candy_CottonCandyPink',
text: t('foodCandyCottonCandyPink'),
}, {
type: 'food',
key: 'Candy_CottonCandyBlue',
text: t('foodCandyCottonCandyBlue'),
}, {
type: 'food',
key: 'Cake_Golden',
text: t('foodCakeGolden'),
},
],
gp: 0,
exp: 0,
},
},
};
each(quests, (v, key) => {

View File

@@ -70,6 +70,7 @@ let specialPets = {
'Jackalope-RoyalPurple': 'royalPurpleJackalope',
'Orca-Base': 'orca',
'Bear-Veteran': 'veteranBear',
'Hippogriff-Hopeful': 'hopefulHippogriffPet',
};
let specialMounts = {
@@ -87,6 +88,7 @@ let specialMounts = {
'Jackalope-RoyalPurple': 'royalPurpleJackalope',
'Aether-Invisible': 'invisibleAether',
'JackOLantern-Ghost': 'ghostJackolantern',
'Hippogriff-Hopeful': 'hopefulHippogriffMount',
};
each(specialPets, (translationString, key) => {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View 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;

View File

@@ -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()];

View File

@@ -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.\``);