mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Restrict users from getting back from death (#8808)
* Add test to prevent death users recovering health * Add check for buying potions with zero health * Validate hp <= 0 to take boss damage into account
This commit is contained in:
@@ -19,6 +19,10 @@ module.exports = function buyHealthPotion (user, req = {}, analytics) {
|
||||
throw new NotAuthorized(i18n.t('messageHealthAlreadyMax', req.language));
|
||||
}
|
||||
|
||||
if (user.stats.hp <= 0) {
|
||||
throw new NotAuthorized(i18n.t('messageHealthAlreadyMin', req.language));
|
||||
}
|
||||
|
||||
user.stats.hp += 15;
|
||||
if (user.stats.hp > 50) {
|
||||
user.stats.hp = 50;
|
||||
|
||||
Reference in New Issue
Block a user