prevent user.stats.points from being negative e.g., after dropping level with Fix Character Values (still need to remove allocated points then)

This commit is contained in:
Alys 2015-04-05 09:03:39 +10:00
parent 3c07a8ee6b
commit e134c36ca2
2 changed files with 19 additions and 4 deletions

View file

@ -2641,12 +2641,16 @@ api.spells = {
target: 'task',
notes: t('spellWizardFireballNotes'),
cast: function(user, target) {
var bonus;
var bonus, req;
bonus = user._statsComputed.int * user.fns.crit('per');
target.value += diminishingReturns(bonus * .02, 4);
bonus *= Math.ceil((target.value < 0 ? 1 : target.value + 1) * .075);
user.stats.exp += diminishingReturns(bonus, 75);
return user.party.quest.progress.up += diminishingReturns(bonus * .1, 50, 30);
user.party.quest.progress.up += diminishingReturns(bonus * .1, 50, 30);
req = {
language: user.preferences.language
};
return user.fns.updateStats(user.stats, req);
}
},
mpheal: {
@ -2772,12 +2776,16 @@ api.spells = {
target: 'task',
notes: t('spellRogueBackStabNotes'),
cast: function(user, target) {
var bonus, _crit;
var bonus, req, _crit;
_crit = user.fns.crit('str', .3);
target.value += _crit * .03;
bonus = (target.value < 0 ? 1 : target.value + 1) * _crit;
user.stats.exp += bonus;
return user.stats.gp += bonus;
user.stats.gp += bonus;
req = {
language: user.preferences.language
};
return user.fns.updateStats(user.stats, req);
}
},
toolsOfTrade: {
@ -7036,6 +7044,9 @@ api.wrap = function(user, main) {
user.fns.autoAllocate();
} else {
user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int);
if (user.stats.points < 0) {
user.stats.points = 0;
}
}
user.stats.hp = 50;
}

View file

@ -1384,6 +1384,10 @@ api.wrap = (user, main=true) ->
else
# add new allocatable points. We could do user.stats.points++, but this does a fail-safe just in case
user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int);
if user.stats.points < 0
user.stats.points = 0
# This happens after dropping level with Fix Character Values and perhaps from other causes.
# TODO: Subtract points from attributes in the same manner as on death.
user.stats.hp = 50
user.stats.exp = stats.exp