/* ─── 드림팀 빌더 상세 화면 ────────────────────────────────────────────── */ (function seedToolPlayers() { if (window.KB_DATA && window.KB_DATA.toolPlayers) return; window.KB_DATA = window.KB_DATA || {}; window.KB_DATA.toolPlayers = [ // 한국인 MLB 5 { id:"lee-jh", ko:"이정후", team:"SF", lg:"MLB", pos:"OF", ops:.908, war:2.6, sal:11.3, color:"#FD5A1E" }, { id:"kim-hs", ko:"김하성", team:"TB", lg:"MLB", pos:"SS", ops:.748, war:1.4, sal: 8.0, color:"#092C5C" }, { id:"kim-hys", ko:"김혜성", team:"LAD", lg:"MLB", pos:"2B", ops:.812, war:1.8, sal: 4.7, color:"#005A9C" }, { id:"choi-jm", ko:"최지만", team:"SD", lg:"MLB", pos:"1B", ops:.721, war:0.9, sal: 5.5, color:"#2F241D" }, { id:"go-ws", ko:"고우석", team:"MIA", lg:"MLB", pos:"P", ops:.000, war:1.1, sal: 4.5, color:"#00A3E0" }, // KBO 스타 15 { id:"austin", ko:"오스틴", team:"LG", lg:"KBO", pos:"1B", ops:1.082, war:4.1, sal: 1.5, color:"#C30452" }, { id:"choi-j", ko:"최정", team:"SSG", lg:"KBO", pos:"3B", ops:1.041, war:3.9, sal: 2.4, color:"#CE0E2D" }, { id:"kim-dy", ko:"김도영", team:"KIA", lg:"KBO", pos:"3B", ops:1.018, war:4.2, sal: 0.9, color:"#EA0029" }, { id:"koo-jw", ko:"구자욱", team:"삼성", lg:"KBO", pos:"OF", ops: .988, war:3.4, sal: 2.0, color:"#074CA1" }, { id:"song-sm", ko:"송성문", team:"키움", lg:"KBO", pos:"3B", ops: .961, war:3.1, sal: 0.6, color:"#570514" }, { id:"noh-sh", ko:"노시환", team:"한화", lg:"KBO", pos:"3B", ops: .947, war:2.8, sal: 1.1, color:"#FA4616" }, { id:"yang-uj", ko:"양의지", team:"두산", lg:"KBO", pos:"C", ops: .934, war:2.7, sal: 5.0, color:"#131230" }, { id:"park-bh", ko:"박병호", team:"KT", lg:"KBO", pos:"1B", ops: .921, war:2.5, sal: 1.5, color:"#000000" }, { id:"han-ys", ko:"한유섬", team:"SSG", lg:"KBO", pos:"OF", ops: .909, war:2.2, sal: 1.2, color:"#CE0E2D" }, { id:"lee-jy", ko:"이재현", team:"삼성", lg:"KBO", pos:"SS", ops: .855, war:1.9, sal: 0.4, color:"#074CA1" }, { id:"park-ch", ko:"박찬호", team:"KIA", lg:"KBO", pos:"SS", ops: .808, war:2.6, sal: 0.5, color:"#EA0029" }, { id:"kim-yh", ko:"김영웅", team:"삼성", lg:"KBO", pos:"3B", ops: .824, war:1.7, sal: 0.3, color:"#074CA1" }, { id:"kim-ks", ko:"김광현", team:"SSG", lg:"KBO", pos:"P", ops: .000, war:3.2, sal: 7.0, color:"#CE0E2D" }, { id:"yang-hj", ko:"양현종", team:"KIA", lg:"KBO", pos:"P", ops: .000, war:2.8, sal: 5.0, color:"#EA0029" }, { id:"ryu-hj", ko:"류현진", team:"한화", lg:"KBO", pos:"P", ops: .000, war:3.5, sal:17.0, color:"#FA4616" }, { id:"an-wj", ko:"안우진", team:"키움", lg:"KBO", pos:"P", ops: .000, war:2.4, sal: 1.5, color:"#570514" }, { id:"moon-dj", ko:"문동주", team:"한화", lg:"KBO", pos:"P", ops: .000, war:1.9, sal: 0.6, color:"#FA4616" }, ]; })(); function ToolDreamteam({ onClose }) { const POS_ORDER = ["전체","C","1B","2B","3B","SS","OF"]; const [tab, setTab] = React.useState("ALL"); // KBO / MLB / ALL const [pos, setPos] = React.useState("전체"); const [q, setQ] = React.useState(""); const [lineup, setLineup] = React.useState(Array(9).fill(null)); const [rotation, setRotation] = React.useState(Array(5).fill(null)); const [share, setShare] = React.useState(false); const pool = window.KB_DATA.toolPlayers; const usedIds = new Set([...lineup,...rotation].filter(Boolean).map(p=>p.id)); const batters = pool.filter(p => p.pos !== "P"); const pitchers = pool.filter(p => p.pos === "P"); const filteredBatters = batters.filter(p => (tab==="ALL" || p.lg === tab) && (pos==="전체" || p.pos === pos) && (q==="" || p.ko.includes(q) || p.team.includes(q)) ).sort((a,b)=> b.ops - a.ops); const filteredPitchers = pitchers.filter(p => (tab==="ALL" || p.lg === tab) && (q==="" || p.ko.includes(q) || p.team.includes(q)) ).sort((a,b)=> b.war - a.war); const addToLineup = (p) => { if (usedIds.has(p.id)) return; if (p.pos === "P") { const idx = rotation.indexOf(null); if (idx < 0) return; const next = [...rotation]; next[idx] = p; setRotation(next); } else { const idx = lineup.indexOf(null); if (idx < 0) return; const next = [...lineup]; next[idx] = p; setLineup(next); } }; const removeBatter = (i) => { const n=[...lineup]; n[i]=null; setLineup(n); }; const removePitcher = (i) => { const n=[...rotation]; n[i]=null; setRotation(n); }; // summary const filledBat = lineup.filter(Boolean); const filledPit = rotation.filter(Boolean); const teamValue = [...filledBat,...filledPit].reduce((s,p)=>s+p.sal,0); const avgOps = filledBat.length ? (filledBat.reduce((s,p)=>s+p.ops,0)/filledBat.length) : 0; const avgSal = (filledBat.length+filledPit.length) ? (teamValue/(filledBat.length+filledPit.length)) : 0; return (