Merge branch 'dev' of https://github.com/hppeng-wynn/hppeng-wynn.github.io into dev
This commit is contained in:
commit
48554a5e36
3 changed files with 37 additions and 26 deletions
|
@ -30,7 +30,11 @@ function encodeCustom(custom, verbose) {
|
|||
if (rolledIDs.includes(id)) {
|
||||
let val_min = custom.get("minRolls").has(id) ? custom.get("minRolls").get(id) : 0;
|
||||
let val_max = custom.get("maxRolls").has(id) ? custom.get("maxRolls").get(id) : 0;
|
||||
let sign = (Boolean(val_min / Math.abs(val_min) < 0) | 0) + 2*(Boolean(val_max / Math.abs(val_max) < 0) | 0) // 0 - both pos 1 - min neg max pos 2 - min pos max neg (how?) 3 - min neg max neg
|
||||
// 0 - both pos
|
||||
// 1 - min neg max pos
|
||||
// 2 - min pos max neg (how?)
|
||||
// 3 - min neg max neg
|
||||
let sign = (Boolean(val_min / Math.abs(val_min) < 0) | 0) + 2*(Boolean(val_max / Math.abs(val_max) < 0) | 0);
|
||||
//console.log(id + ": " + sign);
|
||||
let min_len = Math.max(1,Math.ceil(log(64,Math.abs(val_min)+1)));
|
||||
let max_len = Math.max(1,Math.ceil(log(64,Math.abs(val_max)+1)));
|
||||
|
@ -38,9 +42,7 @@ function encodeCustom(custom, verbose) {
|
|||
val_min = Math.abs(val_min);
|
||||
val_max = Math.abs(val_max);
|
||||
|
||||
|
||||
if ( val_min != 0 || val_max != 0 ) {
|
||||
//hash += Base64.fromIntN(i,2) + Base64.fromIntN(val_min,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + ":" + Base64.fromIntN(val_max,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + "_";
|
||||
if (custom.get("fixID")) {
|
||||
hash += Base64.fromIntN(i,2) + Base64.fromIntN(len,2) + sign + Base64.fromIntN(val_min, len);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* Apply armor powdering.
|
||||
* Applies twice for crafted items because wynn.
|
||||
* Also for jeweling for crafted items.
|
||||
*/
|
||||
function applyArmorPowders(expandedItem, powders) {
|
||||
|
@ -8,32 +9,42 @@ function applyArmorPowders(expandedItem, powders) {
|
|||
applyArmorPowdersOnce(expandedItem, powders);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply armor powders once only.
|
||||
* Encoding shortcut assumes that all powders give +def to one element
|
||||
* and -def to the element "behind" it in cycle ETWFA, which is true
|
||||
* as of now and unlikely to change in the near future.
|
||||
*/
|
||||
function applyArmorPowdersOnce(expandedItem, powders) {
|
||||
for(const id of powders){
|
||||
let powder = powderStats[id];
|
||||
let name = powderNames.get(id);
|
||||
expandedItem.set(name.charAt(0) + "Def", (expandedItem.get(name.charAt(0)+"Def") || 0) + powder["defPlus"]);
|
||||
expandedItem.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (expandedItem.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]);
|
||||
let name = powderNames.get(id).charAt(0);
|
||||
let prevName = skp_elements[(skp_elements.indexOf(name) + 4 )% 5];
|
||||
expandedItem.set(name+"Def", (expandedItem.get(name+"Def") || 0) + powder["defPlus"]);
|
||||
expandedItem.set(prevName+"Def", (expandedItem.get(prevName+"Def") || 0) - powder["defMinus"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an item with id list and turn it into a set of minrolls and maxrolls.
|
||||
* Also applies powders to armor.
|
||||
*/
|
||||
function expandItem(item, powders) {
|
||||
let minRolls = new Map();
|
||||
let maxRolls = new Map();
|
||||
let expandedItem = new Map();
|
||||
if(item.fixID){ //The item has fixed IDs.
|
||||
if (item.fixID) { //The item has fixed IDs.
|
||||
expandedItem.set("fixID",true);
|
||||
for (const id of rolledIDs){ //all rolled IDs are numerical
|
||||
for (const id of rolledIDs) { //all rolled IDs are numerical
|
||||
let val = (item[id] || 0);
|
||||
//if(item[id]) {
|
||||
minRolls.set(id,val);
|
||||
maxRolls.set(id,val);
|
||||
//}
|
||||
}
|
||||
}else{ //The item does not have fixed IDs.
|
||||
for (const id of rolledIDs){
|
||||
} else { //The item does not have fixed IDs.
|
||||
for (const id of rolledIDs) {
|
||||
let val = (item[id] || 0);
|
||||
if(val > 0){ // positive rolled IDs
|
||||
if (val > 0) { // positive rolled IDs
|
||||
if (reversedIDs.includes(id)) {
|
||||
maxRolls.set(id,idRound(val*0.3));
|
||||
minRolls.set(id,idRound(val*1.3));
|
||||
|
@ -41,28 +52,25 @@ function expandItem(item, powders) {
|
|||
maxRolls.set(id,idRound(val*1.3));
|
||||
minRolls.set(id,idRound(val*0.3));
|
||||
}
|
||||
}else if(val < 0){ //negative rolled IDs
|
||||
} else if (val <= 0) { //negative rolled IDs
|
||||
if (reversedIDs.includes(id)) {
|
||||
maxRolls.set(id,idRound(val*1.3));
|
||||
minRolls.set(id,idRound(val*0.7));
|
||||
}
|
||||
else {
|
||||
minRolls.set(id,idRound(val*1.3));
|
||||
maxRolls.set(id,idRound(val*0.7));
|
||||
}
|
||||
}else{//Id = 0
|
||||
minRolls.set(id,0);
|
||||
maxRolls.set(id,0);
|
||||
minRolls.set(id,idRound(val*1.3));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const id of nonRolledIDs){
|
||||
}
|
||||
for (const id of nonRolledIDs) {
|
||||
expandedItem.set(id,item[id]);
|
||||
}
|
||||
expandedItem.set("minRolls",minRolls);
|
||||
expandedItem.set("maxRolls",maxRolls);
|
||||
expandedItem.set("powders", powders);
|
||||
if(item.category === "armor") {
|
||||
if (item.category === "armor") {
|
||||
applyArmorPowders(expandedItem, powders);
|
||||
}
|
||||
return expandedItem;
|
||||
|
|
|
@ -53,7 +53,11 @@ async function load_local(init_func) {
|
|||
}
|
||||
|
||||
/*
|
||||
* Clean bad item data. For now just assigns display name if it isn't already assigned.
|
||||
* Clean bad item data.
|
||||
* Assigns `displayName` to equal `name` if it is undefined.
|
||||
* String values default to empty string.
|
||||
* Numeric values default to 0.
|
||||
* Major ID defaults to empty list.
|
||||
*/
|
||||
function clean_item(item) {
|
||||
if (item.remapID === undefined) {
|
||||
|
@ -68,9 +72,6 @@ function clean_item(item) {
|
|||
if (item.skillpoints[i] === undefined) { item.skillpoints[i] = 0; }
|
||||
if (item.skillpoints[i] < 0) { item.has_negstat = true; }
|
||||
}
|
||||
if (item.slots === undefined) {
|
||||
item.slots = 0
|
||||
}
|
||||
for (let key of item_fields) {
|
||||
if (item[key] === undefined) {
|
||||
if (key in str_item_fields) {
|
||||
|
|
Loading…
Reference in a new issue