change Build internal item repr to include separate tomes array, allow bitvec to append using other bitvec (untested)
This commit is contained in:
parent
d76ad45b9c
commit
31fd1a2f01
4 changed files with 30 additions and 12 deletions
15
js/build.js
15
js/build.js
|
@ -11,17 +11,15 @@ class Build{
|
|||
* @description Construct a build.
|
||||
* @param {Number} level : Level of the player.
|
||||
* @param {String[]} equipment : List of equipment names that make up the build.
|
||||
* In order: boots, Chestplate, Leggings, Boots, Ring1, Ring2, Brace, Neck, Weapon.
|
||||
* @param {Number[]} powders : Powder application. List of lists of integers (powder IDs).
|
||||
* In order: boots, Chestplate, Leggings, Boots, Weapon.
|
||||
* @param {Object[]} inputerrors : List of instances of error-like classes.
|
||||
* In order: boots, Chestplate, Leggings, Boots, Ring1, Ring2, Brace, Neck
|
||||
*
|
||||
* @param {Object[]} tomes: List of tomes.
|
||||
* In order: 2x Weapon Mastery Tome, 4x Armor Mastery Tome, 1x Guild Tome.
|
||||
* 2x Slaying Mastery Tome, 2x Dungeoneering Mastery Tome, 2x Gathering Mastery Tome are in game, but do not have "useful" stats (those that affect damage calculations or building)
|
||||
*
|
||||
* @param {Object} weapon: Weapon.
|
||||
*/
|
||||
constructor(level, items, weapon){
|
||||
|
||||
constructor(level, equipment, tomes, weapon){
|
||||
if (level < 1) { //Should these be constants?
|
||||
this.level = 1;
|
||||
} else if (level > 106) {
|
||||
|
@ -36,9 +34,10 @@ class Build{
|
|||
document.getElementById("level-choice").value = this.level;
|
||||
|
||||
this.availableSkillpoints = levelToSkillPoints(this.level);
|
||||
this.equipment = items;
|
||||
this.equipment = equipment;
|
||||
this.tomes = tomes;
|
||||
this.weapon = weapon;
|
||||
this.items = this.equipment.concat([this.weapon]);
|
||||
this.items = this.equipment.concat(tomes, [this.weapon]);
|
||||
// return [equip_order, best_skillpoints, final_skillpoints, best_total];
|
||||
|
||||
// calc skillpoints requires statmaps only
|
||||
|
|
|
@ -233,7 +233,15 @@ function encodeBuild(build, powders, skillpoints, atree, atree_state) {
|
|||
|
||||
// [flag to indicate if tomes are included (0/1)]
|
||||
// [if set: 7 sequential tome IDs, each 6 bits unsigned]
|
||||
|
||||
if (build.tomes.length > 0) {
|
||||
build_bits.append(1, 1);
|
||||
//decoding will assume that tomes has length of 7.
|
||||
for (const tome of build.tomes) {
|
||||
build_bits.append(tome.id, 6);
|
||||
}
|
||||
} else {
|
||||
build_bits.append(0, 1);
|
||||
}
|
||||
|
||||
// ATREE
|
||||
|
||||
|
|
|
@ -397,7 +397,9 @@ class BuildAssembleNode extends ComputeNode {
|
|||
input_map.get('ring1-input'),
|
||||
input_map.get('ring2-input'),
|
||||
input_map.get('bracelet-input'),
|
||||
input_map.get('necklace-input'),
|
||||
input_map.get('necklace-input')
|
||||
];
|
||||
let tomes = [
|
||||
input_map.get('weaponTome1-input'),
|
||||
input_map.get('weaponTome2-input'),
|
||||
input_map.get('armorTome1-input'),
|
||||
|
@ -419,7 +421,7 @@ class BuildAssembleNode extends ComputeNode {
|
|||
if (all_none && !location.hash) {
|
||||
return null;
|
||||
}
|
||||
return new Build(level, equipments, weapon);
|
||||
return new Build(level, equipments, tomes, weapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
js/utils.js
11
js/utils.js
|
@ -373,10 +373,19 @@ Base64 = (function () {
|
|||
}
|
||||
} else if (data instanceof BitVector) {
|
||||
//fill to end of curr int of existing bv
|
||||
let other_pos = (32 - (pos % 32)) % 32;
|
||||
this.bits[curr_idx] |= data.slice(0, other_pos);
|
||||
curr_idx += 1;
|
||||
|
||||
//fill full ints
|
||||
while (other_pos + 32 < data.length) {
|
||||
this.bits[curr_idx] = data.slice(other_pos, other_pos + 32);
|
||||
curr_idx += 1;
|
||||
other_pos += 32;
|
||||
}
|
||||
|
||||
//fill from "rest of" length/bv
|
||||
//fill from "rest of" length/bv
|
||||
this.bits[curr_idx] = data.slice(other_pos, data.length);
|
||||
} else {
|
||||
throw new TypeError("BitVector must be appended with a Number or a B64 String");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue