Files
blitzkit/src/components/ConsumablesManager.tsx
T

70 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-04-06 19:37:57 -05:00
import { Flex } from '@radix-ui/themes';
2024-04-23 09:57:59 -05:00
import { ConsumableEntry } from '../core/blitzkit/consumableDefinitions';
2024-04-06 19:37:57 -05:00
import { ConsumableButton } from './ModuleButtons/ConsumableButton';
interface ConsumablesManagerProps {
consumables: ConsumableEntry[];
selected: number[];
onChange?: (consumables: number[]) => void;
disabled?: boolean;
timers?: boolean;
hasHighEndConsumables?: boolean;
hasConsumableDeliverySystem?: boolean;
cooldownBooster?: number;
}
export function ConsumablesManager({
consumables,
selected,
onChange,
disabled,
timers,
hasConsumableDeliverySystem,
cooldownBooster,
hasHighEndConsumables,
}: ConsumablesManagerProps) {
return (
<Flex wrap="wrap" gap="2">
2024-04-06 19:37:57 -05:00
{consumables.map((consumable, index) => {
const isSelected = selected.some((id) => id === consumable.id);
return (
<ConsumableButton
special={consumable.duration === undefined}
duration={
timers
? consumable.duration === undefined
? undefined
2024-04-20 11:45:41 -05:00
: consumable.duration * (hasHighEndConsumables ? 1.7 : 1)
2024-04-06 19:37:57 -05:00
: undefined
}
cooldown={
timers
? consumable.cooldown *
2024-05-22 13:04:39 -05:00
(hasConsumableDeliverySystem ? 0.88 : 1) *
2024-04-06 19:37:57 -05:00
(1 - cooldownBooster! * 0.1)
: undefined
}
key={consumable.id}
disabled={disabled && !isSelected}
consumable={consumable.id}
selected={isSelected}
onClick={() => {
if (!onChange) return;
const draft = [...selected];
if (draft.some((id) => id === consumable.id)) {
draft.splice(draft.indexOf(consumable.id), 1);
} else {
draft.push(consumable.id);
}
onChange(draft);
}}
/>
);
})}
</Flex>
);
}