Add remove all/add all to damage combo filtering

This commit is contained in:
Kalle 2026-01-20 20:41:28 +02:00
parent 2fb23e009d
commit 6009832864
19 changed files with 137 additions and 16 deletions

View File

@ -167,6 +167,34 @@
color: var(--text-lighter);
}
.filterControlsRow {
display: flex;
gap: var(--s-2);
padding-block-end: var(--s-2);
border-block-end: 1px solid var(--border);
margin-block-end: var(--s-1);
}
.filterControlButton {
padding: var(--s-1) var(--s-2);
background: var(--bg-lighter);
border: 1px solid var(--border);
border-radius: var(--rounded-sm);
font-size: var(--fonts-xs);
color: var(--text);
cursor: pointer;
transition: background-color 0.15s ease;
}
.filterControlButton:hover:not(:disabled) {
background: var(--bg-lightest);
}
.filterControlButton:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.filteredItemsRow {
display: flex;
flex-wrap: wrap;

View File

@ -19,6 +19,7 @@ import {
calculateDamageCombos,
calculateInkTimeToKill,
type ExcludedDamageKey,
getAllDamageKeys,
} from "../core/damage-combinations";
import styles from "./DamageComboBar.module.css";
@ -273,6 +274,8 @@ export function DamageComboList({ weaponIds }: DamageComboListProps) {
return null;
}
const allDamageKeys = getAllDamageKeys(weaponIds, targetSubDefenseAp);
const handleToggleFilter = (key: ExcludedDamageKey) => {
const keyString = filterKeyToString(key);
const exists = excludedKeys.some((k) => filterKeyToString(k) === keyString);
@ -286,6 +289,14 @@ export function DamageComboList({ weaponIds }: DamageComboListProps) {
}
};
const handleRemoveAll = () => {
setExcludedKeys(allDamageKeys);
};
const handleClearAll = () => {
setExcludedKeys([]);
};
return (
<div className={styles.container} data-testid="damage-combo-list">
<button
@ -331,6 +342,24 @@ export function DamageComboList({ weaponIds }: DamageComboListProps) {
/>
<span className={styles.resSliderValue}>{targetResAp} AP</span>
</div>
<div className={styles.filterControlsRow}>
<button
type="button"
className={styles.filterControlButton}
onClick={handleRemoveAll}
disabled={excludedKeys.length === allDamageKeys.length}
>
{t("analyzer:comp.removeAll")}
</button>
<button
type="button"
className={styles.filterControlButton}
onClick={handleClearAll}
disabled={excludedKeys.length === 0}
>
{t("analyzer:comp.addAll")}
</button>
</div>
{excludedKeys.length > 0 ? (
<div className={styles.filteredItemsRow}>
{excludedKeys.map((key) => (

View File

@ -90,6 +90,38 @@ export interface ExcludedDamageKey {
damageType: DamageType;
}
export function getAllDamageKeys(
weaponIds: MainWeaponId[],
targetSubDefenseAp = 0,
): ExcludedDamageKey[] {
const sources = extractDamageSources(weaponIds, targetSubDefenseAp);
const seen = new Set<string>();
const keys: ExcludedDamageKey[] = [];
for (const source of sources) {
for (const damage of source.damages) {
const weaponType = damage.weaponType.toLowerCase() as
| "main"
| "sub"
| "special";
const keyString = `${source.weaponId}-${weaponType}-${damage.type}`;
if (seen.has(keyString)) {
continue;
}
seen.add(keyString);
keys.push({
weaponId: source.weaponId,
weaponType,
damageType: damage.type,
});
}
}
return keys;
}
export function calculateDamageCombos(
weaponIds: MainWeaponId[],
excludedKeys: ExcludedDamageKey[] = [],

View File

@ -200,5 +200,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -200,5 +200,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -200,5 +200,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "Global Tracking",
"comp.specialCategory.AREA_CONTROL": "Area Control",
"comp.specialCategory.TEAM_SHIELD": "Team Shield",
"comp.specialCategory.TEAM_BUFF": "Team Buff"
"comp.specialCategory.TEAM_BUFF": "Team Buff",
"comp.removeAll": "Remove all",
"comp.addAll": "Add all"
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -194,5 +194,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -194,5 +194,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -200,5 +200,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -206,5 +206,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -203,5 +203,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -206,5 +206,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}

View File

@ -194,5 +194,7 @@
"comp.specialCategory.GLOBAL_TRACKING": "",
"comp.specialCategory.AREA_CONTROL": "",
"comp.specialCategory.TEAM_SHIELD": "",
"comp.specialCategory.TEAM_BUFF": ""
"comp.specialCategory.TEAM_BUFF": "",
"comp.removeAll": "",
"comp.addAll": ""
}