Fix minor bug in skillpoint engine, add assign skillpoint
This commit is contained in:
parent
f3c2cefd5a
commit
00f380fe87
4 changed files with 35 additions and 10 deletions
15
index.html
15
index.html
|
@ -130,6 +130,9 @@
|
|||
</div>
|
||||
<div class="skillpoints">
|
||||
<div class="center" style="grid-column:1;grid-row:1">
|
||||
<div id="str-skp-assign">
|
||||
Before Boosts: 0
|
||||
</div>
|
||||
<div>
|
||||
<label for="str-skp">Strength:</label>
|
||||
<input type="number" id="str-skp" name="str-skp" value="0"/>
|
||||
|
@ -139,6 +142,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:2;grid-row:1">
|
||||
<div id="dex-skp-assign">
|
||||
Before Boosts: 0
|
||||
</div>
|
||||
<div>
|
||||
<label for="dex-skp">Dexterity:</label>
|
||||
<input type="number" id="dex-skp" name="dex-skp" value="0"/>
|
||||
|
@ -148,6 +154,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:1">
|
||||
<div id="int-skp-assign">
|
||||
Before Boosts: 0
|
||||
</div>
|
||||
<div>
|
||||
<label for="int-skp">Intelligence:</label>
|
||||
<input type="number" id="int-skp" name="int-skp" value="0"/>
|
||||
|
@ -157,6 +166,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:1">
|
||||
<div id="def-skp-assign">
|
||||
Before Boosts: 0
|
||||
</div>
|
||||
<div>
|
||||
<label for="def-skp">Defense:</label>
|
||||
<input type="number" id="def-skp" name="def-skp" value="0"/>
|
||||
|
@ -166,6 +178,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:5;grid-row:1">
|
||||
<div id="agi-skp-assign">
|
||||
Before Boosts: 0
|
||||
</div>
|
||||
<div>
|
||||
<label for="agi-skp">Agility:</label>
|
||||
<input type="number" id="agi-skp" name="agi-skp" value="0"/>
|
||||
|
|
|
@ -5,14 +5,8 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
let fixed = [];
|
||||
let consider = [];
|
||||
let noboost = [];
|
||||
let has_skillpoint = [false, false, false, false, false];
|
||||
|
||||
for (const item of equipment) {
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
if (item.reqs[i] > 0) {
|
||||
has_skillpoint[i] = true;
|
||||
}
|
||||
}
|
||||
if (item.reqs.every(x => x === 0)) {
|
||||
fixed.push(item);
|
||||
}
|
||||
|
@ -46,6 +40,7 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
total -= item.skillpoints[i];
|
||||
}
|
||||
if (item.reqs[i] == 0) continue;
|
||||
skillpoint_filter[i] = true;
|
||||
const req = item.reqs[i];
|
||||
const cur = skillpoints[i];
|
||||
if (req > cur) {
|
||||
|
@ -71,6 +66,8 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
if (consider.length > 0 || noboost.length > 0) {
|
||||
// Try every combination and pick the best one.
|
||||
for (let permutation of perm(consider)) {
|
||||
let has_skillpoint = [false, false, false, false, false];
|
||||
|
||||
permutation = permutation.concat(noboost);
|
||||
console.log(permutation);
|
||||
|
||||
|
|
17
test.js
17
test.js
|
@ -268,17 +268,26 @@ function calculateBuild(){
|
|||
}
|
||||
setHTML("build-order", equip_order_text);
|
||||
|
||||
player_build.base_skillpoints;
|
||||
let assigned = player_build.base_skillpoints;
|
||||
setText("str-skp-assign", "Before Boosts: " + assigned[0]);
|
||||
setText("dex-skp-assign", "Before Boosts: " + assigned[1]);
|
||||
setText("int-skp-assign", "Before Boosts: " + assigned[2]);
|
||||
setText("def-skp-assign", "Before Boosts: " + assigned[3]);
|
||||
setText("agi-skp-assign", "Before Boosts: " + assigned[4]);
|
||||
|
||||
let skillpoints = player_build.total_skillpoints;
|
||||
setValue("str-skp", skillpoints[0]);
|
||||
setValue("dex-skp", skillpoints[1]);
|
||||
setValue("int-skp", skillpoints[2]);
|
||||
setValue("def-skp", skillpoints[3]);
|
||||
setValue("agi-skp", skillpoints[4]);
|
||||
console.log(skillpoints);
|
||||
player_build.assigned_skillpoints;
|
||||
setText("str-skp-base", "Original Value: " + skillpoints[0]);
|
||||
setText("dex-skp-base", "Original Value: " + skillpoints[1]);
|
||||
setText("int-skp-base", "Original Value: " + skillpoints[2]);
|
||||
setText("def-skp-base", "Original Value: " + skillpoints[3]);
|
||||
setText("agi-skp-base", "Original Value: " + skillpoints[4]);
|
||||
|
||||
setHTML("summary-box", "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints.");
|
||||
setText("summary-box", "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints.");
|
||||
|
||||
displayExpandedItem(expandItem(player_build.helmet), "build-helmet");
|
||||
displayExpandedItem(expandItem(player_build.chestplate), "build-chestplate");
|
||||
|
|
4
utils.js
4
utils.js
|
@ -22,6 +22,10 @@ function perm(a){
|
|||
return r;
|
||||
}
|
||||
|
||||
function setText(id, text) {
|
||||
document.getElementById(id).textContent = text;
|
||||
}
|
||||
|
||||
function setHTML(id, html) {
|
||||
document.getElementById(id).innerHTML = html;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue