fixed tome ID system, tome encoding and decoding support in build link

This commit is contained in:
ferricles 2022-05-20 19:01:53 -07:00
parent 58e75eb0a2
commit 621a115a5c
5 changed files with 212 additions and 121 deletions

View file

@ -417,13 +417,13 @@
<div class="col fw-bold dark-4 rounded-top">
<div class = "row">
<div class = "col-4 py-2">
<button class = "button rounded scaled-font fw-bold text-light dark-5" id = "edit-ID-button" onclick = "toggle_tab('edit_id_tab'); toggleButton('edit-ID-button')">
Edit IDs
<button class = "col-auto button rounded scaled-font fw-bold text-light dark-5" id = "toggle-tomes" onclick = "toggle_tab('tomes-dropdown'); toggleButton('toggle-tomes')">
Show Tomes
</button>
</div>
<div class = "col-4 py-2">
<button class = "col-auto button rounded scaled-font fw-bold text-light dark-5" id = "toggle-tomes" onclick = "toggle_tab('tomes-dropdown'); toggleButton('toggle-tomes')">
Show Tomes
<button class = "button rounded scaled-font fw-bold text-light dark-5" id = "edit-ID-button" onclick = "toggle_tab('edit_id_tab'); toggleButton('edit-ID-button')">
Edit IDs
</button>
</div>
<div class = "col-4 py-2">

View file

@ -7,7 +7,8 @@ let tload_complete = false;
let tload_in_progress = false;
let tomes;
let tomeMap;
let tomeIDMap;
let tometomeIDMap;
let tomeRedirectMap;
let tomeLists = new Map();
/*
* Load tome set from local DB. Calls init() on success.
@ -127,6 +128,8 @@ function init_tome_maps() {
tomeMap = new Map();
/* Mapping from item names to set names. */
tomeIDMap = new Map();
tomeRedirectMap = new Map();
for (const it of tomeTypes) {
tomeLists.set(it, []);
}
@ -150,7 +153,7 @@ function init_tome_maps() {
tome.reqs = [0, 0, 0, 0, 0];
tome.fixID = true;
tome.tier = "Normal";
tome.id = 10000 + i;
tome.id = 61 + i; //special case!
tome.nDam = "0-0";
tome.eDam = "0-0";
tome.tDam = "0-0";
@ -163,22 +166,19 @@ function init_tome_maps() {
noneTomes[i] = tome;
}
tomes = tomes.concat(noneTomes);
//console.log(tomes);
for (const tome of tomes) {
if (tome.remapID === undefined) {
tomeLists.get(tome.type).push(tome.displayName);
tomeMap.set(tome.displayName, tome);
if (noneTomes.includes(tome)) {
idMap.set(tome.id, "");
tomeIDMap.set(tome.id, "");
}
else {
idMap.set(tome.id, tome.displayName);
tomeIDMap.set(tome.id, tome.displayName);
}
}
else {
redirectMap.set(tome.id, tome.remapID);
tomeRedirectMap.set(tome.id, tome.remapID);
}
}
console.log(tomeLists);
console.log(tomeMap);
}

View file

@ -110,6 +110,13 @@ function getItemNameFromID(id) {
return idMap.get(id);
}
function getTomeNameFromID(id) {
if (tomeRedirectMap.has(id)) {
return getTomeNameFromID(tomeRedirectMap.get(id));
}
return tomeIDMap.get(id);
}
function parsePowdering(powder_info) {
// TODO: Make this run in linear instead of quadratic time... ew
let powdering = [];
@ -138,13 +145,17 @@ function parsePowdering(powder_info) {
*/
function decodeBuild(url_tag) {
if (url_tag) {
//default values
let equipment = [null, null, null, null, null, null, null, null, null];
let tomes = [null, null, null, null, null, null, null];
let powdering = ["", "", "", "", ""];
let info = url_tag.split("_");
let version = info[0];
let save_skp = false;
let skillpoints = [0, 0, 0, 0, 0];
let level = 106;
//equipment (items)
if (version === "0" || version === "1" || version === "2" || version === "3") {
let equipments = info[1];
for (let i = 0; i < 9; ++i ) {
@ -188,6 +199,42 @@ function decodeBuild(url_tag) {
}
info[1] = info_str.slice(start_idx);
}
if (version === "6") {
let info_str = info[1];
let start_idx = 0;
for (let i = 0; i < 9; ++i ) {
if (info_str.slice(start_idx,start_idx+3) === "CR-") {
equipment[i] = info_str.slice(start_idx, start_idx+20);
start_idx += 20;
} else if (info_str.slice(start_idx+3,start_idx+6) === "CI-") {
let len = Base64.toInt(info_str.slice(start_idx,start_idx+3));
equipment[i] = info_str.slice(start_idx+3,start_idx+3+len);
start_idx += (3+len);
} else {
let equipment_str = info_str.slice(start_idx, start_idx+3);
equipment[i] = getItemNameFromID(Base64.toInt(equipment_str));
start_idx += 3;
}
}
//tomes!
for (let i = 0; i < 7; ++i) {
let tome_str = info_str.charAt(start_idx);
tomes[i] = getTomeNameFromID(Base64.toInt(tome_str));
start_idx += 1;
}
info[1] = info_str.slice(start_idx);
//tome values do not appear in anything before v6.
for (let i in tomes) {
setValue(tomeInputs[i], tomes[i]);
}
}
//constant in all versions
for (let i in equipment) {
setValue(equipmentInputs[i], equipment[i]);
}
//level, skill point assignments, and powdering
if (version === "1") {
let powder_info = info[1];
powdering = parsePowdering(powder_info);
@ -200,7 +247,7 @@ function decodeBuild(url_tag) {
let powder_info = info[1].slice(10);
powdering = parsePowdering(powder_info);
} else if (version === "3" || version === "4" || version === "5"){
} else if (version === "3" || version === "4" || version === "5" || version === "6"){
level = Base64.toInt(info[1].slice(10,12));
setValue("level-choice",level);
save_skp = true;
@ -213,13 +260,10 @@ function decodeBuild(url_tag) {
powdering = parsePowdering(powder_info);
}
for (let i in powderInputs) {
setValue(powderInputs[i], powdering[i]);
}
for (let i in equipment) {
setValue(equipmentInputs[i], equipment[i]);
}
calculateBuild(save_skp, skillpoints);
}
}
@ -230,15 +274,14 @@ function encodeBuild() {
if (player_build) {
let build_string;
if (player_build.customItems.length > 0) { //v5 encoding
build_string = "5_";
//V6 encoding - Tomes
if (player_build.items.length == 16 && player_build.tomes) {
build_string = "6_";
let crafted_idx = 0;
let custom_idx = 0;
for (const item of player_build.items) {
//skip tomes (do we skip them?)
if (item.category === "tome") {
continue;
}
if (item.get("custom")) {
let custom = "CI-"+encodeCustom(player_build.customItems[custom_idx],true);
@ -247,42 +290,9 @@ function encodeBuild() {
} else if (item.get("crafted")) {
build_string += "CR-"+encodeCraft(player_build.craftedItems[crafted_idx]);
crafted_idx += 1;
} else {
build_string += Base64.fromIntN(item.get("id"), 3);
}
}
for (const skp of skp_order) {
build_string += Base64.fromIntN(getValue(skp + "-skp"), 2); // Maximum skillpoints: 2048
}
build_string += Base64.fromIntN(player_build.level, 2);
for (const _powderset of player_build.powders) {
let n_bits = Math.ceil(_powderset.length / 6);
build_string += Base64.fromIntN(n_bits, 1); // Hard cap of 378 powders.
// Slice copy.
let powderset = _powderset.slice();
while (powderset.length != 0) {
let firstSix = powderset.slice(0,6).reverse();
let powder_hash = 0;
for (const powder of firstSix) {
powder_hash = (powder_hash << 5) + 1 + powder; // LSB will be extracted first.
}
build_string += Base64.fromIntN(powder_hash, 5);
powderset = powderset.slice(6);
}
}
} else { //v4 encoding
build_string = "4_";
let crafted_idx = 0;
for (const item of player_build.items) {
//skip tomes for now
if (item.get("category") === "tome") {
continue;
}
if (item.get("crafted")) {
build_string += "-"+encodeCraft(player_build.craftedItems[crafted_idx]);
crafted_idx += 1;
} else if (item.get("category") === "tome") {
console.log(item);
build_string += Base64.fromIntN(item.get("id"), 1);
} else {
build_string += Base64.fromIntN(item.get("id"), 3);
}
@ -308,8 +318,89 @@ function encodeBuild() {
}
}
}
return build_string;
}
/* For reference in development - V5 and V4 encoding schemes */
// //V5 encoding - Custom Items
// if (player_build.customItems.length > 0) {
// build_string = "5_";
// let crafted_idx = 0;
// let custom_idx = 0;
// for (const item of player_build.items) {
// //skip tomes (do we skip them?)
// if (item.category === "tome") {
// continue;
// }
// if (item.get("custom")) {
// let custom = "CI-"+encodeCustom(player_build.customItems[custom_idx],true);
// build_string += Base64.fromIntN(custom.length, 3) + custom;
// custom_idx += 1;
// } else if (item.get("crafted")) {
// build_string += "CR-"+encodeCraft(player_build.craftedItems[crafted_idx]);
// crafted_idx += 1;
// } else {
// build_string += Base64.fromIntN(item.get("id"), 3);
// }
// }
// for (const skp of skp_order) {
// build_string += Base64.fromIntN(getValue(skp + "-skp"), 2); // Maximum skillpoints: 2048
// }
// build_string += Base64.fromIntN(player_build.level, 2);
// for (const _powderset of player_build.powders) {
// let n_bits = Math.ceil(_powderset.length / 6);
// build_string += Base64.fromIntN(n_bits, 1); // Hard cap of 378 powders.
// // Slice copy.
// let powderset = _powderset.slice();
// while (powderset.length != 0) {
// let firstSix = powderset.slice(0,6).reverse();
// let powder_hash = 0;
// for (const powder of firstSix) {
// powder_hash = (powder_hash << 5) + 1 + powder; // LSB will be extracted first.
// }
// build_string += Base64.fromIntN(powder_hash, 5);
// powderset = powderset.slice(6);
// }
// }
// } else { //v4 encoding
// build_string = "4_";
// let crafted_idx = 0;
// for (const item of player_build.items) {
// //skip tomes for now
// if (item.get("category") === "tome") {
// continue;
// }
// if (item.get("crafted")) {
// build_string += "-"+encodeCraft(player_build.craftedItems[crafted_idx]);
// crafted_idx += 1;
// } else {
// build_string += Base64.fromIntN(item.get("id"), 3);
// }
// }
// for (const skp of skp_order) {
// build_string += Base64.fromIntN(getValue(skp + "-skp"), 2); // Maximum skillpoints: 2048
// }
// build_string += Base64.fromIntN(player_build.level, 2);
// for (const _powderset of player_build.powders) {
// let n_bits = Math.ceil(_powderset.length / 6);
// build_string += Base64.fromIntN(n_bits, 1); // Hard cap of 378 powders.
// // Slice copy.
// let powderset = _powderset.slice();
// while (powderset.length != 0) {
// let firstSix = powderset.slice(0,6).reverse();
// let powder_hash = 0;
// for (const powder of firstSix) {
// powder_hash = (powder_hash << 5) + 1 + powder; // LSB will be extracted first.
// }
// build_string += Base64.fromIntN(powder_hash, 5);
// powderset = powderset.slice(6);
// }
// }
// }
// this.equipment = [ this.helmet, this.chestplate, this.leggings, this.boots, this.ring1, this.ring2, this.bracelet, this.necklace ];
// let build_string = "3_" + Base64.fromIntN(player_build.helmet.get("id"), 3) +
// Base64.fromIntN(player_build.chestplate.get("id"), 3) +
@ -326,7 +417,7 @@ function encodeBuild() {
function calculateBuild(save_skp, skp){
try {
resetEditableIDs();
if(player_build){
if (player_build) {
reset_powder_specials();
updateBoosts("skip", false);
updatePowderSpecials("skip", false);

View file

@ -13,15 +13,15 @@ tome_mapping = dict()
max_id = 0
for tome in tome_data:
if "tomeID" in tome:
if tome["tomeID"] > max_id:
max_id = tome["tomeID"]
tome_mapping[tome["name"]] = tome["tomeID"]
if "id" in tome:
if tome["id"] > max_id:
max_id = tome["id"]
tome_mapping[tome["name"]] = tome["id"]
i = max_id + 1
for tome in tome_data:
if "tomeID" not in tome:
tome["tomeID"] = i
if "id" not in tome:
tome["id"] = i
tome_mapping[tome["name"]] = i
i += 1

View file

@ -13,7 +13,7 @@
"ref": 6,
"hpBonus": 120,
"fixID": false,
"tomeID": 0
"id": 0
},
{
"name": "Retaliating Tome of Armour Mastery II",
@ -26,7 +26,7 @@
"thorns": 8,
"ref": 8,
"fixID": false,
"tomeID": 1
"id": 1
},
{
"name": "Destructive Tome of Armour Mastery I",
@ -40,7 +40,7 @@
"mdPct": 5,
"hpBonus": 120,
"fixID": false,
"tomeID": 2
"id": 2
},
{
"name": "Destructive Tome of Armour Mastery II",
@ -53,7 +53,7 @@
"thorns": 6,
"reflection": 6,
"fixID": false,
"tomeID": 3
"id": 3
},
{
"name": "Sorcerer's Tome of Armour Mastery I",
@ -66,7 +66,7 @@
"sdPct": 5,
"hpBonus": 120,
"fixID": false,
"tomeID": 4
"id": 4
},
{
"name": "Sorcerer's Tome of Armour Mastery II",
@ -78,7 +78,7 @@
"lvl": 100,
"sdPct": 6,
"fixID": false,
"tomeID": 5
"id": 5
},
{
"name": "Everlasting Tome of Armour Mastery I",
@ -91,7 +91,7 @@
"hprRaw": 15,
"hpBonus": 120,
"fixID": false,
"tomeID": 6
"id": 6
},
{
"name": "Everlasting Tome of Armour Mastery II",
@ -103,7 +103,7 @@
"lvl": 100,
"hprRaw": 60,
"fixID": false,
"tomeID": 7
"id": 7
},
{
"name": "Vampiric Tome of Armour Mastery I",
@ -116,7 +116,7 @@
"ls": 25,
"hpBonus": 120,
"fixID": false,
"tomeID": 8
"id": 8
},
{
"name": "Vampiric Tome of Armour Mastery II",
@ -128,7 +128,7 @@
"lvl": 100,
"ls": 85,
"fixID": false,
"tomeID": 9
"id": 9
},
{
"name": "Greedy Tome of Armour Mastery I",
@ -141,7 +141,7 @@
"lb": 5,
"hpBonus": 120,
"fixID": false,
"tomeID": 10
"id": 10
},
{
"name": "Greedy Tome of Armour Mastery II",
@ -153,7 +153,7 @@
"lvl": 100,
"lb": 6,
"fixID": false,
"tomeID": 11
"id": 11
},
{
"name": "Weightless Tome of Armour Mastery I",
@ -166,7 +166,7 @@
"spd": 5,
"hpBonus": 120,
"fixID": false,
"tomeID": 12
"id": 12
},
{
"name": "Weightless Tome of Armour Mastery II",
@ -178,7 +178,7 @@
"lvl": 100,
"spd": 6,
"fixID": false,
"tomeID": 13
"id": 13
},
{
"name": "Blooming Tome of Armour Mastery II",
@ -191,7 +191,7 @@
"eDefPct": 10,
"hpBonus": 150,
"fixID": false,
"tomeID": 14
"id": 14
},
{
"name": "Pulsing Tome of Armour Mastery II",
@ -204,7 +204,7 @@
"tDefPct": 10,
"hpBonus": 150,
"fixID": false,
"tomeID": 15
"id": 15
},
{
"name": "Oceanic Tome of Armour Mastery II",
@ -217,7 +217,7 @@
"wDefPct": 10,
"hpBonus": 150,
"fixID": false,
"tomeID": 16
"id": 16
},
{
"name": "Courageous Tome of Armour Mastery II",
@ -230,7 +230,7 @@
"fDefPct": 10,
"hpBonus": 150,
"fixID": false,
"tomeID": 17
"id": 17
},
{
"name": "Clouded Tome of Armour Mastery II",
@ -243,7 +243,7 @@
"aDefPct": 10,
"hpBonus": 150,
"fixID": false,
"tomeID": 18
"id": 18
},
{
"name": "Radiant Tome of Armour Mastery II",
@ -260,7 +260,7 @@
"aDefPct": 6,
"hpBonus": 150,
"fixID": false,
"tomeID": 19
"id": 19
},
{
"name": "Tome of Weapon Mastery I",
@ -272,7 +272,7 @@
"lvl": 60,
"dmgMobs": 6,
"fixID": false,
"tomeID": 20
"id": 20
},
{
"name": "Earthbound Tome of Weapon Mastery I",
@ -285,7 +285,7 @@
"dmgMobs": 7,
"str": 3,
"fixID": false,
"tomeID": 21
"id": 21
},
{
"name": "Earthbound Tome of Weapon Mastery II",
@ -298,7 +298,7 @@
"dmgMobs": 8,
"str": 3,
"fixID": false,
"tomeID": 22
"id": 22
},
{
"name": "Nimble Tome of Weapon Mastery I",
@ -311,7 +311,7 @@
"dmgMobs": 7,
"dex": 3,
"fixID": false,
"tomeID": 23
"id": 23
},
{
"name": "Nimble Tome of Weapon Mastery II",
@ -324,7 +324,7 @@
"dmgMobs": 8,
"dex": 3,
"fixID": false,
"tomeID": 24
"id": 24
},
{
"name": "Mystical Tome of Weapon Mastery I",
@ -337,7 +337,7 @@
"dmgMobs": 7,
"int": 3,
"fixID": false,
"tomeID": 25
"id": 25
},
{
"name": "Mystical Tome of Weapon Mastery II",
@ -350,7 +350,7 @@
"dmgMobs": 8,
"int": 3,
"fixID": false,
"tomeID": 26
"id": 26
},
{
"name": "Warding Tome of Weapon Mastery I",
@ -363,7 +363,7 @@
"dmgMobs": 7,
"def": 3,
"fixID": false,
"tomeID": 27
"id": 27
},
{
"name": "Warding Tome of Weapon Mastery II",
@ -376,7 +376,7 @@
"dmgMobs": 8,
"def": 3,
"fixID": false,
"tomeID": 28
"id": 28
},
{
"name": "Athletic Tome of Weapon Mastery I",
@ -389,7 +389,7 @@
"dmgMobs": 7,
"agi": 3,
"fixID": false,
"tomeID": 29
"id": 29
},
{
"name": "Athletic Tome of Weapon Mastery II",
@ -402,7 +402,7 @@
"dmgMobs": 8,
"agi": 3,
"fixID": false,
"tomeID": 30
"id": 30
},
{
"name": "Cosmic Tome of Weapon Mastery I",
@ -419,7 +419,7 @@
"def": 1,
"agi": 1,
"fixID": false,
"tomeID": 31
"id": 31
},
{
"name": "Cosmic Tome of Weapon Mastery II",
@ -436,7 +436,7 @@
"def": 1,
"agi": 1,
"fixID": false,
"tomeID": 32
"id": 32
},
{
"name": "Seismic Tome of Weapon Mastery II",
@ -449,7 +449,7 @@
"dmgMobs": 12,
"eDamPct": 7,
"fixID": false,
"tomeID": 33
"id": 33
},
{
"name": "Voltaic Tome of Weapon Mastery II",
@ -462,7 +462,7 @@
"dmgMobs": 12,
"tDamPct": 7,
"fixID": false,
"tomeID": 34
"id": 34
},
{
"name": "Abyssal Tome of Weapon Mastery II",
@ -475,7 +475,7 @@
"dmgMobs": 12,
"wDamPct": 7,
"fixID": false,
"tomeID": 35
"id": 35
},
{
"name": "Infernal Tome of Weapon Mastery II",
@ -488,7 +488,7 @@
"dmgMobs": 12,
"fDamPct": 7,
"fixID": false,
"tomeID": 36
"id": 36
},
{
"name": "Cyclonic Tome of Weapon Mastery II",
@ -501,7 +501,7 @@
"dmgMobs": 12,
"aDamPct": 7,
"fixID": false,
"tomeID": 37
"id": 37
},
{
"name": "Astral Tome of Weapon Mastery II",
@ -518,7 +518,7 @@
"fDamPct": 6,
"aDamPct": 6,
"fixID": false,
"tomeID": 38
"id": 38
},
{
"name": "Brute's Tome of Allegiance",
@ -531,7 +531,7 @@
"str": 3,
"eDamPct": 2,
"fixID": false,
"tomeID": 39
"id": 39
},
{
"name": "Sadist's Tome of Allegiance",
@ -544,7 +544,7 @@
"dex": 3,
"tDamPct": 2,
"fixID": false,
"tomeID": 40
"id": 40
},
{
"name": "Mastermind's Tome of Allegiance",
@ -557,7 +557,7 @@
"int": 3,
"wDamPct": 2,
"fixID": false,
"tomeID": 41
"id": 41
},
{
"name": "Arsonist's Tome of Allegiance",
@ -570,7 +570,7 @@
"def": 3,
"fDamPct": 2,
"fixID": false,
"tomeID": 42
"id": 42
},
{
"name": "Ghost's Tome of Allegiance",
@ -583,7 +583,7 @@
"agi": 3,
"aDamPct": 2,
"fixID": false,
"tomeID": 43
"id": 43
},
{
"name": "Psychopath's Tome of Allegiance",
@ -596,7 +596,7 @@
"str": 2,
"dex": 2,
"fixID": false,
"tomeID": 44
"id": 44
},
{
"name": "Loner's Tome of Allegiance",
@ -609,7 +609,7 @@
"str": 2,
"int": 2,
"fixID": false,
"tomeID": 45
"id": 45
},
{
"name": "Warlock's Tome of Allegiance",
@ -622,7 +622,7 @@
"dex": 2,
"int": 2,
"fixID": false,
"tomeID": 46
"id": 46
},
{
"name": "Destroyer's Tome of Allegiance",
@ -635,7 +635,7 @@
"str": 2,
"def": 2,
"fixID": false,
"tomeID": 47
"id": 47
},
{
"name": "Devil's Tome of Allegiance",
@ -648,7 +648,7 @@
"dex": 2,
"def": 2,
"fixID": false,
"tomeID": 48
"id": 48
},
{
"name": "Alchemist's Tome of Allegiance",
@ -661,7 +661,7 @@
"int": 2,
"def": 2,
"fixID": false,
"tomeID": 49
"id": 49
},
{
"name": "Barbarian's Tome of Allegiance",
@ -674,7 +674,7 @@
"str": 2,
"agi": 2,
"fixID": false,
"tomeID": 50
"id": 50
},
{
"name": "Freelancer's Tome of Allegiance",
@ -687,7 +687,7 @@
"dex": 2,
"agi": 2,
"fixID": false,
"tomeID": 51
"id": 51
},
{
"name": "Sycophant's Tome of Allegiance",
@ -700,7 +700,7 @@
"int": 2,
"agi": 2,
"fixID": false,
"tomeID": 52
"id": 52
},
{
"name": "Fanatic's Tome of Allegiance",
@ -713,7 +713,7 @@
"def": 2,
"agi": 2,
"fixID": false,
"tomeID": 53
"id": 53
},
{
"name": "Assimilator's Tome of Allegiance",
@ -729,7 +729,7 @@
"def": 1,
"agi": 1,
"fixID": false,
"tomeID": 54
"id": 54
}
]
}