mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-12 23:08:35 +00:00
cleanup death handling
This commit is contained in:
parent
86dae794b1
commit
deb7e83394
2 changed files with 10 additions and 17 deletions
19
dist/habitrpg-shared.js
vendored
19
dist/habitrpg-shared.js
vendored
|
|
@ -8771,25 +8771,20 @@ var global=self;/**
|
|||
};
|
||||
|
||||
obj.revive = function(user) {
|
||||
var candidate, count, item, k, lostItem, lostStat, v, _ref1;
|
||||
var count, item, k, lostItem, lostStat, v, _ref1;
|
||||
user.stats.hp = 50;
|
||||
user.stats.exp = 0;
|
||||
user.stats.gp = 0;
|
||||
if (user.stats.lvl > 1) {
|
||||
user.stats.lvl--;
|
||||
}
|
||||
if ((user.stats.str + user.stats.con + user.stats.per + user.stats.int) > 1) {
|
||||
while (!lostStat) {
|
||||
candidate = {
|
||||
0: 'str',
|
||||
1: 'con',
|
||||
2: 'per',
|
||||
3: 'int'
|
||||
}[Math.random() * 4 | 0];
|
||||
if (user.stats[candidate] > 0) {
|
||||
lostStat = candidate;
|
||||
}
|
||||
lostStat = helpers.randomVal(_.reduce(['str', 'con', 'per', 'int'], (function(m, k) {
|
||||
if (user.stats[v]) {
|
||||
m[k] = k;
|
||||
}
|
||||
return m;
|
||||
}), {}));
|
||||
if (lostStat) {
|
||||
user.stats[lostStat]--;
|
||||
}
|
||||
count = 0;
|
||||
|
|
|
|||
|
|
@ -37,13 +37,11 @@ obj.revive = (user)->
|
|||
user.stats.lvl-- if user.stats.lvl > 1
|
||||
|
||||
# Lose a stat point
|
||||
if (user.stats.str + user.stats.con + user.stats.per + user.stats.int) > 1
|
||||
until lostStat
|
||||
candidate = {0:'str', 1:'con', 2:'per', 3:'int'}[Math.random()*4|0]
|
||||
lostStat = candidate if user.stats[candidate] > 0
|
||||
user.stats[lostStat]--
|
||||
lostStat = helpers.randomVal _.reduce ['str','con','per','int'], ((m,k)->(m[k]=k if user.stats[v];m)), {}
|
||||
user.stats[lostStat]-- if lostStat
|
||||
|
||||
# Lose a gear piece
|
||||
# Can't use randomVal since we need k, not v
|
||||
count = 0
|
||||
for k,v of user.items.gear.owned
|
||||
lostItem = k if Math.random() < (1 / ++count)
|
||||
|
|
|
|||
Loading…
Reference in a new issue