mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
Heal when necessary
Events.setHeal() enables/disables eatMeat and useMeds buttons depending on player's HP. The check is done in 4 cases: * when a fight starts * after an attack * after healing * in the loot screen
This commit is contained in:
@@ -133,6 +133,7 @@ var Events = {
|
|||||||
Events.createUseMedsButton().appendTo(healBtns);
|
Events.createUseMedsButton().appendTo(healBtns);
|
||||||
}
|
}
|
||||||
$('<div>').addClass('clear').appendTo(healBtns);
|
$('<div>').addClass('clear').appendTo(healBtns);
|
||||||
|
Events.setHeal(healBtns);
|
||||||
|
|
||||||
// Set up the enemy attack timer
|
// Set up the enemy attack timer
|
||||||
Events._enemyAttackTimer = Engine.setInterval(Events.enemyAttack, scene.attackDelay * 1000);
|
Events._enemyAttackTimer = Engine.setInterval(Events.enemyAttack, scene.attackDelay * 1000);
|
||||||
@@ -276,6 +277,18 @@ var Events = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setHeal: function(healBtns){
|
||||||
|
if(!healBtns){
|
||||||
|
healBtns = $('#healButtons');
|
||||||
|
}
|
||||||
|
healBtns = healBtns.children('.button');
|
||||||
|
var canHeal = (World.health < World.getMaxHealth());
|
||||||
|
healBtns.each(function(i){
|
||||||
|
Button.setDisabled($(this), !canHeal);
|
||||||
|
});
|
||||||
|
return canHeal;
|
||||||
|
},
|
||||||
|
|
||||||
doHeal: function(healing, cured, btn){
|
doHeal: function(healing, cured, btn){
|
||||||
if(Path.outfit[healing] > 0) {
|
if(Path.outfit[healing] > 0) {
|
||||||
Path.outfit[healing]--;
|
Path.outfit[healing]--;
|
||||||
@@ -287,6 +300,7 @@ var Events = {
|
|||||||
var hp = World.health + cured;
|
var hp = World.health + cured;
|
||||||
hp = Math.min(World.getMaxHealth(),hp);
|
hp = Math.min(World.getMaxHealth(),hp);
|
||||||
World.setHp(hp);
|
World.setHp(hp);
|
||||||
|
Events.setHeal();
|
||||||
|
|
||||||
if(Events.activeEvent()) {
|
if(Events.activeEvent()) {
|
||||||
var w = $('#wanderer');
|
var w = $('#wanderer');
|
||||||
@@ -401,6 +415,7 @@ var Events = {
|
|||||||
enemy.data('hp', enemyHp);
|
enemy.data('hp', enemyHp);
|
||||||
if(fighter.attr('id') == 'enemy') {
|
if(fighter.attr('id') == 'enemy') {
|
||||||
World.setHp(enemyHp);
|
World.setHp(enemyHp);
|
||||||
|
Events.setHeal();
|
||||||
}
|
}
|
||||||
Events.updateFighterDiv(enemy);
|
Events.updateFighterDiv(enemy);
|
||||||
}
|
}
|
||||||
@@ -536,6 +551,7 @@ var Events = {
|
|||||||
Events.createUseMedsButton(0).appendTo(healBtns);
|
Events.createUseMedsButton(0).appendTo(healBtns);
|
||||||
}
|
}
|
||||||
$('<div>').addClass('clear').appendTo(healBtns);
|
$('<div>').addClass('clear').appendTo(healBtns);
|
||||||
|
Events.setHeal();
|
||||||
}
|
}
|
||||||
$('<div>').addClass('clear').appendTo(exitBtns);
|
$('<div>').addClass('clear').appendTo(exitBtns);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user