import { useState } from 'react'; import { Plus, Trash2 } from 'lucide-react'; import type { NPCConfiguration, NPCPartyProvider, SimplePartyProvider, PoolPartyProvider, PoolEntry } from '../types/npc'; interface NPCPartyBuilderProps { config: NPCConfiguration; onChange: (config: NPCConfiguration) => void; } export function NPCPartyBuilder({ config, onChange }: NPCPartyBuilderProps) { const [partyType, setPartyType] = useState<'simple' | 'pool' | 'script'>(config.party?.type || 'simple'); const handlePartyChange = (party: NPCPartyProvider) => { onChange({ ...config, party }); }; const handlePartyTypeChange = (type: 'simple' | 'pool' | 'script') => { setPartyType(type); switch (type) { case 'simple': handlePartyChange({ type: 'simple', pokemon: [''] }); break; case 'pool': handlePartyChange({ type: 'pool', pool: [{ pokemon: '', weight: 1 }] }); break; case 'script': handlePartyChange({ type: 'script', script: '' }); break; } }; const renderSimpleParty = () => { const party = config.party as SimplePartyProvider; if (!party || !party.pokemon) { return null; } const addPokemon = () => { handlePartyChange({ ...party, pokemon: [...party.pokemon, ''] }); }; const removePokemon = (index: number) => { handlePartyChange({ ...party, pokemon: party.pokemon.filter((_, i) => i !== index) }); }; const updatePokemon = (index: number, value: string) => { const newPokemon = [...party.pokemon]; newPokemon[index] = value; handlePartyChange({ ...party, pokemon: newPokemon }); }; return (
If true, party won't change between battles
Enable battle configuration to set up a party