mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
committed by
Blade Barringer
parent
bccdf4e989
commit
b54441a637
@@ -29,8 +29,10 @@ describe('common.fns.randomDrop', () => {
|
|||||||
};
|
};
|
||||||
randomDrop(user, { task, predictableRandom });
|
randomDrop(user, { task, predictableRandom });
|
||||||
expect(user.party.quest.progress.collectedItems).to.eql(1);
|
expect(user.party.quest.progress.collectedItems).to.eql(1);
|
||||||
|
expect(user._tmp.quest.collection).to.eql(1);
|
||||||
randomDrop(user, { task, predictableRandom });
|
randomDrop(user, { task, predictableRandom });
|
||||||
expect(user.party.quest.progress.collectedItems).to.eql(2);
|
expect(user.party.quest.progress.collectedItems).to.eql(2);
|
||||||
|
expect(user._tmp.quest.collection).to.eql(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
context('drops enabled', () => {
|
context('drops enabled', () => {
|
||||||
@@ -42,7 +44,7 @@ describe('common.fns.randomDrop', () => {
|
|||||||
it('does nothing if user.items.lastDrop.count is exceeded', () => {
|
it('does nothing if user.items.lastDrop.count is exceeded', () => {
|
||||||
user.items.lastDrop.count = 100;
|
user.items.lastDrop.count = 100;
|
||||||
randomDrop(user, { task, predictableRandom });
|
randomDrop(user, { task, predictableRandom });
|
||||||
expect(user._tmp).to.eql({});
|
expect(user._tmp.drop).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('drops something when the task is a todo', () => {
|
it('drops something when the task is a todo', () => {
|
||||||
|
|||||||
@@ -142,6 +142,21 @@ describe('shared.ops.scoreTask', () => {
|
|||||||
expect(ref.beforeUser._id).to.eql(ref.afterUser._id);
|
expect(ref.beforeUser._id).to.eql(ref.afterUser._id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('and increments quest progress', () => {
|
||||||
|
expect(ref.afterUser.party.quest.progress.up).to.eql(0);
|
||||||
|
ref.afterUser.party.quest.key = 'gryphon';
|
||||||
|
|
||||||
|
scoreTask({ user: ref.afterUser, task: habit, direction: 'up', cron: false });
|
||||||
|
let firstTaskDelta = ref.afterUser.party.quest.progress.up;
|
||||||
|
expect(firstTaskDelta).to.be.greaterThan(0);
|
||||||
|
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(firstTaskDelta);
|
||||||
|
|
||||||
|
scoreTask({ user: ref.afterUser, task: habit, direction: 'up', cron: false });
|
||||||
|
let secondTaskDelta = ref.afterUser.party.quest.progress.up - firstTaskDelta;
|
||||||
|
expect(secondTaskDelta).to.be.greaterThan(0);
|
||||||
|
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(secondTaskDelta);
|
||||||
|
});
|
||||||
|
|
||||||
context('habits', () => {
|
context('habits', () => {
|
||||||
it('up', () => {
|
it('up', () => {
|
||||||
options = { user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false };
|
options = { user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false };
|
||||||
|
|||||||
@@ -326,6 +326,24 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _questProgress() {
|
||||||
|
var user = $scope.user;
|
||||||
|
if (user.party.quest) {
|
||||||
|
var userQuest = Content.quests[user.party.quest.key];
|
||||||
|
|
||||||
|
if (!userQuest) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (userQuest.boss && user.party.quest.progress.up > 0) {
|
||||||
|
return user.party.quest.progress.up;
|
||||||
|
}
|
||||||
|
if (userQuest.collect && user.party.quest.progress.collectedItems > 0) {
|
||||||
|
return user.party.quest.progress.collectedItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------
|
------------------------
|
||||||
Spells
|
Spells
|
||||||
@@ -365,6 +383,8 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.castEnd = function(target, type, $event){
|
$scope.castEnd = function(target, type, $event){
|
||||||
|
var beforeQuestProgress = _questProgress();
|
||||||
|
|
||||||
if (!$rootScope.applyingAction) return 'No applying action';
|
if (!$rootScope.applyingAction) return 'No applying action';
|
||||||
$event && ($event.stopPropagation(),$event.preventDefault());
|
$event && ($event.stopPropagation(),$event.preventDefault());
|
||||||
|
|
||||||
@@ -383,12 +403,22 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
$http.post(spellUrl)
|
$http.post(spellUrl)
|
||||||
.success(function(){ // TODO response will always include the modified data, no need to sync!
|
.success(function(){ // TODO response will always include the modified data, no need to sync!
|
||||||
var msg = window.env.t('youCast', {spell: spell.text()});
|
var msg = window.env.t('youCast', {spell: spell.text()});
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'task': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.text});break;
|
case 'task': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.text});break;
|
||||||
case 'user': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.profile.name});break;
|
case 'user': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.profile.name});break;
|
||||||
case 'party': msg = window.env.t('youCastParty', {spell: spell.text()});break;
|
case 'party': msg = window.env.t('youCastParty', {spell: spell.text()});break;
|
||||||
}
|
}
|
||||||
Notification.markdown(msg);
|
Notification.markdown(msg);
|
||||||
|
var questProgress = _questProgress() - beforeQuestProgress;
|
||||||
|
if (questProgress > 0) {
|
||||||
|
var userQuest = Content.quests[user.party.quest.key];
|
||||||
|
if (userQuest.boss) {
|
||||||
|
Notification.quest('questDamage', questProgress.toFixed(1));
|
||||||
|
} else if (quest.collection && userQuest.collect) {
|
||||||
|
Notification.quest('questCollection', questProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
User.sync();
|
User.sync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ angular.module("habitrpg").factory("Notification",
|
|||||||
_notify(val, 'drop', dropClass);
|
_notify(val, 'drop', dropClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function quest(type, val) {
|
||||||
|
_notify(window.env.t(type, { val: val }), 'success');
|
||||||
|
}
|
||||||
|
|
||||||
function exp(val) {
|
function exp(val) {
|
||||||
if (val < -50) return; // don't show when they level up (resetting their exp)
|
if (val < -50) return; // don't show when they level up (resetting their exp)
|
||||||
_notify(_sign(val) + " " + _round(val) + " " + window.env.t('experience'), 'xp', 'glyphicon glyphicon-star');
|
_notify(_sign(val) + " " + _round(val) + " " + window.env.t('experience'), 'xp', 'glyphicon glyphicon-star');
|
||||||
@@ -147,6 +151,7 @@ angular.module("habitrpg").factory("Notification",
|
|||||||
markdown: markdown,
|
markdown: markdown,
|
||||||
mp: mp,
|
mp: mp,
|
||||||
streak: streak,
|
streak: streak,
|
||||||
text: text
|
text: text,
|
||||||
|
quest: quest
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -247,11 +247,22 @@ angular.module('habitrpg')
|
|||||||
var tmp = res.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
|
var tmp = res.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
|
||||||
var crit = tmp.crit;
|
var crit = tmp.crit;
|
||||||
var drop = tmp.drop;
|
var drop = tmp.drop;
|
||||||
|
var quest = tmp.quest;
|
||||||
|
|
||||||
if (crit) {
|
if (crit) {
|
||||||
var critBonus = crit * 100 - 100;
|
var critBonus = crit * 100 - 100;
|
||||||
Notification.crit(critBonus);
|
Notification.crit(critBonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (quest && user.party.quest) {
|
||||||
|
var userQuest = Content.quests[user.party.quest.key];
|
||||||
|
if (quest.progressDelta && userQuest.boss) {
|
||||||
|
Notification.quest('questDamage', quest.progressDelta.toFixed(1));
|
||||||
|
} else if (quest.collection && userQuest.collect) {
|
||||||
|
Notification.quest('questCollection', quest.collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (drop) {
|
if (drop) {
|
||||||
var text, notes, type;
|
var text, notes, type;
|
||||||
$rootScope.playSound('Item_Drop');
|
$rootScope.playSound('Item_Drop');
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
"pending": "Pending",
|
"pending": "Pending",
|
||||||
"questStart": "Once all members have either accepted or rejected, the quest begins. Only those that clicked \"accept\" will be able to participate in the quest and receive the drops. If members are pending too long (inactive?), the quest owner can start the quest without them by clicking \"Begin\". The quest owner can also cancel the quest and regain the quest scroll by clicking \"Cancel\".",
|
"questStart": "Once all members have either accepted or rejected, the quest begins. Only those that clicked \"accept\" will be able to participate in the quest and receive the drops. If members are pending too long (inactive?), the quest owner can start the quest without them by clicking \"Begin\". The quest owner can also cancel the quest and regain the quest scroll by clicking \"Cancel\".",
|
||||||
"questStartBroken": "Once all members have either accepted or rejected, the quest begins... Only those that clicked \"accept\" will be able to participate in the quest and receive the drops... If members are pending too long (inactive?), the quest owner can start the quest without them by clicking \"Begin\"... The quest owner can also cancel the quest and regain the quest scroll by clicking \"Cancel\"...",
|
"questStartBroken": "Once all members have either accepted or rejected, the quest begins... Only those that clicked \"accept\" will be able to participate in the quest and receive the drops... If members are pending too long (inactive?), the quest owner can start the quest without them by clicking \"Begin\"... The quest owner can also cancel the quest and regain the quest scroll by clicking \"Cancel\"...",
|
||||||
|
"questCollection": "+<%= val %> quest item(s) found",
|
||||||
|
"questDamage": "+<%= val %> damage to boss",
|
||||||
"begin": "Begin",
|
"begin": "Begin",
|
||||||
"bossHP": "Boss Health",
|
"bossHP": "Boss Health",
|
||||||
"bossStrength": "Boss Strength",
|
"bossStrength": "Boss Strength",
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ module.exports = function randomDrop (user, options, req = {}) {
|
|||||||
if (predictableRandom(user, user.stats.gp) < chance) {
|
if (predictableRandom(user, user.stats.gp) < chance) {
|
||||||
if (!user.party.quest.progress.collectedItems) user.party.quest.progress.collectedItems = 0;
|
if (!user.party.quest.progress.collectedItems) user.party.quest.progress.collectedItems = 0;
|
||||||
user.party.quest.progress.collectedItems++;
|
user.party.quest.progress.collectedItems++;
|
||||||
|
if (!user._tmp.quest) user._tmp.quest = {};
|
||||||
|
user._tmp.quest.collection = 1;
|
||||||
user.markModified('party.quest.progress');
|
user.markModified('party.quest.progress');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,14 +150,17 @@ function _changeTaskValue (user, task, direction, times, cron) {
|
|||||||
|
|
||||||
if (direction === 'up') { // Make progress on quest based on STR
|
if (direction === 'up') { // Make progress on quest based on STR
|
||||||
user.party.quest.progress.up = user.party.quest.progress.up || 0;
|
user.party.quest.progress.up = user.party.quest.progress.up || 0;
|
||||||
|
let prevProgress = user.party.quest.progress.up;
|
||||||
|
|
||||||
if (task.type === 'todo' || task.type === 'daily') {
|
if (task.type === 'todo' || task.type === 'daily') {
|
||||||
user.party.quest.progress.up += nextDelta * (1 + user._statsComputed.str / 200);
|
user.party.quest.progress.up += nextDelta * (1 + user._statsComputed.str / 200);
|
||||||
} else if (task.type === 'habit') {
|
} else if (task.type === 'habit') {
|
||||||
user.party.quest.progress.up += nextDelta * (0.5 + user._statsComputed.str / 400);
|
user.party.quest.progress.up += nextDelta * (0.5 + user._statsComputed.str / 400);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!user._tmp.quest) user._tmp.quest = {};
|
||||||
|
user._tmp.quest.progressDelta = user.party.quest.progress.up - prevProgress;
|
||||||
|
}
|
||||||
task.value += nextDelta;
|
task.value += nextDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user