mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Add remove all/add all to damage combo filtering
This commit is contained in:
parent
2fb23e009d
commit
6009832864
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) => (
|
||||
|
|
|
|||
|
|
@ -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[] = [],
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user