mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
* Links stay white on hover * Fixed task icon color * Disabled plus button when needed * Fixed difficulty color * Fixed task reward color * Updated create styles * Fixed group plan link * Fixed second group test modal * Added login incentives * Fixed group notification clear * Show baily correctly * Styled armoire notification * Fixed contributor achievement styles * Fixed death * Fixed drop styles * Fixed invited friend modal * Fixed joined challenge achievement style * Fixed joined guild style * Fixed level up styles * Updated low health styles * Fixed bailey styles * Updated quest completed * Added soem conditionals to hide modals * Added rebirth styles * Fixed rebirth enable styles * Fixed streak styles * Fixed testing modals * Fixed ultimate gear achievement * Fixed won challenge * Set user to welcomed if created on mobile * Removed old default tasks * Began adding more options to avatar * Added change class * Inbox to messages * Moved profile to menu * Added user modal for viewing a user and send message * Fixed conversations * Fixed lint * Fixed challenges sending to server * Added challenge progress view * Fixed group sync after pay * Fixed some group accepting features * Fixed initial chat loading * Fixed some exitence errors * Added user names to assigned * Added upgrade link * Began adding new payment flow * Added default tasks * Updated avatar styles * Updated tutorial styles * Rebuilt notifications and styles * Updated upload script * Fixed lint * Added default tasks back to mobile and added updated tests * More test fixes
118 lines
3.5 KiB
JavaScript
118 lines
3.5 KiB
JavaScript
import habiticaMarkdown from 'habitica-markdown';
|
|
import { mapState } from 'client/libs/store';
|
|
|
|
export default {
|
|
computed: {
|
|
...mapState({notifications: 'notificationStore'}),
|
|
},
|
|
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.notify(message, 'xp', 'glyphicon glyphicon-star', this.sign(val));
|
|
},
|
|
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', '', this.sign(val));
|
|
},
|
|
hp (val) {
|
|
// don't show notifications if user dead
|
|
this.notify(`${this.sign(val)} ${this.round(val)}`, 'hp', 'glyphicon glyphicon-heart', this.sign(val));
|
|
},
|
|
lvl () {
|
|
this.notify(this.$t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up');
|
|
},
|
|
markdown (val) {
|
|
if (!val) return;
|
|
let parsedMarkdown = habiticaMarkdown.render(val);
|
|
this.notify(parsedMarkdown, 'info');
|
|
},
|
|
mp (val) {
|
|
this.notify(`${this.sign(val)} ${this.round(val)}`, 'mp', 'glyphicon glyphicon-fire', this.sign(val));
|
|
},
|
|
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));
|
|
},
|
|
notify (html, type, icon, sign) {
|
|
this.notifications.push({
|
|
title: '',
|
|
text: html,
|
|
type,
|
|
icon,
|
|
sign,
|
|
timeout: true,
|
|
});
|
|
},
|
|
},
|
|
};
|