Changed operative.json and added Selector Population for the Operatives.
This commit is contained in:
+62
-29
@@ -1,5 +1,38 @@
|
||||
let selectedWeapon = null; // Store the selected weapon's data
|
||||
let weapons = []; // This will be populated by the fetched JSON data
|
||||
let selectedOperative = null; // Store the selected operative's data
|
||||
|
||||
// Function to fetch operatives data from JSON
|
||||
function fetchOperativesData() {
|
||||
fetch('static/operative.json') // Adjust the path to the actual location of your JSON file
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
populateOperatives(data.operatives); // Populate the operative dropdown once data is loaded
|
||||
})
|
||||
.catch(error => console.error('Error fetching operatives data:', error));
|
||||
}
|
||||
|
||||
// Function to populate the select element with operatives
|
||||
function populateOperatives(operatives) {
|
||||
const select = document.getElementById('operative-select');
|
||||
select.innerHTML = ""; // Clear any existing options
|
||||
|
||||
operatives.forEach(operative => {
|
||||
const option = document.createElement('option');
|
||||
option.value = operative.id;
|
||||
option.text = operative.name;
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
// Attach event listener to detect when an operative is selected
|
||||
select.addEventListener('change', (event) => {
|
||||
const selectedOperativeId = event.target.value;
|
||||
selectedOperative = operatives.find(op => op.id === selectedOperativeId);
|
||||
if (selectedOperative) {
|
||||
updateOperativeBuffs(selectedOperative)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to fetch weapons data from JSON
|
||||
function fetchWeaponsData() {
|
||||
@@ -70,33 +103,33 @@ 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
|
||||
}
|
||||
// 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
|
||||
@@ -127,9 +160,9 @@ function applyModifiers() {
|
||||
let baseReloadTime = selectedWeapon.reload_time;
|
||||
|
||||
// Initialize the modifier objects
|
||||
let damageModifier = { additive: 0, multiplicative: 1 };
|
||||
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 => {
|
||||
@@ -184,10 +217,9 @@ function applyModifiers() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper function to apply individual buffs
|
||||
function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier = null) {
|
||||
const { type, buffType, value } = buff;
|
||||
const {type, buffType, value} = buff;
|
||||
|
||||
// Apply buffs based on type
|
||||
if (type === 'rpm') {
|
||||
@@ -235,4 +267,5 @@ function updateModifiedWeaponStats(damage, rpm, reloadTime) {
|
||||
|
||||
// Call the fetch function to load the data and populate the dropdown on page load
|
||||
fetchWeaponsData();
|
||||
fetchModifiers();
|
||||
fetchModifiers();
|
||||
fetchOperativesData()
|
||||
+13
-182
@@ -3,236 +3,67 @@
|
||||
{
|
||||
"id": "Classic-Guard",
|
||||
"name": "Guard",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "[SMG] (+15% Damage)",
|
||||
"type": "damage",
|
||||
"value": 1.15,
|
||||
"affectedWeapons": "SMG",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Scout",
|
||||
"name": "Scout",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-RCU",
|
||||
"name": "RCU",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "[SHOTGUN] +25% Damage",
|
||||
"type": "damage",
|
||||
"value": 1.25,
|
||||
"affectedWeapons": "SHOTGUN",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Viper",
|
||||
"name": "Viper",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-SD-Sergeant",
|
||||
"name": "SD Sergeant",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "Max Corruption (+30% Damage)",
|
||||
"type": "damage",
|
||||
"value": 1.3,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-ISD",
|
||||
"name": "ISD",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "[Chaos Insurgency] +50% Damage",
|
||||
"type": "damage",
|
||||
"value": 1.5,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-TRU",
|
||||
"name": "TRU",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-SD-Captain",
|
||||
"name": "SD Captain",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Vanguard",
|
||||
"name": "Vanguard",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "[Not LMG] Bad Experience (+25% Damage, +25% Reload Speed)",
|
||||
"buffs": [
|
||||
{
|
||||
"type": "damage",
|
||||
"value": 1.25,
|
||||
"affectedWeapons": "NOT LMG",
|
||||
"buffType": "multiplicative"
|
||||
},
|
||||
{
|
||||
"type": "reloadTime",
|
||||
"value": 0.75,
|
||||
"affectedWeapons": "NOT LMG",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "[LMG] LMG User (+35% Damage)",
|
||||
"buffs": [
|
||||
{
|
||||
"type": "damage",
|
||||
"value": 1.35,
|
||||
"affectedWeapons": "LMG",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Demolitionist",
|
||||
"name": "Demolitionist",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "Classic-Juggernaut",
|
||||
"name": "Juggernaut",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "Hold the Line (+90% Damage)",
|
||||
"type": "damage",
|
||||
"value": 1.9,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Mercenary",
|
||||
"name": "Mercenary",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "All Upgrades (+25% Damage, +15% Reload Speed)",
|
||||
"buffs": [
|
||||
{
|
||||
"type": "damage",
|
||||
"value": 1.25,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
},
|
||||
{
|
||||
"type": "reloadTime",
|
||||
"value": 0.85,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MCD Sandevistan (+?% Damage",
|
||||
"type": "damage",
|
||||
"value": 1.5,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-CRT",
|
||||
"name": "CRT",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "None",
|
||||
"type": "damage",
|
||||
"value": 1,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
},
|
||||
{
|
||||
"id": "Classic-Anarchist",
|
||||
"name": "Anarchist",
|
||||
"buffs": [
|
||||
{
|
||||
"label": "Last Stand (+150% Damage)",
|
||||
"type": "damage",
|
||||
"value": 2.5,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
},
|
||||
{
|
||||
"label": "World On Fire (+150% Damage)",
|
||||
"type": "damage",
|
||||
"value": 2.5,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
},
|
||||
{
|
||||
"label": "Adrenaline (+30% Damage)",
|
||||
"type": "damage",
|
||||
"value": 2.5,
|
||||
"affectedWeapons": "",
|
||||
"buffType": "multiplicative"
|
||||
}
|
||||
]
|
||||
"category": "Classic"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -59,15 +59,21 @@
|
||||
<!-- Weapon options will be populated here dynamically -->
|
||||
</select>
|
||||
|
||||
<!-- Weapon Stats will be displayed here -->
|
||||
<div id="weapon-stats"></div>
|
||||
<!-- Operative Select Dropdown -->
|
||||
<label for="operative-select">Pick an Operative</label>
|
||||
<select id="operative-select">
|
||||
<option value="">Select an operative</option>
|
||||
</select>
|
||||
|
||||
<!-- Calculated DPS/DPM results will be shown here -->
|
||||
|
||||
<!-- Weapon Stats Display -->
|
||||
<div id="weapon-stats"></div>
|
||||
<div id="calculated-stats"></div>
|
||||
|
||||
<!-- Modifier Checkboxes -->
|
||||
<!-- Modifiers Display -->
|
||||
<div id="modifiers"></div>
|
||||
|
||||
|
||||
<script src="{{ url_for('static', filename='filterWeapons.js') }}"></script>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user