operative.json added

This commit is contained in:
IM23a-spirgif
2025-01-22 13:23:23 +01:00
parent 7748432913
commit e9aad79237
3 changed files with 64 additions and 73 deletions
+21 -30
View File
@@ -1,5 +1,5 @@
let selectedWeapon = null; // Store the selected weapon's data let selectedWeapon = null; // Store the selected weapon's data
let weapons = []; // This will be populated by the fetched JSON data let weapons = [];
// Function to fetch weapons data from JSON // Function to fetch weapons data from JSON
function fetchWeaponsData() { function fetchWeaponsData() {
@@ -131,52 +131,43 @@ function applyModifiers() {
let rpmModifier = {additive: 0, multiplicative: 1}; let rpmModifier = {additive: 0, multiplicative: 1};
let reloadTimeModifier = {additive: 0, multiplicative: 1}; let reloadTimeModifier = {additive: 0, multiplicative: 1};
// Apply operative buffs if selected
if (selectedOperative) {
selectedOperative.buffs.forEach(buff => {
if (buff.affectedWeapons === '' || buff.affectedWeapons.includes(selectedWeapon.guntype.toUpperCase())) {
applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier);
}
});
}
// Collect checked modifier values // Collect checked modifier values
document.querySelectorAll('#modifiers input:checked').forEach(mod => { document.querySelectorAll('#modifiers input:checked').forEach(mod => {
const modType = mod.dataset.type; const modType = mod.dataset.type;
const modValue = parseFloat(mod.value); const modValue = parseFloat(mod.value);
// Handle multi-buff modifiers (like Bloxy Cola or Firefight) // Handle multi-buff modifiers
if (mod.dataset.buffs) { if (mod.dataset.buffs) {
const buffs = JSON.parse(mod.dataset.buffs); // Parse buffs data from the data-buffs attribute const buffs = JSON.parse(mod.dataset.buffs);
buffs.forEach(buff => { buffs.forEach(buff => applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier));
// Apply each buff
applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier);
});
} else { } else {
// Handle single-buff modifiers const singleBuff = {type: modType, value: modValue};
const singleBuff = {
type: modType === 'multiplicative' ? 'multiplicative' : 'additive', // Use the proper modifier type
buffType: modType,
value: 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); applyBuff(singleBuff, rpmModifier, reloadTimeModifier, damageModifier);
} }
}); });
// Apply the damage modifiers // Apply damage modifiers
let damage = baseDamage * damageModifier.multiplicative; // First apply multiplicative modifiers let damage = baseDamage * damageModifier.multiplicative;
damage += damageModifier.additive; // Then apply percentage-based additive modifiers damage += damageModifier.additive;
// Apply the RPM modifiers // Apply RPM modifiers
let rpm = baseRpm * rpmModifier.multiplicative; let rpm = baseRpm * rpmModifier.multiplicative;
rpm = rpm + (rpm * rpmModifier.additive); rpm = rpm + (rpm * rpmModifier.additive);
// Apply the reload time modifiers // Apply reload time modifiers
let reloadTime = baseReloadTime * reloadTimeModifier.multiplicative; let reloadTime = baseReloadTime * reloadTimeModifier.multiplicative;
reloadTime = reloadTime + (reloadTime * reloadTimeModifier.additive); reloadTime = reloadTime + (reloadTime * reloadTimeModifier.additive);
// Recalculate DPS and DPM with the modified stats // Recalculate DPS and DPM with modified stats
calculateDPSAndDPM(damage, rpm, selectedWeapon.mag_size, reloadTime); calculateDPSAndDPM(damage, rpm, selectedWeapon.mag_size, reloadTime);
// Update the displayed weapon stats with the modified values // Update the displayed weapon stats with the modified values
@@ -184,7 +175,6 @@ function applyModifiers() {
} }
// Helper function to apply individual buffs // Helper function to apply individual buffs
function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier = null) { function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier = null) {
const {type, buffType, value} = buff; const {type, buffType, value} = buff;
@@ -236,3 +226,4 @@ function updateModifiedWeaponStats(damage, rpm, reloadTime) {
// Call the fetch function to load the data and populate the dropdown on page load // Call the fetch function to load the data and populate the dropdown on page load
fetchWeaponsData(); fetchWeaponsData();
fetchModifiers(); fetchModifiers();
fetchOperativesData();
+14 -14
View File
@@ -1,7 +1,7 @@
{ {
"operatives": [ "operatives": [
{ {
"id": "Classic-Guard", "id": 1,
"name": "Guard", "name": "Guard",
"buffs": [ "buffs": [
{ {
@@ -14,7 +14,7 @@
] ]
}, },
{ {
"id": "Classic-Scout", "id": 2,
"name": "Scout", "name": "Scout",
"buffs": [ "buffs": [
{ {
@@ -27,7 +27,7 @@
] ]
}, },
{ {
"id": "Classic-RCU", "id": 3,
"name": "RCU", "name": "RCU",
"buffs": [ "buffs": [
{ {
@@ -40,7 +40,7 @@
] ]
}, },
{ {
"id": "Classic-Viper", "id": 4,
"name": "Viper", "name": "Viper",
"buffs": [ "buffs": [
{ {
@@ -53,7 +53,7 @@
] ]
}, },
{ {
"id": "Classic-SD-Sergeant", "id": 5,
"name": "SD Sergeant", "name": "SD Sergeant",
"buffs": [ "buffs": [
{ {
@@ -66,7 +66,7 @@
] ]
}, },
{ {
"id": "Classic-ISD", "id": 6,
"name": "ISD", "name": "ISD",
"buffs": [ "buffs": [
{ {
@@ -79,7 +79,7 @@
] ]
}, },
{ {
"id": "Classic-TRU", "id": 7,
"name": "TRU", "name": "TRU",
"buffs": [ "buffs": [
{ {
@@ -92,7 +92,7 @@
] ]
}, },
{ {
"id": "Classic-SD-Captain", "id": 8,
"name": "SD Captain", "name": "SD Captain",
"buffs": [ "buffs": [
{ {
@@ -105,7 +105,7 @@
] ]
}, },
{ {
"id": "Classic-Vanguard", "id": 9,
"name": "Vanguard", "name": "Vanguard",
"buffs": [ "buffs": [
{ {
@@ -139,7 +139,7 @@
] ]
}, },
{ {
"id": "Classic-Demolitionist", "id": 10,
"name": "Demolitionist", "name": "Demolitionist",
"buffs": [ "buffs": [
{ {
@@ -152,7 +152,7 @@
] ]
}, },
{ {
"id": "Classic-Juggernaut", "id": 11,
"name": "Juggernaut", "name": "Juggernaut",
"buffs": [ "buffs": [
{ {
@@ -165,7 +165,7 @@
] ]
}, },
{ {
"id": "Classic-Mercenary", "id": 12,
"name": "Mercenary", "name": "Mercenary",
"buffs": [ "buffs": [
{ {
@@ -195,7 +195,7 @@
] ]
}, },
{ {
"id": "Classic-CRT", "id": 13,
"name": "CRT", "name": "CRT",
"buffs": [ "buffs": [
{ {
@@ -208,7 +208,7 @@
] ]
}, },
{ {
"id": "Classic-Anarchist", "id": 14,
"name": "Anarchist", "name": "Anarchist",
"buffs": [ "buffs": [
{ {
+1 -1
View File
@@ -1,7 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/static/img/TRL_Logo_Custom.jpg"> <link rel="icon" type="image/x-icon" href="/static/img/TRL_Logo_Custom.jpg">
@@ -68,6 +67,7 @@
<!-- Modifier Checkboxes --> <!-- Modifier Checkboxes -->
<div id="modifiers"></div> <div id="modifiers"></div>
<script src="{{ url_for('static', filename='filterWeapons.js') }}"></script> <script src="{{ url_for('static', filename='filterWeapons.js') }}"></script>
</main> </main>
</body> </body>