Fix negative skillpoints in skillpoint engine
This commit is contained in:
parent
55ba7f4fc2
commit
ef96d77b2f
4 changed files with 17 additions and 0 deletions
|
@ -121,6 +121,9 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="center" id="summary-box">
|
||||||
|
Summary:
|
||||||
|
</div>
|
||||||
<div class="skillpoints">
|
<div class="skillpoints">
|
||||||
<div class="center" style="grid-column:1;grid-row:1">
|
<div class="center" style="grid-column:1;grid-row:1">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -92,6 +92,8 @@ def apply_to_fit(skillpoints, item):
|
||||||
applied = [0, 0, 0, 0, 0]
|
applied = [0, 0, 0, 0, 0]
|
||||||
total = 0
|
total = 0
|
||||||
for i, req, cur in zip(range(5), item["reqs"], skillpoints):
|
for i, req, cur in zip(range(5), item["reqs"], skillpoints):
|
||||||
|
if (item["reqs"][i] == 0):
|
||||||
|
continue
|
||||||
if req > cur:
|
if req > cur:
|
||||||
diff = req - cur
|
diff = req - cur
|
||||||
applied[i] += diff
|
applied[i] += diff
|
||||||
|
|
|
@ -34,6 +34,7 @@ function calculate_skillpoints(equipment, weapon) {
|
||||||
let applied = [0, 0, 0, 0, 0];
|
let applied = [0, 0, 0, 0, 0];
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
if (item.reqs[i] == 0) continue;
|
||||||
const req = item.reqs[i];
|
const req = item.reqs[i];
|
||||||
const cur = skillpoints[i];
|
const cur = skillpoints[i];
|
||||||
if (req > cur) {
|
if (req > cur) {
|
||||||
|
@ -87,8 +88,14 @@ function calculate_skillpoints(equipment, weapon) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total_applied < best_total) {
|
if (total_applied < best_total) {
|
||||||
|
console.log(total_applied);
|
||||||
|
console.log(skillpoints_applied);
|
||||||
|
console.log("Iteration 2");
|
||||||
for (const item of permutation) {
|
for (const item of permutation) {
|
||||||
|
console.log(item);
|
||||||
|
|
||||||
remove_skillpoints(skillpoints, item);
|
remove_skillpoints(skillpoints, item);
|
||||||
|
console.log(skillpoints);
|
||||||
result = apply_to_fit(skillpoints, item);
|
result = apply_to_fit(skillpoints, item);
|
||||||
needed_skillpoints = result[0];
|
needed_skillpoints = result[0];
|
||||||
total_diff = result[1];
|
total_diff = result[1];
|
||||||
|
@ -96,7 +103,10 @@ function calculate_skillpoints(equipment, weapon) {
|
||||||
skillpoints_applied[i] += needed_skillpoints[i];
|
skillpoints_applied[i] += needed_skillpoints[i];
|
||||||
skillpoints[i] += needed_skillpoints[i];
|
skillpoints[i] += needed_skillpoints[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_skillpoints(skillpoints, item);
|
apply_skillpoints(skillpoints, item);
|
||||||
|
console.log(skillpoints);
|
||||||
|
console.log(total_diff);
|
||||||
total_applied += total_diff;
|
total_applied += total_diff;
|
||||||
if (total_applied >= best_total) {
|
if (total_applied >= best_total) {
|
||||||
break;
|
break;
|
||||||
|
|
2
test.js
2
test.js
|
@ -190,6 +190,8 @@ function calculateBuild(){
|
||||||
console.log(skillpoints);
|
console.log(skillpoints);
|
||||||
player_build.assigned_skillpoints;
|
player_build.assigned_skillpoints;
|
||||||
|
|
||||||
|
setHTML("summary-box", "Summary: Assigned " + player_build.assigned_skillpoints + " skillpoints.");
|
||||||
|
|
||||||
setHTML("build-helmet", player_build.helmet.name);
|
setHTML("build-helmet", player_build.helmet.name);
|
||||||
setHTML("build-chestplate", player_build.chestplate.name);
|
setHTML("build-chestplate", player_build.chestplate.name);
|
||||||
setHTML("build-leggings", player_build.helmet.name);
|
setHTML("build-leggings", player_build.helmet.name);
|
||||||
|
|
Loading…
Reference in a new issue