refactor: Removed copies of functions

This commit is contained in:
reschan 2021-10-18 07:25:02 +07:00
parent e51f1ef92b
commit 4e0342f213
8 changed files with 74 additions and 1556 deletions

View file

@ -689,15 +689,6 @@
</div>
</div>
</div>
<div id="drag-spell-boost" style="display: none;">
<div class="externalBuffs hide-container-block" id="buff-box" style="display: none;">
<div class = "powder-specials" style="display: none;">
<div class = "powder-special-stats" style = "grid-column:1;grid-row:1">
</div>
</div>
</div>
</div>
<div id="drag-full-eqs" style="display: none;">
<div class = "build hide-container-grid" style="display: none;">
<div class = "center build-order" id = "build-order" style = "grid-item-10">
@ -1144,8 +1135,13 @@
<script type="text/javascript" src="powders.js"></script>
<script type="text/javascript" src="skillpoints.js"></script>
<script type="text/javascript" src="damage_calc.js"></script>
<script type="text/javascript" src="sq2display_constants.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="sq2display.js"></script>
<script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="/query.js"></script>
<script type="text/javascript" src="load.js"></script>
<script type="text/javascript" src="load_ing.js"></script>

65
sq2.js
View file

@ -51,53 +51,72 @@ $(document).ready(function(){
// set search style
$("#weapon-choice").on('input', function(){
set_input_style('weapon');
check_item($("#weapon-choice").val());
update_powder_count('weapon');
setTimeout(function() {
set_input_style('weapon');
check_item($("#weapon-choice").val());
update_powder_count('weapon');
}, 500);
});
$("#helmet-choice").on('input', function(){
set_input_style('helmet');
check_item($("#helmet-choice").val());
update_powder_count('helmet', '|example: t6t6');
setTimeout(function() {
set_input_style('helmet');
check_item($("#helmet-choice").val());
update_powder_count('helmet', '|example: t6t6');
}, 500);
});
$("#chestplate-choice").on('input', function(){
set_input_style('chestplate');
check_item($("#chestplate-choice").val());
update_powder_count('chestplate');
setTimeout(function() {
set_input_style('chestplate');
check_item($("#chestplate-choice").val());
update_powder_count('chestplate');
}, 500);
});
$("#leggings-choice").on('input', function(){
set_input_style('leggings');
check_item($("#leggings-choice").val());
update_powder_count('leggings');
setTimeout(function() {
set_input_style('leggings');
check_item($("#leggings-choice").val());
update_powder_count('leggings');
}, 500);
});
$("#boots-choice").on('input', function(){
set_input_style('boots');
check_item($("#boots-choice").val());
update_powder_count('boots');
setTimeout(function() {
set_input_style('boots');
check_item($("#boots-choice").val());
update_powder_count('boots');
}, 500);
});
$("#ring1-choice").on('input', function(){
set_input_style('ring1');
check_item($("#ring1-choice").val());
setTimeout(function() {
set_input_style('ring1');
check_item($("#ring1-choice").val());
}, 500);
});
$("#ring2-choice").on('input', function(){
set_input_style('ring2');
check_item($("#ring2-choice").val());
setTimeout(function() {
set_input_style('ring2');
check_item($("#ring2-choice").val());
}, 500);
});
$("#bracelet-choice").on('input', function(){
set_input_style('bracelet');
check_item($("#bracelet-choice").val());
setTimeout(function() {
set_input_style('bracelet');
check_item($("#bracelet-choice").val());
}, 500);
});
$("#necklace-choice").on('input', function(){
set_input_style('necklace');
check_item($("#necklace-choice").val());
setTimeout(function() {
set_input_style('necklace');
check_item($("#necklace-choice").val());
}, 500);
});
// control vars

View file

@ -299,17 +299,10 @@ class Build{
errors.push(new ItemNotFound(equipment[7], "necklace", true));
}
}
if(itemMap.get(equipment[8]) && itemMap.get(equipment[8]).category === "weapon") {
const weapon = itemMap.get(equipment[8]);
this.powders[4] = this.powders[4].slice(0,weapon.slots);
this.weapon = expandItem(weapon, this.powders[4]);
/*
if (equipment[8] !== "No Weapon") {
document.getElementsByClassName("powder-specials")[0].style.display = "grid";
} else {
document.getElementsByClassName("powder-specials")[0].style.display = "none";
}*/
}else{
try {
let weapon = getCustomFromHash(equipment[8]) ? getCustomFromHash(equipment[8]) : (getCraftFromHash(equipment[8]) ? getCraftFromHash(equipment[8]) : undefined);

View file

@ -830,29 +830,29 @@ function calculateBuildStats() {
}
for (let i in player_build.items) {
displayExpandedItem(player_build.items[i], buildFields[i], true);
displaysq2ExpandedItem(player_build.items[i], buildFields[i], true);
}
displayWeaponBase(player_build);
displayArmorStats(player_build);
displayMinimalBuildStats("all-stats", player_build, build_overall_display_commands);
displaysq2WeaponBase(player_build);
displaysq2ArmorStats(player_build);
displayMinimalBuildStats("all-stats", player_build, build_all_display_commands);
displayMinimalBuildStats("minimal-stats", player_build, build_basic_display_commands);
displayMinimalBuildStats("minimal-offensive-stats",player_build, build_offensive_display_commands);
displaySetBonuses("set-info",player_build);
displayNextCosts("int-info",player_build);
let meleeStats = player_build.getMeleeStats();
displayMeleeDamage(document.getElementById("build-melee-stats"), document.getElementById("build-melee-statsAvg"), meleeStats);
displaysq2MeleeDamage(document.getElementById("build-melee-stats"), document.getElementById("build-melee-statsAvg"), meleeStats);
displayDefenseStats(document.getElementById("minimal-defensive-stats"),player_build);
displaysq2DefenseStats(document.getElementById("minimal-defensive-stats"),player_build);
displayPoisonDamage(document.getElementById("build-poison-stats"),player_build);
displaysq2PoisonDamage(document.getElementById("build-poison-stats"),player_build);
let spells = spell_table[player_build.weapon.get("type")];
for (let i = 0; i < 4; ++i) {
let parent_elem = document.getElementById("spell"+i+"-info");
let overallparent_elem = document.getElementById("spell"+i+"-infoAvg");
displaySpellDamage(parent_elem, overallparent_elem, player_build, spells[i], i+1);
displaysq2SpellDamage(parent_elem, overallparent_elem, player_build, spells[i], i+1);
}
location.hash = encodeBuild();

File diff suppressed because it is too large Load diff

View file

@ -1,311 +1,7 @@
let nonRolledIDs = [
"name",
"lore",
"displayName",
"tier",
"set",
"slots",
"type",
"material",
"drop",
"quest",
"restrict",
"nDam",
"fDam",
"wDam",
"aDam",
"tDam",
"eDam",
"atkSpd",
"hp",
"fDef",
"wDef",
"aDef",
"tDef",
"eDef",
"lvl",
"classReq",
"strReq",
"dexReq",
"intReq",
"defReq",
"agiReq","str",
"dex",
"int",
"agi",
"def",
"fixID",
"category",
"id",
"skillpoints",
"reqs",
"nDam_",
"fDam_",
"wDam_",
"aDam_",
"tDam_",
"eDam_",
"majorIds"];
let rolledIDs = [
"hprPct",
"mr",
"sdPct",
"mdPct",
"ls",
"ms",
"xpb",
"lb",
"ref",
"thorns",
"expd",
"spd",
"atkTier",
"poison",
"hpBonus",
"spRegen",
"eSteal",
"hprRaw",
"sdRaw",
"mdRaw",
"fDamPct",
"wDamPct",
"aDamPct",
"tDamPct",
"eDamPct",
"fDefPct",
"wDefPct",
"aDefPct",
"tDefPct",
"eDefPct",
"spPct1",
"spRaw1",
"spPct2",
"spRaw2",
"spPct3",
"spRaw3",
"spPct4",
"spRaw4",
"rainbowRaw",
"sprint",
"sprintReg",
"jh",
"lq",
"gXp",
"gSpd"
];
let reversedIDs = [ "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ];
let colorMap = new Map(
[
["Normal", "#fff"],
["Unique", "#ff5"],
["Rare","#f5f"],
["Legendary","#5ff"],
["Fabled","#f55"],
["Mythic","#a0a"],
["Crafted","#0aa"],
["Custom","#0aa"],
["Set","#5f5"]
]
);
let idPrefixes = {"displayName": "",
"lvl":"Combat Level Min: ",
"classReq":"Class Req: ",
"strReq":"Strength Min: ",
"dexReq":"Dexterity Min: ",
"intReq":"Intelligence Min: ",
"defReq":"Defense Min: ",
"agiReq":"Agility Min: ",
"nDam_":"Neutral Damage: ",
"eDam_":"Earth Damage: ",
"tDam_":"Thunder Damage: ",
"wDam_":"Water Damage: ",
"fDam_":"Fire Damage: ",
"aDam_":"Air Damage: ",
"atkSpd":"Attack Speed: ",
"hp":"Health : ",
"eDef":"Earth Defense: ",
"tDef":"Thunder Defense: ",
"wDef":"Water Defense: ",
"fDef":"Fire Defense: ",
"aDef":"Air Defense: ",
"str":"Strength: ",
"dex":"Dexterity: ",
"int":"Intelligence: ",
"def":"Defense: ","agi":"Agility: ",
"hpBonus":"Health Bonus: ",
"hprRaw":"Health Regen Raw: ",
"hprPct":"Health Regen %: ",
"sdRaw":"Raw Spell Damage: ",
"sdPct":"Spell Damage %: ",
"mdRaw":"Raw Melee Damage: ",
"mdPct":"Melee Damage %: ",
"mr":"Mana Regen: ",
"ms":"Mana Steal: ",
"ref":"Reflection: ",
"ls":"Life Steal: ",
"poison":"Poison: ",
"thorns":"Thorns: ",
"expd":"Exploding: ",
"spd":"Walk Speed Bonus: ",
"atkTier":"Attack Speed Bonus: ",
"eDamPct":"Earth Damage %: ",
"tDamPct":"Thunder Damage %: ",
"wDamPct":"Water Damage %: ",
"fDamPct":"Fire Damage %: ",
"aDamPct":"Air Damage %: ",
"eDefPct":"Earth Defense %: ",
"tDefPct":"Thunder Defense %: ",
"wDefPct":"Water Defense %: ",
"fDefPct":"Fire Defense %: ",
"aDefPct":"Air Defense %: ",
"spPct1":"1st Spell Cost %: ",
"spRaw1":"1st Spell Cost Raw: ",
"spPct2":"2nd Spell Cost %: ",
"spRaw2":"2nd Spell Cost Raw: ",
"spPct3":"3rd Spell Cost %: ",
"spRaw3":"3rd Spell Cost Raw: ",
"spPct4":"4th Spell Cost %: ",
"spRaw4":"4th Spell Cost Raw: ",
"rainbowRaw":"Rainbow Spell Damage Raw: ",
"sprint":"Sprint Bonus: ",
"sprintReg":"Sprint Regen Bonus: ",
"jh":"Jump Height: ",
"xpb":"Combat XP Bonus: ",
"lb":"Loot Bonus: ",
"lq":"Loot Quality: ",
"spRegen":"Soul Point Regen: ",
"eSteal":"Stealing: ",
"gXp":"Gathering XP Bonus: ",
"gSpd":"Gathering Speed Bonus: ",
"slots":"Powder Slots: ",
"set":"Set: ",
"quest":"Quest Req: ",
"restrict":"",
"lore": ""
};
let idSuffixes = {"displayName": "",
"lvl":"",
"classReq":"",
"strReq":"",
"dexReq":"",
"intReq":"",
"defReq":"",
"agiReq":"",
"nDam_":"",
"eDam_":"",
"tDam_":"",
"wDam_":"",
"fDam_":"",
"aDam_":"",
"atkSpd":"",
"hp":"",
"eDef":"",
"tDef":"",
"wDef":"",
"fDef":"",
"aDef":"",
"str":"",
"dex":"",
"int":"",
"def":"",
"agi":"",
"hpBonus":"",
"hprRaw":"",
"hprPct":"%",
"sdRaw":"",
"sdPct":"%",
"mdRaw":"",
"mdPct":"%",
"mr":"/5s",
"ms":"/3s",
"ref":"%",
"ls":"/3s",
"poison":"/3s",
"thorns":"%",
"expd":"%",
"spd":"%",
"atkTier":" tier",
"eDamPct":"%",
"tDamPct":"%",
"wDamPct":"%",
"fDamPct":"%",
"aDamPct":"%",
"eDefPct":"%",
"tDefPct":"%",
"wDefPct":"%",
"fDefPct":"%",
"aDefPct":"%",
"spPct1":"%",
"spRaw1":"",
"spPct2":"%",
"spRaw2":"",
"spPct3":"%",
"spRaw3":"",
"spPct4":"%",
"spRaw4":"",
"rainbowRaw":"",
"sprint":"%",
"sprintReg":"%",
"jh":"",
"xpb":"%",
"lb":"%",
"lq":"%",
"spRegen":"%",
"eSteal":"%",
"gXp":"%",
"gSpd":"%",
"slots":"",
"set":" set.",
"quest":"",
"restrict":"",
"lore": ""
};
//Used for item IDs and ingredient id field IDs
//Used for ingredient IDs - name, lvl, tier. As of now, not used.
/*let ingPrefixes = {"name": "", "lvl": "", "tier": ""};
let ingSuffixes = {"name": "", "lvl": "", "tier": ""}*/
//Used for ingredient consumableIDs
let consumableIDPrefixes = {
"charges": "Charges: ",
"dura": "Duration: "
}
let consumableIDSuffixes = {
"charges": "",
"dura": " sec."
}
//Used for ingredient itemIDs
let itemIDPrefixes = {
"dura": "Durability: ",
"strReq": "Strength Min: ",
"dexReq": "Dexterity Min: ",
"intReq": "Intelligence Min: ",
"defReq": "Defense Min: ",
"agiReq": "Agility Min: "
}
//Used for ingredient posMods IDs
let posModPrefixes = {
"left":"Effectiveness Left: ",
"right":"EFfectiveness Right: ",
"above":"Effectiveness Above: ",
"under":"Effectiveness Under: ",
"touching":"EFfectiveness Touching: ",
"notTouching":"Effectiveness Not Touching: "
}
let posModSuffixes = {
"left":"%",
"right":"%",
"above":"%",
"under":"%",
"touching":"%",
"notTouching":"%"
}
/*
* Display commands
*/
let build_overall_display_commands = [
let build_all_display_commands = [
"#table",
"#defense-stats",
"str", "dex", "int", "def", "agi",
@ -366,54 +62,3 @@ let build_basic_display_commands = [
"atkTier",
]
let item_display_commands = [
"#cdiv",
"displayName",
//"type", //REPLACE THIS WITH SKIN
"#ldiv",
"atkSpd",
"#ldiv",
"!elemental",
"hp",
"nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_",
"fDef", "wDef", "aDef", "tDef", "eDef",
"!elemental",
"#ldiv",
"classReq",
"lvl",
"strReq", "dexReq", "intReq", "defReq","agiReq",
"#ldiv",
"str", "dex", "int", "def", "agi",
"#table",
"str", "dex", "int", "def", "agi", //jank lmao
"hpBonus",
"hprRaw", "hprPct",
"sdRaw", "sdPct",
"mdRaw", "mdPct",
"mr", "ms",
"ref", "thorns",
"ls",
"poison",
"expd",
"spd",
"atkTier",
"!elemental",
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
"fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw",
"sprint", "sprintReg",
"jh",
"xpb", "lb", "lq",
"spRegen",
"eSteal",
"gXp", "gSpd",
"#ldiv",
"majorIds",
"slots",
"set",
"lore",
"quest",
"restrict"
];

View file

@ -4,35 +4,3 @@ console.log(window_storage);
icon_state_stored = window_storage.getItem("newicons");
newIcons = true;
if (icon_state_stored === "false") {toggleIcons()}
//REMOVE THIS IN THE REAL VERSION 7 OR SOMETHING
window_storage.removeItem("rick");
/** Toggle icons on the ENTIRE page.
*
*/
/*
function toggleIcons() {
newIcons = !newIcons;
let imgs = document.getElementsByTagName("IMG");
let favicon = document.querySelector("link[rel~='icon']");
let toggleiconbutton = document.getElementById("toggle-icon-button");
if (newIcons) { //switch to new
favicon.href = favicon.href.replace("media/icons/old","media/icons/new");
for (const img of imgs) {
if (img.src.includes("media/icons/old")) {img.src = img.src.replace("media/icons/old","media/icons/new");}
if (img.src.includes("media/items/old")) {img.src = img.src.replace("media/items/old","media/items/new");}
}
toggleiconbutton.textContent = "Use Old Icons";
window_storage.setItem("newicons","true");
} else { //switch to old
favicon.href = favicon.href.replace("media/icons/new","media/icons/old");
for (const img of imgs) {
if (img.src.includes("media/icons/new")) {img.src = img.src.replace("media/icons/new","media/icons/old");}
if (img.src.includes("media/items/new")) {img.src = img.src.replace("media/items/new","media/items/old");}
}
toggleiconbutton.textContent = "Use New Icons";
window_storage.setItem("newicons","false");
}
}*/

View file

@ -143,7 +143,6 @@ function doItemSearch() {
queries.push(new NameQuery(document.getElementById("name-choice").value.trim()));
let categoryOrType = document.getElementById("category-choice").value;
console.log("category: "+categoryOrType)
if (itemTypes.includes(categoryOrType)) {
queries.push(new IdMatchQuery("type", categoryOrType));
}
@ -188,8 +187,6 @@ function doItemSearch() {
console.log(items_copy.length);
}
// document.getElementById("summary").textContent = items_copy.length + " results."
console.log('a')
console.log(items_copy);
displayItems(items_copy);
}