Merge remote-tracking branch 'origin/main'

This commit is contained in:
IM23a-bachmannj2
2024-09-17 14:23:04 +02:00
3 changed files with 85 additions and 215 deletions
+61 -28
View File
@@ -1,5 +1,38 @@
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 = []; // 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/json/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 to fetch weapons data from JSON
function fetchWeaponsData() { function fetchWeaponsData() {
@@ -70,33 +103,33 @@ function populateModifiers(modifiers) {
const modifiersContainer = document.getElementById('modifiers'); const modifiersContainer = document.getElementById('modifiers');
const createModifierSection = (title, modifierList) => { const createModifierSection = (title, modifierList) => {
const section = document.createElement('div'); const section = document.createElement('div');
const header = document.createElement('h3'); const header = document.createElement('h3');
header.textContent = title; header.textContent = title;
section.appendChild(header); section.appendChild(header);
modifierList.forEach(mod => { modifierList.forEach(mod => {
const label = document.createElement('label'); const label = document.createElement('label');
const input = document.createElement('input'); const input = document.createElement('input');
input.type = 'checkbox'; input.type = 'checkbox';
input.id = mod.id; input.id = mod.id;
// Check if the modifier has multiple buffs // Check if the modifier has multiple buffs
if (mod.buffs) { if (mod.buffs) {
input.dataset.buffs = JSON.stringify(mod.buffs); // Store buffs data as a string in data-buffs input.dataset.buffs = JSON.stringify(mod.buffs); // Store buffs data as a string in data-buffs
} else { } else {
input.value = mod.value; input.value = mod.value;
input.dataset.type = mod.type; // Store if it's additive or multiplicative input.dataset.type = mod.type; // Store if it's additive or multiplicative
} }
label.appendChild(input); label.appendChild(input);
label.appendChild(document.createTextNode(mod.label)); label.appendChild(document.createTextNode(mod.label));
section.appendChild(label); section.appendChild(label);
section.appendChild(document.createElement('br')); section.appendChild(document.createElement('br'));
}); });
return section; return section;
}; };
// Clear any existing modifiers // Clear any existing modifiers
@@ -127,9 +160,9 @@ function applyModifiers() {
let baseReloadTime = selectedWeapon.reload_time; let baseReloadTime = selectedWeapon.reload_time;
// Initialize the modifier objects // Initialize the modifier objects
let damageModifier = { additive: 0, multiplicative: 1 }; let damageModifier = {additive: 0, multiplicative: 1};
let rpmModifier = { additive: 0, multiplicative: 1 }; let rpmModifier = {additive: 0, multiplicative: 1};
let reloadTimeModifier = { additive: 0, multiplicative: 1 }; let reloadTimeModifier = {additive: 0, multiplicative: 1};
// Collect checked modifier values // Collect checked modifier values
document.querySelectorAll('#modifiers input:checked').forEach(mod => { document.querySelectorAll('#modifiers input:checked').forEach(mod => {
@@ -184,10 +217,9 @@ 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;
// Apply buffs based on type // Apply buffs based on type
if (type === 'rpm') { if (type === 'rpm') {
@@ -236,3 +268,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()
+13 -182
View File
@@ -3,236 +3,67 @@
{ {
"id": "Classic-Guard", "id": "Classic-Guard",
"name": "Guard", "name": "Guard",
"buffs": [ "category": "Classic"
{
"label": "[SMG] (+15% Damage)",
"type": "damage",
"value": 1.15,
"affectedWeapons": "SMG",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-Scout", "id": "Classic-Scout",
"name": "Scout", "name": "Scout",
"buffs": [ "category": "Classic"
{
"label": "None",
"type": "damage",
"value": 1,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-RCU", "id": "Classic-RCU",
"name": "RCU", "name": "RCU",
"buffs": [ "category": "Classic"
{
"label": "[SHOTGUN] +25% Damage",
"type": "damage",
"value": 1.25,
"affectedWeapons": "SHOTGUN",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-Viper", "id": "Classic-Viper",
"name": "Viper", "name": "Viper",
"buffs": [ "category": "Classic"
{
"label": "None",
"type": "damage",
"value": 1,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-SD-Sergeant", "id": "Classic-SD-Sergeant",
"name": "SD Sergeant", "name": "SD Sergeant",
"buffs": [ "category": "Classic"
{
"label": "Max Corruption (+30% Damage)",
"type": "damage",
"value": 1.3,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-ISD", "id": "Classic-ISD",
"name": "ISD", "name": "ISD",
"buffs": [ "category": "Classic"
{
"label": "[Chaos Insurgency] +50% Damage",
"type": "damage",
"value": 1.5,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-TRU", "id": "Classic-TRU",
"name": "TRU", "name": "TRU",
"buffs": [ "category": "Classic"
{
"label": "None",
"type": "damage",
"value": 1,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-SD-Captain", "id": "Classic-SD-Captain",
"name": "SD Captain", "name": "SD Captain",
"buffs": [ "category": "Classic"
{
"label": "None",
"type": "damage",
"value": 1,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-Vanguard", "id": "Classic-Vanguard",
"name": "Vanguard", "name": "Vanguard",
"buffs": [ "category": "Classic"
{
"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"
}
]
}
]
}, },
{ {
"id": "Classic-Demolitionist", "id": "Classic-Demolitionist",
"name": "Demolitionist", "name": "Demolitionist",
"buffs": [ "category": "Classic"
{
"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"
}
]
}, },
{ {
"id": "Classic-Mercenary", "id": "Classic-Mercenary",
"name": "Mercenary", "name": "Mercenary",
"buffs": [ "category": "Classic"
{
"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"
}
]
}, },
{ {
"id": "Classic-CRT", "id": "Classic-CRT",
"name": "CRT", "name": "CRT",
"buffs": [ "category": "Classic"
{
"label": "None",
"type": "damage",
"value": 1,
"affectedWeapons": "",
"buffType": "multiplicative"
}
]
}, },
{ {
"id": "Classic-Anarchist", "id": "Classic-Anarchist",
"name": "Anarchist", "name": "Anarchist",
"buffs": [ "category": "Classic"
{
"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"
}
]
} }
] ]
} }
+10 -4
View File
@@ -59,15 +59,21 @@
<!-- Weapon options will be populated here dynamically --> <!-- Weapon options will be populated here dynamically -->
</select> </select>
<!-- Weapon Stats will be displayed here --> <!-- Operative Select Dropdown -->
<div id="weapon-stats"></div> <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> <div id="calculated-stats"></div>
<!-- Modifier Checkboxes --> <!-- Modifiers Display -->
<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>