diff --git a/static/filterWeapons.js b/static/filterWeapons.js index fbc022f..969bffb 100644 --- a/static/filterWeapons.js +++ b/static/filterWeapons.js @@ -39,14 +39,14 @@ function updateWeaponStats(weapon) { const statsElement = document.getElementById('weapon-stats'); statsElement.innerHTML = `

Name: ${weapon.name}

-

Damage: ${weapon.damage}

+

Damage: ${weapon.damage * weapon.damage_multiplier}

RPM: ${weapon.rpm}

Mag Size: ${weapon.mag_size}

Reload Time: ${weapon.reload_time}

`; // Store values for further calculations - const damage = weapon.damage; + const damage = weapon.damage * weapon.damage_multiplier; const rpm = weapon.rpm; const magSize = weapon.mag_size; const reloadTime = weapon.reload_time; @@ -70,26 +70,34 @@ function populateModifiers(modifiers) { const modifiersContainer = document.getElementById('modifiers'); const createModifierSection = (title, modifierList) => { - const section = document.createElement('div'); - const header = document.createElement('h3'); - header.textContent = title; - section.appendChild(header); + const section = document.createElement('div'); + const header = document.createElement('h3'); + header.textContent = title; + section.appendChild(header); - modifierList.forEach(mod => { - const label = document.createElement('label'); - const input = document.createElement('input'); - input.type = 'checkbox'; - input.id = mod.id; + modifierList.forEach(mod => { + const label = document.createElement('label'); + const input = document.createElement('input'); + input.type = 'checkbox'; + input.id = mod.id; + + // Check if the modifier has multiple buffs + if (mod.buffs) { + input.dataset.buffs = JSON.stringify(mod.buffs); // Store buffs data as a string in data-buffs + } else { input.value = mod.value; input.dataset.type = mod.type; // Store if it's additive or multiplicative - label.appendChild(input); - label.appendChild(document.createTextNode(mod.label)); - section.appendChild(label); - section.appendChild(document.createElement('br')); - }); + } + + label.appendChild(input); + label.appendChild(document.createTextNode(mod.label)); + section.appendChild(label); + section.appendChild(document.createElement('br')); + }); + + return section; +}; - return section; - }; // Clear any existing modifiers modifiersContainer.innerHTML = ''; @@ -114,41 +122,51 @@ function applyModifiers() { if (!selectedWeapon) return; // Get the base stats from the selected weapon - let baseDamage = selectedWeapon.damage; + let baseDamage = selectedWeapon.damage * selectedWeapon.damage_multiplier; let baseRpm = selectedWeapon.rpm; let baseReloadTime = selectedWeapon.reload_time; // Initialize the modifier objects - let damageModifier = {additive: 0, multiplicative: 1, flat: 0}; - let rpmModifier = {additive: 0, multiplicative: 1}; - let reloadTimeModifier = {additive: 0, multiplicative: 1}; + let damageModifier = { additive: 0, multiplicative: 1 }; + let rpmModifier = { additive: 0, multiplicative: 1 }; + let reloadTimeModifier = { additive: 0, multiplicative: 1 }; // Collect checked modifier values document.querySelectorAll('#modifiers input:checked').forEach(mod => { const modType = mod.dataset.type; const modValue = parseFloat(mod.value); - // Apply damage modifiers - if (mod.id.includes('damage')) { - if (modType === 'multiplicative') damageModifier.multiplicative *= modValue; // Multiplicative - else if (modType === 'additive') damageModifier.additive += modValue; // Additive - } - // Apply RPM modifiers - if (mod.id.includes('rpm')) { - if (modType === 'multiplicative') rpmModifier.multiplicative *= modValue; - else if (modType === 'additive') rpmModifier.additive += modValue; - } + // Handle multi-buff modifiers (like Bloxy Cola or Firefight) + if (mod.dataset.buffs) { + const buffs = JSON.parse(mod.dataset.buffs); // Parse buffs data from the data-buffs attribute + buffs.forEach(buff => { + // Apply each buff + applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier); + }); + } else { + // Handle single-buff modifiers + const singleBuff = { + type: modType === 'multiplicative' ? 'multiplicative' : 'additive', // Use the proper modifier type + buffType: modType, + value: modValue + }; - // Apply Reload Time modifiers - if (mod.id.includes('reloadTime')) { - if (modType === 'multiplicative') reloadTimeModifier.multiplicative *= modValue; - else if (modType === 'additive') reloadTimeModifier.additive += modValue; + if (mod.id.includes('damage')) { + singleBuff.type = 'damage'; // This mod applies to damage + } else if (mod.id.includes('rpm')) { + singleBuff.type = 'rpm'; // This mod applies to RPM + } else if (mod.id.includes('reload')) { + singleBuff.type = 'reloadTime'; // This mod applies to reload time + } + + // Apply the single buff + applyBuff(singleBuff, rpmModifier, reloadTimeModifier, damageModifier); } }); // Apply the damage modifiers - let damage = baseDamage * damageModifier.multiplicative; // First apply multiplicative modifiers// Then apply percentage-based additive modifiers - damage += damageModifier.additive; // Finally, add the flat additive modifier (e.g., HE Rounds) + let damage = baseDamage * damageModifier.multiplicative; // First apply multiplicative modifiers + damage += damageModifier.additive; // Then apply percentage-based additive modifiers // Apply the RPM modifiers let rpm = baseRpm * rpmModifier.multiplicative; @@ -165,6 +183,30 @@ function applyModifiers() { updateModifiedWeaponStats(damage, rpm, reloadTime); } + + +// Helper function to apply individual buffs +function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier = null) { + const { type, buffType, value } = buff; + + // Apply buffs based on type + if (type === 'rpm') { + if (buffType === 'multiplicative') rpmModifier.multiplicative *= value; + else if (buffType === 'additive') rpmModifier.additive += value; + } + + if (type === 'reloadTime') { + if (buffType === 'multiplicative') reloadTimeModifier.multiplicative *= value; + else if (buffType === 'additive') reloadTimeModifier.additive += value; + } + + // Apply damage buffs + if (type === 'damage' && damageModifier) { + if (buffType === 'multiplicative') damageModifier.multiplicative *= value; + else if (buffType === 'additive') damageModifier.additive += value; + } +} + // Function to calculate DPS and DPM with optional modifiers function calculateDPSAndDPM(damage, rpm, magSize, reloadTime) { const rps = rpm / 60; // Rounds per second diff --git a/static/modifiers.json b/static/modifiers.json index 61546df..55783a4 100644 --- a/static/modifiers.json +++ b/static/modifiers.json @@ -1,31 +1,31 @@ { "itemBuffs": [ { - "id": "damage-item-additive", + "id": "damage-item-additive-elite-he-rounds", "label": "Elite HE Rounds (+14 damage)", "value": 14, "type": "additive" }, { - "id": "damage-item-additive", + "id": "damage-item-additive-he-rounds", "label": "HE Rounds (+8 damage)", "value": 8, "type": "additive" }, { - "id": "damage-item-multiplicative", + "id": "damage-item-multiplicative-strength-mixture", "label": "Strength Mixture (+20% damage)", "value": 1.2, "type": "multiplicative" }, { - "id": "damage-item-multiplicative", + "id": "damage-item-multiplicative-fortunos-necklace", "label": "Fortunos Necklace (+15% damage)", "value": 1.15, "type": "multiplicative" }, { - "id": "multiple-buffs", + "id": "multiple-buffs-bloxy-cola", "label": "Bloxy Cola (+25% Firerate, +100% Reload Speed)", "buffs": [ { @@ -41,13 +41,13 @@ ] }, { - "id": "damage-item-multiplicative", + "id": "damage-item-multiplicative-enhancer", "label": "Enhancer (+10% damage)", "value": 1.1, "type": "multiplicative" }, { - "id": "damage-item-multiplicative", + "id": "damage-item-multiplicative-teleport-device", "label": "Teleport Device (+25% damage)", "value": 1.25, "type": "multiplicative" @@ -55,77 +55,73 @@ ], "operativePerks": [ { - "id": "damage-perk-additive", - "label": "Operative Damage Additive +15%", - "value": 0.15, - "type": "additive" - }, - { - "id": "damage-perk-multiplicative", - "label": "Operative Damage Multiplicative +30%", - "value": 1.3, - "type": "multiplicative" - }, - { - "id": "rpm-perk-additive", - "label": "Operative RPM Additive +10%", - "value": 0.1, - "type": "additive" - }, - { - "id": "rpm-perk-multiplicative", - "label": "Operative RPM Multiplicative +20%", - "value": 1.2, - "type": "multiplicative" - }, - { - "id": "reloadTime-perk-additive", - "label": "Operative Reload Time Additive -10%", - "value": -0.1, - "type": "additive" - }, - { - "id": "reloadTime-perk-multiplicative", - "label": "Operative Reload Time Multiplicative -20%", - "value": 0.8, + "id": "damage-perk-multiplicative-fbi-badge", + "label": "FBI Badge (+10% Damage)", + "value": 1.1, "type": "multiplicative" } ], "abilityPerks": [ { - "id": "damage-ability-additive", - "label": "Ability Damage Additive +20%", - "value": 0.2, - "type": "additive" + "id": "multiple-buffs-firefight", + "label": "[Heath] Firefight (+35% Damage, +40% Reload Speed)", + "buffs": [ + { + "type": "damage", + "value": 1.35, + "buffType": "multiplicative" + }, + { + "type": "reloadTime", + "value": 0.6, + "buffType": "multiplicative" + } + ] }, { - "id": "damage-ability-multiplicative", - "label": "Ability Damage Multiplicative +40%", - "value": 1.4, - "type": "multiplicative" - }, - { - "id": "rpm-ability-additive", - "label": "Ability RPM Additive +10%", - "value": 0.1, - "type": "additive" - }, - { - "id": "rpm-ability-multiplicative", - "label": "Ability RPM Multiplicative +30%", + "id": "damage-ability-multiplicative-heath-spawn", + "label": "[Heath] Heath Spawn (+30% Damage)", "value": 1.3, "type": "multiplicative" }, { - "id": "reloadTime-ability-additive", - "label": "Ability Reload Time Additive -5%", - "value": -0.05, - "type": "additive" + "id": "multiple-buffs-warcry", + "label": "[SD Captain] War Cry(+25% Damage, +?% Reload Speed)", + "buffs": [ + { + "type": "damage", + "value": 1.25, + "buffType": "multiplicative" + }, + { + "type": "reloadTime", + "value": 1, + "buffType": "multiplicative" + } + ] }, { - "id": "reloadTime-ability-multiplicative", - "label": "Ability Reload Time Multiplicative -15%", - "value": 0.85, + "id": "damage-ability-multiplicative-blackout", + "label": "[Hacker] Blackout (+30% Damage)", + "value": 1.3, + "type": "multiplicative" + }, + { + "id": "damage-ability-multiplicative-red-scan", + "label": "[TRU] Red Scan (+30% Damage)", + "value": 1.3, + "type": "multiplicative" + }, + { + "id": "damage-ability-multiplicative-red-scan", + "label": "[TRU] Green Scan (+50% Damage)", + "value": 1.5, + "type": "multiplicative" + }, + { + "id": "damage-ability-multiplicative-point-out", + "label": "[UIU Detective] Point Out (+50% Damage)", + "value": 1.5, "type": "multiplicative" } ]