mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
Change out one if chain for a switch, put stats in 3:2:1:1 order in code (@paglias)
This commit is contained in:
parent
6997cd9821
commit
0478323efc
2 changed files with 29 additions and 24 deletions
32
dist/habitrpg-shared.js
vendored
32
dist/habitrpg-shared.js
vendored
|
|
@ -11937,7 +11937,7 @@ var process=require("__browserify_process");(function() {
|
|||
*/
|
||||
|
||||
updateStats: function(stats) {
|
||||
var diff, ideal, lowest, preference, suggested, tallies, tnl;
|
||||
var diff, ideal, preference, suggested, tallies, tnl;
|
||||
if (stats.hp <= 0) {
|
||||
return user.stats.hp = 0;
|
||||
}
|
||||
|
|
@ -11958,27 +11958,31 @@ var process=require("__browserify_process");(function() {
|
|||
if (user.preferences.automaticAllocation) {
|
||||
switch (user.preferences.allocationMode) {
|
||||
case "flat":
|
||||
lowest = Math.min(user.stats.str, user.stats.int, user.stats.con, user.stats.per);
|
||||
if (user.stats.int === lowest) {
|
||||
suggested = Math.min(user.stats.str, user.stats.int, user.stats.con, user.stats.per);
|
||||
if (user.stats.int === suggested) {
|
||||
user.stats.int++;
|
||||
} else if (user.stats.per === lowest) {
|
||||
} else if (user.stats.per === suggested) {
|
||||
user.stats.per++;
|
||||
} else if (user.stats.str === lowest) {
|
||||
} else if (user.stats.str === suggested) {
|
||||
user.stats.str++;
|
||||
} else {
|
||||
user.stats.con++;
|
||||
}
|
||||
break;
|
||||
case "classbased":
|
||||
ideal = [user.stats.lvl / 7, user.stats.lvl / 7, user.stats.lvl / 7 * 2, user.stats.lvl / 7 * 3];
|
||||
if (user.stats["class"] === "wizard") {
|
||||
preference = ["con", "str", "per", "int"];
|
||||
} else if (user.stats["class"] === "rogue") {
|
||||
preference = ["int", "con", "str", "per"];
|
||||
} else if (user.stats["class"] === "healer") {
|
||||
preference = ["str", "per", "int", "con"];
|
||||
} else {
|
||||
preference = ["per", "int", "con", "str"];
|
||||
ideal = [user.stats.lvl / 7 * 3, user.stats.lvl / 7 * 2, user.stats.lvl / 7, user.stats.lvl / 7];
|
||||
switch (user.stats["class"]) {
|
||||
case "wizard":
|
||||
preference = ["int", "per", "con", "str"];
|
||||
break;
|
||||
case "rogue":
|
||||
preference = ["per", "str", "int", "con"];
|
||||
break;
|
||||
case "healer":
|
||||
preference = ["con", "int", "str", "per"];
|
||||
break;
|
||||
default:
|
||||
preference = ["str", "con", "per", "int"];
|
||||
}
|
||||
diff = [user.stats[preference[0]] - ideal[0], user.stats[preference[1]] - ideal[1], user.stats[preference[2]] - ideal[2], user.stats[preference[3]] - ideal[3]];
|
||||
suggested = _.findIndex(diff, (function(val) {
|
||||
|
|
|
|||
|
|
@ -964,23 +964,24 @@ api.wrap = (user) ->
|
|||
if user.preferences.automaticAllocation
|
||||
switch user.preferences.allocationMode
|
||||
when "flat"
|
||||
lowest = Math.min(user.stats.str, user.stats.int, user.stats.con, user.stats.per)
|
||||
if user.stats.int is lowest # In case of ties, favor INT first, to get the next point sooner
|
||||
suggested = Math.min(user.stats.str, user.stats.int, user.stats.con, user.stats.per)
|
||||
if user.stats.int is suggested # In case of ties, favor INT first, to get the next point sooner
|
||||
user.stats.int++
|
||||
else if user.stats.per is lowest # Then favor PER, it's a god stat
|
||||
else if user.stats.per is suggested # Then favor PER, it's a god stat
|
||||
user.stats.per++
|
||||
else if user.stats.str is lowest # Then favor STR, everyone loves crits
|
||||
else if user.stats.str is suggested # Then favor STR, everyone loves crits
|
||||
user.stats.str++
|
||||
else
|
||||
user.stats.con++ # CON, the unsexiest of attributes
|
||||
when "classbased"
|
||||
# Attributes get 3:2:1:1 per 7 levels. But put dump stats up front so they're favored in ties ("building the foundation of the pyramid")
|
||||
ideal = [(user.stats.lvl / 7), (user.stats.lvl / 7), (user.stats.lvl / 7 * 2), (user.stats.lvl / 7 * 3)] # Tertiary, quaternary, secondary, primary
|
||||
# Attributes get 3:2:1:1 per 7 levels.
|
||||
ideal = [(user.stats.lvl / 7 * 3), (user.stats.lvl / 7 * 2), (user.stats.lvl / 7), (user.stats.lvl / 7)]
|
||||
# Primary, secondary etc. attributes aren't explicitly defined, so hardcode them. In order per above
|
||||
if user.stats.class is "wizard" then preference = ["con", "str", "per", "int"]
|
||||
else if user.stats.class is "rogue" then preference = ["int", "con", "str", "per"]
|
||||
else if user.stats.class is "healer" then preference = ["str", "per", "int", "con"]
|
||||
else preference = ["per", "int", "con", "str"]
|
||||
switch user.stats.class
|
||||
when "wizard" then preference = ["int", "per", "con", "str"]
|
||||
when "rogue" then preference = ["per", "str", "int", "con"]
|
||||
when "healer" then preference = ["con", "int", "str", "per"]
|
||||
else preference = ["str", "con", "per", "int"]
|
||||
# Get the difference between the ideal attribute spread according to level, and the user's current spread.
|
||||
diff = [(user.stats[preference[0]]-ideal[0]),(user.stats[preference[1]]-ideal[1]),(user.stats[preference[2]]-ideal[2]),(user.stats[preference[3]]-ideal[3])]
|
||||
suggested = _.findIndex(diff, ((val) -> if val is _.min(diff) then true)) # Returns the index of the first attribute that's furthest behind the ideal
|
||||
|
|
|
|||
Loading…
Reference in a new issue