WIP(warning-modal): Low health warning

This commit is contained in:
Sabe Jones
2015-08-18 16:05:48 -04:00
parent 120550666d
commit 12b0361d45
6 changed files with 37 additions and 3 deletions

View File

@@ -3,5 +3,9 @@
"dontDespair": "Don't despair!",
"deathPenaltyDetails": "You lost a Level, your Gold, and a piece of Equipment, but you can get them all back with hard work! Good luck--you'll do great.",
"refillHealthTryAgain": "Refill Health & Try Again",
"dyingOftenTips": "Is this happening often? <a href='http://habitica.wikia.com/wiki/Death_Mechanics#Strategies_for_Staying_Alive' target='_blank'>Here are some tips!</a>"
"dyingOftenTips": "Is this happening often? <a href='http://habitica.wikia.com/wiki/Death_Mechanics#Strategies_for_Staying_Alive' target='_blank'>Here are some tips!</a>",
"losingHealth": "Careful - You're Losing Health!",
"lowHealthTips1": "Level up to be fully healed, or buy a Health Potion from the Rewards column to restore 15 Health Points. Don't let your Health drop to zero! If you do, you'll lose a level, your Gold, and a piece of equipment.",
"lowHealthTips2": "Losing Health quickly? Reassess your Habits and Dailies to make sure that you're starting slowly and building up over time. Incomplete Dailies hurt you overnight, so be careful not to have too many at first! If a Daily isn't due on a certain day, you can disable it by clicking the pencil icon.",
"goodLuck": "Good luck!"
}

View File

@@ -8,6 +8,8 @@ habitrpg.controller('NotificationCtrl',
if (after <= 0){
$rootScope.playSound('Death');
$rootScope.openModal('death', {keyboard:false, backdrop:'static'});
} else if (after <= 30 && !User.user.flags.warnedLowHealth) {
$rootScope.openModal('lowHealth', {keyboard:false, backdrop:'static', controller:'UserCtrl'});
}
if (after == before) return;
if (User.user.stats.lvl == 0) return;

View File

@@ -43,6 +43,10 @@ habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$
$scope._editing.profile = false;
}
$scope.acknowledgeHealthWarning = function(){
User.user.ops.update && User.set({'flags.warnedLowHealth':false});
}
/**
* For gem-unlockable preferences, (a) if owned, select preference (b) else, purchase
* @param path: User.preferences <-> User.purchased maps like User.preferences.skin=abc <-> User.purchased.skin.abc.

View File

@@ -163,7 +163,8 @@ var UserSchema = new Schema({
armoireEnabled: {type: Boolean, 'default': false},
armoireOpened: {type: Boolean, 'default': false},
armoireEmpty: {type: Boolean, 'default': false},
cardReceived: {type: Boolean, 'default': false}
cardReceived: {type: Boolean, 'default': false},
warnedLowHealth: {type: Boolean, 'default': false}
},
history: {
exp: Array, // [{date: Date, value: Number}], // big peformance issues if these are defined

View File

@@ -13,3 +13,4 @@ include ./rebirth
include ./limited
include ./invite-friends
include ./welcome.jade
include ./low-health.jade

View File

@@ -0,0 +1,22 @@
include ../avatar/generated_avatar
script(type='text/ng-template', id='modals/lowHealth.html')
.modal-header
h3.text-center=env.t('losingHealth')
.modal-body
.hero-stats
.meter-label(tooltip=env.t('health'))
span.glyphicon.glyphicon-heart
.meter.health(tooltip='{{Math.round(user.stats.hp * 100) / 100}}')
.bar(ng-style='{"width": Shared.percent(user.stats.hp, Shared.maxHealth)+"%"}')
span.meter-text.value
| {{Math.ceil(user.stats.hp)}} / {{::Shared.maxHealth}}
.herobox.inline-block(style='padding-top:0em')
.character-sprites
+generatedAvatar
p=env.t('lowHealthTips1')
p(style='margin-top:1.5em')=env.t('lowHealthTips2')
p(style='margin-top:1.5em')=env.t('goodLuck')
.modal-footer
a.btn.btn-primary(ng-click='acknowledgeHealthWarning(); $close()')=env.t('ok')