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:
Oscar Rendón
2017-07-18 15:26:10 -05:00
committed by Sabe Jones
parent d918bc9f56
commit ab777f7006
6 changed files with 38 additions and 3 deletions

View File

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