mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
* Added initial challenge pages * Added challenge item and find guilds page * Added challenge detail * Added challenge modals * Ported over challenge service code * Ported over challenge ctrl code * Added styles and column * Minor modal updates * Removed duplicate keys * Fixed casing * Added initial chat component * Added copy as todo modal * Added sync * Added chat to groups * Fixed lint * Added notification service * Added tag services * Added notifications * Added hall * Added analytics * Added http interceptor * Added initial autocomplete * Added initial footer component * Began coding and designing footer * Added inital hall * Ported over inital group plan ctrl code * Added initial invite modal * Added initial member detail modal * Added initial notification menu * Ported over inital notification code * Fixed import line * Fixed autocomplete import casing
125 lines
4.0 KiB
JavaScript
125 lines
4.0 KiB
JavaScript
export default {
|
|
methods: {
|
|
/**
|
|
Show '+ 5 {gold_coin} 3 {silver_coin}'
|
|
*/
|
|
coins (money) {
|
|
let absolute;
|
|
let gold;
|
|
let silver;
|
|
absolute = Math.abs(money);
|
|
gold = Math.floor(absolute);
|
|
silver = Math.floor((absolute - gold) * 100);
|
|
if (gold && silver > 0) {
|
|
return `${gold} <span class='notification-icon shop_gold'></span> ${silver} <span class='notification-icon shop_silver'></span>`;
|
|
} else if (gold > 0) {
|
|
return `${gold} <span class='notification-icon shop_gold'></span>`;
|
|
} else if (silver > 0) {
|
|
return `${silver} <span class='notification-icon shop_silver'></span>`;
|
|
}
|
|
},
|
|
crit (val) {
|
|
let message = `${this.$t('critBonus')} ${Math.round(val)} %`;
|
|
this.notify(message, 'crit', 'glyphicon glyphicon-certificate');
|
|
},
|
|
drop (val, item) {
|
|
let dropClass = '';
|
|
if (item) {
|
|
switch (item.type) {
|
|
case 'Egg':
|
|
dropClass = `Pet_Egg_${item.key}`;
|
|
break;
|
|
case 'HatchingPotion':
|
|
dropClass = `Pet_HatchingPotion_${item.key}`;
|
|
break;
|
|
case 'Food':
|
|
dropClass = `Pet_Food_${item.key}`;
|
|
break;
|
|
case 'armor':
|
|
case 'back':
|
|
case 'body':
|
|
case 'eyewear':
|
|
case 'head':
|
|
case 'headAccessory':
|
|
case 'shield':
|
|
case 'weapon':
|
|
dropClass = `shop_${item.key}`;
|
|
break;
|
|
default:
|
|
dropClass = 'glyphicon glyphicon-gift';
|
|
}
|
|
}
|
|
this.notify(val, 'drop', dropClass);
|
|
},
|
|
quest (type, val) {
|
|
this.notify(this.$t(type, { val }), 'success');
|
|
},
|
|
exp (val) {
|
|
if (val < -50) return; // don't show when they level up (resetting their exp)
|
|
let message = `${this.sign(val)} ${this.round(val)} + ${this.$t('experience')}`;
|
|
this.notify(message, 'xp', 'glyphicon glyphicon-star');
|
|
},
|
|
error (error, canHide) {
|
|
this.notify(error, 'danger', 'glyphicon glyphicon-exclamation-sign', canHide);
|
|
},
|
|
gp (val, bonus) {
|
|
this.notify(`${this.sign(val)} ${this.coins(val - bonus)}`, 'gp');
|
|
},
|
|
hp (val) {
|
|
// don't show notifications if user dead
|
|
this.notify(`${this.sign(val)} ${this.round(val)} ${this.$t('health')}`, 'hp', 'glyphicon glyphicon-heart');
|
|
},
|
|
lvl () {
|
|
this.notify(this.$t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up');
|
|
},
|
|
markdown (val) {
|
|
if (!val) return;
|
|
// @TODO: Implement markdown library
|
|
// let parsed_markdown = $filter("markdown")(val);
|
|
// this.notify(parsed_markdown, 'info');
|
|
},
|
|
mp (val) {
|
|
this.notify(`${this.sign(val)} ${this.round(val)} ${this.$t('mana')}`, 'mp', 'glyphicon glyphicon-fire');
|
|
},
|
|
streak (val) {
|
|
this.notify(`${this.$t('streaks')}: ${val}`, 'streak', 'glyphicon glyphicon-repeat');
|
|
},
|
|
text (val, onClick) {
|
|
if (!val) return;
|
|
this.notify(val, 'info', null, null, onClick);
|
|
},
|
|
sign (number) {
|
|
let sign = '+';
|
|
if (number && number < 0) {
|
|
sign = '-';
|
|
}
|
|
return sign;
|
|
},
|
|
round (number) {
|
|
return Math.abs(number.toFixed(1));
|
|
},
|
|
// @TODO: Implement when we have a notify library
|
|
//notify (html, type, icon, canHide, onClick) {
|
|
// let stack_topright = {"dir1": "down", "dir2": "left", "spacing1": 15, "spacing2": 15, "firstpos1": 60};
|
|
// let notice = $.pnotify({
|
|
// type: type || 'warning', //('info', 'text', 'warning', 'success', 'gp', 'xp', 'hp', 'lvl', 'death', 'mp', 'crit')
|
|
// text: html,
|
|
// opacity: 1,
|
|
// addclass: 'alert-' + type,
|
|
// delay: 7000,
|
|
// hide: ((type == 'error' || type == 'danger') && !canHide) ? false : true,
|
|
// mouse_reset: false,
|
|
// width: "250px",
|
|
// stack: stack_topright,
|
|
// icon: icon || false
|
|
// }).click(function() {
|
|
// notice.pnotify_remove();
|
|
//
|
|
// if (onClick) {
|
|
// onClick();
|
|
// }
|
|
// });
|
|
//},
|
|
},
|
|
};
|