mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Revert "fix(common): Corrects bug where stat points could be awarded after level 100"
This reverts commit 2bbdf66d76.
This commit is contained in:
@@ -2287,15 +2287,15 @@ api.wrap = function(user, main) {
|
|||||||
user.stats.lvl++;
|
user.stats.lvl++;
|
||||||
experienceToNextLevel = api.tnl(user.stats.lvl);
|
experienceToNextLevel = api.tnl(user.stats.lvl);
|
||||||
user.stats.hp = 50;
|
user.stats.hp = 50;
|
||||||
var allocatedStatPoints = user.stats.str + user.stats.int + user.stats.con + user.stats.per
|
var userTotalStatPoints = user.stats.str + user.stats.int + user.stats.con + user.stats.per;
|
||||||
|
|
||||||
if (allocatedStatPoints >= MAX_STAT_POINTS) {
|
if (userTotalStatPoints >= MAX_STAT_POINTS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (user.preferences.automaticAllocation) {
|
if (user.preferences.automaticAllocation) {
|
||||||
user.fns.autoAllocate();
|
user.fns.autoAllocate();
|
||||||
} else {
|
} else {
|
||||||
user.stats.points = MAX_STAT_POINTS - allocatedStatPoints;
|
user.stats.points = user.stats.lvl - userTotalStatPoints;
|
||||||
if (user.stats.points < 0) {
|
if (user.stats.points < 0) {
|
||||||
user.stats.points = 0;
|
user.stats.points = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe('user.fns.updateStats', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context('Stat Allocation', () => {
|
context('Stat Allocation', () => {
|
||||||
it('adds an attibute point when user\'s stat points are less than max level', () => {
|
it('Adds an attibute point when user\'s stat points are less than max level', () => {
|
||||||
let stats = {
|
let stats = {
|
||||||
exp: 3581,
|
exp: 3581,
|
||||||
};
|
};
|
||||||
@@ -54,7 +54,7 @@ describe('user.fns.updateStats', () => {
|
|||||||
expect(user.stats.points).to.eql(1);
|
expect(user.stats.points).to.eql(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add an attibute point when user\'s stat points are equal to max level', () => {
|
it('Does not add an attibute point when user\'s stat points are equal to max level', () => {
|
||||||
let stats = {
|
let stats = {
|
||||||
exp: 3581,
|
exp: 3581,
|
||||||
};
|
};
|
||||||
@@ -69,39 +69,5 @@ describe('user.fns.updateStats', () => {
|
|||||||
|
|
||||||
expect(user.stats.points).to.eql(0);
|
expect(user.stats.points).to.eql(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add an attibute point when user\'s stat points + unallocated points are equal to max level', () => {
|
|
||||||
let stats = {
|
|
||||||
exp: 3581,
|
|
||||||
};
|
|
||||||
|
|
||||||
user.stats.lvl = 99;
|
|
||||||
user.stats.str = 25;
|
|
||||||
user.stats.int = 25;
|
|
||||||
user.stats.con = 25;
|
|
||||||
user.stats.per = 15;
|
|
||||||
user.stats.points = 10;
|
|
||||||
|
|
||||||
user.fns.updateStats(stats);
|
|
||||||
|
|
||||||
expect(user.stats.points).to.eql(10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('if user is missing unallocated stat points and is over level 100, only awards stat points up to level 100', () => {
|
|
||||||
let stats = {
|
|
||||||
exp: 5581,
|
|
||||||
};
|
|
||||||
|
|
||||||
user.stats.lvl = 104;
|
|
||||||
user.stats.str = 25;
|
|
||||||
user.stats.int = 25;
|
|
||||||
user.stats.con = 25;
|
|
||||||
user.stats.per = 15;
|
|
||||||
user.stats.points = 0;
|
|
||||||
|
|
||||||
user.fns.updateStats(stats);
|
|
||||||
|
|
||||||
expect(user.stats.points).to.eql(10);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user