import { createStore } from './createStore.js'; /** * Shiny hunts: one entry per Pokémon you're actively hunting, with an * encounter counter and the method's odds. Lives in localStorage next to * the other tracking data; rides along in the JSON export. */ export const shinyHunts = createStore('pdx.shinyHunts', { hunts: [] }); let seq = Date.now(); const uid = () => `h${(seq++).toString(36)}`; export function addHunt({ speciesId, method, charm }) { shinyHunts.set((s) => ({ ...s, hunts: [ { id: uid(), speciesId, method, charm: !!charm, count: 0, notes: '', startedAt: new Date().toISOString() }, ...s.hunts, ], })); } export function updateHunt(id, patch) { shinyHunts.set((s) => ({ ...s, hunts: s.hunts.map((h) => (h.id === id ? { ...h, ...patch } : h)), })); } export function bumpHunt(id, delta) { shinyHunts.set((s) => ({ ...s, hunts: s.hunts.map((h) => (h.id === id ? { ...h, count: Math.max(0, h.count + delta) } : h)), })); } export function removeHunt(id) { shinyHunts.set((s) => ({ ...s, hunts: s.hunts.filter((h) => h.id !== id) })); }