From ef96d77b2f380e5af0fbe81fda8df28cd1f7ace3 Mon Sep 17 00:00:00 2001 From: b Date: Thu, 7 Jan 2021 01:08:16 -0600 Subject: [PATCH] Fix negative skillpoints in skillpoint engine --- index.html | 3 +++ skillpoint_test.py | 2 ++ skillpoints.js | 10 ++++++++++ test.js | 2 ++ 4 files changed, 17 insertions(+) diff --git a/index.html b/index.html index 2cfa710..019d7ce 100644 --- a/index.html +++ b/index.html @@ -121,6 +121,9 @@ +
+ Summary: +
diff --git a/skillpoint_test.py b/skillpoint_test.py index 5e8e681..0738100 100644 --- a/skillpoint_test.py +++ b/skillpoint_test.py @@ -92,6 +92,8 @@ def apply_to_fit(skillpoints, item): applied = [0, 0, 0, 0, 0] total = 0 for i, req, cur in zip(range(5), item["reqs"], skillpoints): + if (item["reqs"][i] == 0): + continue if req > cur: diff = req - cur applied[i] += diff diff --git a/skillpoints.js b/skillpoints.js index 3c78f42..248735d 100644 --- a/skillpoints.js +++ b/skillpoints.js @@ -34,6 +34,7 @@ function calculate_skillpoints(equipment, weapon) { let applied = [0, 0, 0, 0, 0]; let total = 0; for (let i = 0; i < 5; i++) { + if (item.reqs[i] == 0) continue; const req = item.reqs[i]; const cur = skillpoints[i]; if (req > cur) { @@ -87,8 +88,14 @@ function calculate_skillpoints(equipment, weapon) { } } if (total_applied < best_total) { + console.log(total_applied); + console.log(skillpoints_applied); + console.log("Iteration 2"); for (const item of permutation) { + console.log(item); + remove_skillpoints(skillpoints, item); + console.log(skillpoints); result = apply_to_fit(skillpoints, item); needed_skillpoints = result[0]; total_diff = result[1]; @@ -96,7 +103,10 @@ function calculate_skillpoints(equipment, weapon) { skillpoints_applied[i] += needed_skillpoints[i]; skillpoints[i] += needed_skillpoints[i]; } + apply_skillpoints(skillpoints, item); + console.log(skillpoints); + console.log(total_diff); total_applied += total_diff; if (total_applied >= best_total) { break; diff --git a/test.js b/test.js index fd8cb5d..9c96207 100644 --- a/test.js +++ b/test.js @@ -190,6 +190,8 @@ function calculateBuild(){ console.log(skillpoints); player_build.assigned_skillpoints; + setHTML("summary-box", "Summary: Assigned " + player_build.assigned_skillpoints + " skillpoints."); + setHTML("build-helmet", player_build.helmet.name); setHTML("build-chestplate", player_build.chestplate.name); setHTML("build-leggings", player_build.helmet.name);