added default value for selectors and some more operatives

This commit is contained in:
IM23a-spirgif
2024-09-21 09:42:12 +02:00
parent 2acac58131
commit 98f87ad60e
3 changed files with 93 additions and 7 deletions
+9 -4
View File
@@ -238,6 +238,9 @@ function applyModifiers() {
if (mod.appliesTo && mod.appliesTo !== selectedWeapon.guntype) {
return; // Skip this modifier
}
if (mod.operatives && selectedOperative && mod.operatives !== selectedOperative.category) {
return; // Skip this modifier if it doesn't apply to the current operative's category
}
// Handle modifiers with multiple buffs
if (mod.dataset.buffs) {
@@ -266,7 +269,7 @@ function applyModifiers() {
}
};
// Function to process operative-based modifiers
// Function to process operative-specific modifiers
const processOperativeModifier = (mod) => {
if (mod.appliesNotTo && mod.appliesNotTo === selectedWeapon.guntype) {
return; // Skip this modifier for this weapon type
@@ -275,6 +278,11 @@ function applyModifiers() {
return; // Skip if the modifier does not apply to this weapon type
}
// Ensure that the modifier only applies if it matches the selected operative's category
if (mod.operatives && selectedOperative && mod.operatives !== selectedOperative.category) {
return; // Skip this modifier if it doesn't apply to the current operative's category
}
// Handle operative modifiers with multiple buffs
if (mod.buffs) {
mod.buffs.forEach(buff => {
@@ -303,11 +311,9 @@ function applyModifiers() {
processModifier(mod);
});
// Re-apply listener after change
modifiersContainer.addEventListener('change', applyModifiers);
// Process operative-specific modifiers
// Process operative-specific modifiers that are checked
const operativeSection = document.getElementById('operative-modifiers');
operativeSection.querySelectorAll('input:checked').forEach(mod => {
@@ -319,7 +325,6 @@ function applyModifiers() {
}
});
// Recalculate with applied modifiers
let damage = baseDamage * damageModifier.multiplicative;
damage += damageModifier.additive;
+1 -1
View File
@@ -337,7 +337,7 @@
"rpm": 30,
"mag_size": 5,
"reload_time": 3.5,
"guntype": "RIFLE?"
"guntype": "RIFLE"
},
{
"id": 38,
+83 -2
View File
@@ -182,8 +182,8 @@
"appliesTo": ""
},
{
"id": "adrenaline-damage-perk",
"label": "All Upgrades (+30% Damage)",
"id": "anarchist-adrenaline-damage-perk",
"label": "Adrenaline (+30% Damage)",
"value": 1.3,
"type": "multiplicative",
"appliesTo": ""
@@ -1097,6 +1097,87 @@
"appliesTo": "SMG"
}
]
},
{
"id": "GRU-P-Assault",
"name": "GRU-P Assault",
"category": "GRU-P",
"modifiers": [
{
"id": "not-step-back-damage-perk",
"label": "Not one step back (+50% Damage)",
"value": 1.5,
"type": "multiplicative",
"appliesTo": ""
},
{
"id": "gru-p-assault-mastery-reload-perk",
"label": "Mastery [SOVIET WEAPONS] (+10% Reload Speed)",
"buffs": [
{
"type": "reloadTime",
"value": 0.9,
"buffType": "multiplicative"
}
],
"appliesTo": "SOVIET"
},
{
"id": "gru-p-assault-mastery-damage-perk",
"label": "Mastery (+20% Damage)",
"buffs": [
{
"type": "damage",
"value": 1.2,
"buffType": "multiplicative"
}
],
"appliesTo": ""
},
{
"id": "gru-p-assault-patriotic-damage-perk",
"label": "Patriotic (+60% Damage)",
"buffs": [
{
"type": "damage",
"value": 1.6,
"buffType": "multiplicative"
}
],
"appliesTo": ""
}
]
},
{
"id": "GRU-P-Specialist",
"name": "GRU-P Specialist",
"category": "GRU-P",
"modifiers": [
{
"id": "well-taught-reload-perk",
"label": "Not one step back (+50% Reload Speed)",
"buffs": [
{
"type": "reloadTime",
"value": 0.5,
"buffType": "multiplicative"
}
],
"appliesNotTo": "SHOTGUN"
},
{
"id": "heavy-bullets-damage-perk",
"label": "Heavy Bullets (+32% Damage)",
"buffs": [
{
"type": "damage",
"value": 1.32,
"buffType": "multiplicative"
}
],
"appliesTo": ""
}
]
}
]
}