From b312c7b0697aec81755fdcb177942ec30aaa635d Mon Sep 17 00:00:00 2001 From: class04f25 Date: Tue, 13 Oct 2026 04:04:59 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=88=B1=E8=B1=86=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E5=99=A8=E4=B8=BB=E7=BB=84=E4=BB=B6=EF=BC=88=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=89=88=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=9C=88=E6=9C=AB=E8=80=83?= =?UTF-8?q?=E6=A0=B8=E8=BD=AF=E9=94=81=20+=20=E5=8D=95=E9=A3=9E=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=B4=A9=E6=BA=83=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/IdolSimulator.jsx | 1272 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1272 insertions(+) create mode 100644 src/IdolSimulator.jsx diff --git a/src/IdolSimulator.jsx b/src/IdolSimulator.jsx new file mode 100644 index 0000000..ce73b57 --- /dev/null +++ b/src/IdolSimulator.jsx @@ -0,0 +1,1272 @@ +import { useState, useEffect, useRef } from "react"; + +/* ================= 工具 ================= */ +const clamp = (v, a = 0, b = 100) => Math.max(a, Math.min(b, v)); +const rnd = (a, b) => Math.floor(Math.random() * (b - a + 1)) + a; +const pick = (arr) => arr[Math.floor(Math.random() * arr.length)]; + +const fmtNum = (n) => { + n = Math.round(n); + if (n >= 100000000) return (n / 100000000).toFixed(2) + "亿"; + if (n >= 10000) return (n / 10000).toFixed(n >= 1000000 ? 0 : 1) + "万"; + return n.toLocaleString("en-US"); +}; + +const STATS = [ + { key: "vocal", name: "唱功", icon: "🎤", color: "#22d3ee" }, + { key: "dance", name: "舞蹈", icon: "💃", color: "#a855f7" }, + { key: "visual", name: "颜值", icon: "✨", color: "#f472b6" }, + { key: "variety", name: "综艺", icon: "🎬", color: "#fbbf24" }, +]; + +const TRAINEE_WEEKS = 8; +const IDOL_WEEKS = 20; +const TOTAL_WEEKS = TRAINEE_WEEKS + IDOL_WEEKS; +const EXAM_WEEKS = [4, 8]; + +const LOG_COLORS = { + good: "#4ade80", bad: "#f87171", info: "#a78bfa", + win: "#fbbf24", sys: "#94a3b8", cp: "#e879f9", rival: "#fdba74", +}; + +const getPop = (st) => clamp(Math.round(Math.log10(st.fans + 1) * 13), 0, 100); +const hateRatioOf = (st) => st.haters / (st.fans + st.haters + 1); + +/* ================= 队友 ================= */ +const TEAMMATE_POOL = [ + { name: "诗雅", role: "队长", emoji: "🦢", color: "#22d3ee", trait: "责任感爆棚" }, + { name: "柔娜", role: "主唱", emoji: "🐰", color: "#a855f7", trait: "外冷内热" }, + { name: "彩恩", role: "主舞", emoji: "🐱", color: "#f472b6", trait: "练习狂" }, + { name: "荷娜", role: "忙内", emoji: "🐣", color: "#fbbf24", trait: "没心没肺" }, + { name: "书静", role: "Rapper", emoji: "🐺", color: "#4ade80", trait: "嘴很毒" }, + { name: "恩菲", role: "门面", emoji: "🦊", color: "#60a5fa", trait: "慢热害羞" }, +]; + +function makeTeammates() { + return [...TEAMMATE_POOL].sort(() => Math.random() - 0.5).slice(0, 3).map((t, i) => ({ + ...t, id: i, rel: rnd(45, 65), cp: 0, ambition: rnd(6, 18), + })); +} + +function relTier(r) { + if (r >= 85) return { name: "挚友", color: "#f472b6" }; + if (r >= 65) return { name: "亲近", color: "#4ade80" }; + if (r >= 40) return { name: "客气", color: "#a78bfa" }; + if (r >= 22) return { name: "疏远", color: "#94a3b8" }; + return { name: "冰点", color: "#f87171" }; +} + +const teamAvgOf = (st) => + st.teammates.length ? st.teammates.reduce((a, t) => a + t.rel, 0) / st.teammates.length : 40; +const teamFactorOf = (st) => (st.phase === "trainee" ? 1 : 0.85 + (teamAvgOf(st) / 100) * 0.3); +const cpHeatOf = (st) => + st.teammates.length ? st.teammates.reduce((a, t) => a + t.cp, 0) / st.teammates.length : 0; + +function checkTeamBond(st, entries) { + if (st.phase !== "idol" || !st.teammates.length) return; + const avg = teamAvgOf(st); + if (avg >= 82 && !st.bondMaxed) { + st.bondMaxed = true; + st.mood = clamp(st.mood + 10); + entries.push({ week: st.week, kind: "win", text: "💫 全队关系拉满,媒体开始用「团魂」形容你们。团魂加成解锁!" }); + } else if (avg < 25 && Math.random() < 0.5) { + st.mood = clamp(st.mood - 12); + st.fans = Math.max(0, st.fans - Math.round(st.fans * 0.02)); + st.haters += Math.round(st.fans * 0.004 + 200); + entries.push({ week: st.week, kind: "bad", text: "💢 队内关系跌到冰点,成员之间零互动上了热搜。粉丝 -2%、心情 -12。" }); + } +} + +/* ================= 竞争团体 ================= */ +const RIVAL_POOL = [ + { name: "LUNARIS", emoji: "🌙", color: "#60a5fa" }, + { name: "VIVID", emoji: "⚡", color: "#f97316" }, + { name: "AURORA", emoji: "🌌", color: "#a78bfa" }, + { name: "PRISM 9", emoji: "💎", color: "#22d3ee" }, + { name: "BLOSSOM", emoji: "🌸", color: "#f472b6" }, + { name: "HYPER X", emoji: "🚀", color: "#4ade80" }, + { name: "NOCTURNE", emoji: "🦇", color: "#818cf8" }, +]; + +function makeRivals(base) { + return [...RIVAL_POOL].sort(() => Math.random() - 0.5).slice(0, 3).map((r, i) => ({ + ...r, id: i, power: clamp(rnd(base - 8, base + 10)), wins: 0, isSolo: false, + })); +} + +function myPower(st) { + return clamp( + Math.round( + getPop(st) * 0.55 + + teamFactorOf(st) * 18 + + clamp(Math.log10(st.albumSales + 1) * 7, 0, 26) + + cpHeatOf(st) * 0.1 + ), + 0, 100 + ); +} + +function myRank(st) { + if (!st.rivals.length) return 1; + const me = myPower(st); + const arr = [me, ...st.rivals.filter((r) => !r.gone).map((r) => r.power)].sort((a, b) => b - a); + return arr.indexOf(me) + 1; +} + +/* ================= 专辑里程碑 ================= */ +const MILESTONES = [100000, 500000, 1000000, 3000000, 8000000]; +const MILE_NAMES = ["金唱片认证", "白金唱片认证", "百万销量认证", "三百万销量认证", "千万销量认证"]; + +/* ================= 行动 ================= */ +const TRAINEE_ACTIONS = [ + { id: "vocal", icon: "🎤", name: "声乐课", desc: "唱功大幅提升", cost: 1 }, + { id: "dance", icon: "💃", name: "舞蹈课", desc: "舞蹈大幅提升", cost: 1 }, + { id: "visual", icon: "✨", name: "形象管理", desc: "颜值提升 · 较轻松", cost: 1 }, + { id: "variety", icon: "🎬", name: "综艺训练", desc: "综艺感提升", cost: 1 }, + { id: "teambuild", icon: "🍜", name: "团建", desc: "全队关系+ · 心情+", cost: 1 }, + { id: "rest", icon: "🛌", name: "休息", desc: "大幅恢复疲劳", cost: 1 }, +]; + +const IDOL_ACTIONS = [ + { id: "comeback", icon: "🎶", name: "回归打歌", desc: "专辑销量 · 爆涨粉丝 · 冲一位", cost: 2 }, + { id: "show", icon: "📺", name: "综艺出演", desc: "涨粉 · 综艺感+", cost: 1 }, + { id: "cf", icon: "💼", name: "商业代言", desc: "赚钱 · 小涨粉", cost: 1 }, + { id: "practice", icon: "🎧", name: "练习室", desc: "随机属性+", cost: 1 }, + { id: "fanmeet", icon: "💞", name: "粉丝见面会", desc: "涨粉 · 心情+", cost: 1 }, + { id: "teambuild", icon: "🍜", name: "团建", desc: "全队关系+ · 心情+", cost: 1 }, + { id: "pr", icon: "🧯", name: "公关", desc: "压低黑粉热度", cost: 1 }, + { id: "security", icon: "🛡️", name: "安保升级", desc: "压制私生粉 · 永久降速", cost: 1 }, + { id: "rest", icon: "🛌", name: "休息", desc: "大幅恢复疲劳", cost: 1 }, +]; + +/* ================= 随机事件 ================= */ +const TRAINEE_EVENTS = [ + { kind: "good", fn: (st) => { const g = rnd(2, 4); st.stats.vocal = clamp(st.stats.vocal + g); return `🌟 声乐老师说你进步神速,唱功 +${g}。`; } }, + { kind: "good", fn: (st) => { const g = rnd(2, 4); st.stats.dance = clamp(st.stats.dance + g); return `🌟 舞蹈编导给你单独加练,舞蹈 +${g}。`; } }, + { kind: "good", fn: (st) => { st.mood = clamp(st.mood + 12); st.fatigue = clamp(st.fatigue - 8); return "🍜 家人寄来家乡特产,心情 +12、疲劳 -8。"; } }, + { kind: "bad", fn: (st) => { st.mood = clamp(st.mood - 14); return "😰 同期的练习生被淘汰了,你压力山大,心情 -14。"; } }, + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 14); st.mood = clamp(st.mood - 6); return "🌙 你偷偷加练到凌晨两点,疲劳 +14、心情 -6。"; } }, + { kind: "good", fn: (st) => { const g = rnd(1, 3); STATS.forEach((x) => { st.stats[x.key] = clamp(st.stats[x.key] + g); }); return `📓 公司安排综合集训,全属性 +${g}。`; } }, + { kind: "info", fn: (st) => { const f = rnd(300, 1500); st.fans += f; st.haters += rnd(10, 60); return `📱 你的练习室视频小范围出圈,粉丝 +${fmtNum(f)},也混进来几个黑粉。`; } }, + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 10); return "🩹 拉伤了小腿肌肉,只能慢慢来,疲劳 +10。"; } }, +]; + +const IDOL_EVENTS = [ + { kind: "good", fn: (st) => { const f = Math.round(st.fans * 0.08); st.fans += f; st.mood = clamp(st.mood + 14); st.haters += Math.round(f * 0.18); return `🔥 你的直拍意外爆上热搜,粉丝 +${fmtNum(f)}、心情 +14(黑粉也涨了)。`; } }, + { kind: "good", fn: (st) => { const f = Math.round(st.fans * 0.1); st.fans += f; st.mood = clamp(st.mood + 12); st.haters += Math.round(f * 0.12); return `🏅 拿下年末颁奖礼最佳新人奖,粉丝 +${fmtNum(f)}。`; } }, + { kind: "good", fn: (st) => { const m = Math.round(200 + getPop(st) * 3); st.money += m; return `💰 老牌赞助商续约,收入 +${m} 万。`; } }, + { kind: "good", fn: (st) => { st.mood = clamp(st.mood + 10); const f = rnd(2000, 8000); st.fans += f; return `🛒 你在便利店被粉丝认出,对方红着眼说“谢谢你出道”。心情 +10、粉丝 +${fmtNum(f)}。`; } }, + { kind: "info", fn: (st) => { const f = Math.round(st.fans * 0.05); st.fans += f; return `🎥 团综播出反响不错,粉丝 +${fmtNum(f)}。`; } }, + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 12); st.stats.vocal = clamp(st.stats.vocal - 3); return "🤒 嗓子发炎,医生让你噤声三天。唱功 -3、疲劳 +12。"; } }, + { kind: "info", fn: (st) => { st.mood = clamp(st.mood + 8); return "☕ 难得放假的下午,你窝在宿舍看剧,心情 +8。"; } }, +]; + +const TEAM_EVENTS = [ + { kind: "good", fn: (st) => { const t = pick(st.teammates); const d = rnd(8, 16); t.rel = clamp(t.rel + d); return `🌙 你和${t.name}练到凌晨,后来一起去吃了宵夜。关系 +${d}。`; } }, + { kind: "bad", fn: (st) => { const t = pick(st.teammates); const d = rnd(8, 15); t.rel = clamp(t.rel - d); return `😶 你和${t.name}在直播里一句话没接上,被解读成队内不和。关系 -${d}。`; } }, + { kind: "good", fn: (st) => { const d = rnd(5, 10); st.teammates.forEach((t) => { t.rel = clamp(t.rel + d); }); st.mood = clamp(st.mood + 8); return `🎂 你偷偷准备了全队的生日惊喜,全员关系 +${d}、心情 +8。`; } }, + { kind: "bad", fn: (st) => { const t = pick(st.teammates); const d = rnd(6, 12); t.rel = clamp(t.rel - d); st.mood = clamp(st.mood - 8); return `⚔️ ${t.name}在采访里说了句模棱两可的话,粉圈又开始吵。关系 -${d}、心情 -8。`; } }, + { kind: "good", fn: (st) => { const d = rnd(4, 9); st.teammates.forEach((t) => { t.rel = clamp(t.rel + d); }); return `🍜 宿舍夜聊到三点,大家把心里话都说了。全员关系 +${d}。`; } }, + { kind: "info", fn: (st) => { const t = pick(st.teammates); return `☕ ${t.name}今天状态也不太好,你们互相打气了一会儿。`; } }, +]; + +const HATER_EVENTS = [ + { kind: "bad", fn: (st) => { const f = Math.round(st.fans * 0.06); st.fans -= f; st.mood = clamp(st.mood - 14); st.haters += Math.round(st.fans * 0.01 + 300); return `🔥 你被挂上黑热搜,词条挂了整晚。粉丝 -${fmtNum(f)}、心情 -14。`; } }, + { kind: "bad", fn: (st) => { st.mood = clamp(st.mood - 15); return "✂️ 一段舞台被恶意剪辑成「划水」,黑粉疯狂转发。心情 -15。"; } }, + { kind: "bad", fn: (st) => { const f = Math.round(st.fans * 0.03); st.fans -= f; st.haters += Math.round(st.fans * 0.005 + 200); return `📉 黑粉组织刷低分,音源排名下滑。粉丝 -${fmtNum(f)}。`; } }, + { kind: "good", fn: (st) => { const f = Math.round(st.fans * 0.05); st.fans += f; st.mood = clamp(st.mood + 6); st.haters = Math.round(st.haters * 0.85); return `🛡️ 黑粉的恶意剪辑被完整现场打脸,路人反而站你。粉丝 +${fmtNum(f)}、黑粉 -15%。`; } }, + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 14); st.mood = clamp(st.mood - 12); return "📵 有黑粉翻出你练习生时期的旧照做鬼畜。疲劳 +14、心情 -12。"; } }, +]; + +const SASAENG_EVENTS = [ + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 15); st.mood = clamp(st.mood - 13); return "🚗 私生饭开车跟了你的保姆车一路,到了宿舍也不走。疲劳 +15、心情 -13。"; } }, + { kind: "bad", fn: (st) => { st.mood = clamp(st.mood - 16); st.fatigue = clamp(st.fatigue + 8); return "🚪 凌晨三点有人在宿舍楼下喊你的名字,全队都被吵醒了。心情 -16、疲劳 +8。"; } }, + { kind: "bad", fn: (st) => { st.fatigue = clamp(st.fatigue + 12); st.haters += Math.round(st.fans * 0.004 + 200); return "📞 你的私人号码被挂到网上,手机被打爆,只能换号。疲劳 +12、黑粉上升。"; } }, + { kind: "bad", fn: (st) => { st.mood = clamp(st.mood - 18); st.fatigue = clamp(st.fatigue + 10); return "📦 有人往公司寄了你的同款项链和一封长信,警察来做了笔录。心情 -18。"; } }, + { kind: "bad", fn: (st) => { st.mood = clamp(st.mood - 12); st.fans = Math.round(st.fans * 0.99); return "🏠 你家地址被泄露,父母被陌生人敲门问候。心情 -12、粉丝 -1%。"; } }, + { kind: "good", fn: (st) => { st.sasaeng = Math.round(st.sasaeng * 0.7); st.mood = clamp(st.mood + 6); return "👮 公司终于报警立案,几个长期骚扰者被处理了。私生粉 -30%、心情 +6。"; } }, +]; + +const RIVAL_EVENTS = [ + { kind: "rival", fn: (st) => { const r = pick(st.rivals); r.power = clamp(r.power + rnd(4, 9)); return `⚡ 隔壁 ${r.name} 打了个现象级回归,打歌榜排名飙升。`; } }, + { kind: "rival", fn: (st) => { const r = pick(st.rivals); r.power = clamp(r.power - rnd(5, 11)); st.fans += Math.round(st.fans * 0.02); return `💥 ${r.name} 被爆出队内丑闻,部分粉丝转投你们这边。粉丝 +2%。`; } }, + { kind: "rival", fn: (st) => { const r = pick(st.rivals); const m = Math.round(getPop(st) * 2 + 60); st.money += m; return `📰 某品牌原本要签 ${r.name},最后换成了你们。收入 +${m} 万。`; } }, + { kind: "rival", fn: (st) => { const r = pick(st.rivals); st.mood = clamp(st.mood - 8); st.haters += Math.round(st.fans * 0.005 + 200); return `🗡️ ${r.name} 的粉丝在评论区拉踩你们,两边粉圈开战。心情 -8、黑粉上升。`; } }, +]; + +function rollEvent(st) { + if (st.phase === "trainee") return pick(TRAINEE_EVENTS); + const hateRatio = hateRatioOf(st); + const cp = cpHeatOf(st); + const saeP = clamp(st.sasaeng / (getPop(st) * 60 + 300), 0, 3); + const r = Math.random(); + if (r < 0.22) return pick(IDOL_EVENTS); + if (r < 0.42 && st.teammates.length) return pick(TEAM_EVENTS); + if (r < 0.42 + clamp(saeP * 0.16, 0.05, 0.22)) return pick(SASAENG_EVENTS); + if (r < 0.42 + clamp(saeP * 0.16, 0.05, 0.22) + clamp(hateRatio * 0.9, 0.08, 0.24)) return pick(HATER_EVENTS); + if (r < 0.8 && st.rivals.length) return pick(RIVAL_EVENTS); + if (cp > 45 && st.teammates.length) return pick(TEAM_EVENTS); + return pick(IDOL_EVENTS); +} + +/* ================= 弹幕语料 ================= */ +const FAN_DM = [ + "啊啊啊啊我女儿!!!", "这段直拍我能刷一年", "颜值天花板不是说说而已", "路人转粉了,声音好甜", + "求切一个近景呜呜呜", "今天状态也太好了吧", "这舞台质感绝了", "宝贝别太累,注意身体", + "唱功真的进步好多", "买专辑了,冲!", "现场比音源还好听", "怎么这么会啊", +]; +const NEUTRAL_DM = [ + "这首歌副歌有点上头", "第一次听,意外的可以", "是谁?求个科普", "路过,歌还挺好听", + "朋友安利的,来听听", "综艺感不错啊哈哈", "音源榜上见过这名字", "专辑封面好看", +]; +const HATER_DM = [ + "跳得也就那样吧", "全靠公司砸钱营销", "数据注水了吧", "路人缘差是有原因的", + "唱歌像在念经", "票数不对劲,懂的都懂", "颜值靠滤镜好吧", "热搜买得挺勤啊", +]; +const HOT_DM = ["这段直拍上热搜了吧", "我朋友都在问这是谁", "朋友圈全在转这条", "出圈了出圈了", "路人海啸来了"]; + +const CP_DM = [ + "我的CP是真的!!!", "磕死我了磕死我了", "这两个人绝对有事", "CP粉狂喜,糖分超标", + "这段对视我截了八百张", "拜托营业久一点", "谁家CP这么甜啊", "入坑CP粉,走不掉了", + "站位不对但我磕到了", "同框即胜利", +]; +const SOLO_DM = [ + "专注自家,别蹭", "唯粉不接受CP营业", "只爱一个人谢谢", "别拿我担炒CP", + "唯粉早就看不下去了", "分不清主次吗", "请把镜头给我担", "CP营业适可而止吧", +]; +const RIVAL_DM = [ + "隔壁团这次回归很强啊", "对家又买热搜了", "打歌榜第一要换人了吗", "这个团数据太猛了", + "同期竞争好激烈", "对家粉丝又在拉踩了", "音源榜被占了", "惜败,下周再来", +]; + +const DM_COLORS = { + fans: "#f9a8d4", neutral: "#cbd5e1", hater: "#fca5a5", win: "#fde047", + hot: "#fb923c", cp: "#f0abfc", solo: "#93c5fd", rival: "#fdba74", +}; + +let DM_ID = 1; +function makeBullets(texts, kind, count) { + const items = []; + for (let i = 0; i < count; i++) { + items.push({ + id: DM_ID++, text: pick(texts), kind, + color: DM_COLORS[kind] || "#cbd5e1", + top: 3 + Math.random() * 62, + dur: 7 + Math.random() * 6, + born: Date.now(), + }); + } + return items; +} + +function ambientBullets(st) { + const pop = getPop(st); + const hateRatio = hateRatioOf(st); + const cp = cpHeatOf(st); + const out = []; + let fanN = 0; + if (st.fans > 500) { if (Math.random() < 0.8) fanN = pop > 70 && Math.random() < 0.35 ? 2 : 1; } + else if (Math.random() < 0.25) fanN = 1; + if (fanN) out.push({ kind: "fans", texts: FAN_DM, count: fanN }); + if (cp > 32 && Math.random() < clamp(cp / 110, 0, 0.55)) out.push({ kind: "cp", texts: CP_DM, count: 1 }); + if (cp > 55 && Math.random() < 0.28) out.push({ kind: "solo", texts: SOLO_DM, count: 1 }); + if (Math.random() < 0.3) out.push({ kind: "neutral", texts: NEUTRAL_DM, count: 1 }); + if (st.phase === "idol" && st.rivals.length && Math.random() < 0.24) out.push({ kind: "rival", texts: RIVAL_DM, count: 1 }); + if (Math.random() < clamp(hateRatio * 2.4, 0, 0.7)) out.push({ kind: "hater", texts: HATER_DM, count: 1 }); + if (Math.random() < 0.04) out.push({ kind: "hot", texts: HOT_DM, count: 1 }); + return out; +} + +/* ================= 初始状态 ================= */ +function initState(started) { + return { + started: !!started, + week: 1, + phase: "trainee", + energy: 3, maxEnergy: 3, energyPenalty: 0, + fatigue: 0, mood: 60, + stats: { vocal: 12, dance: 12, visual: 12, variety: 6 }, + fans: 0, haters: 0, sasaeng: 0, money: 0, + albumSales: 0, wins: 0, cooldown: 0, + tier: null, tierMult: 1, + warnings: 0, collapses: 0, + lastExam: 0, // 防止同一周重复考核 + teammates: makeTeammates(), + bondMaxed: false, + security: 0, + rivals: [], + lastRank: 1, + danmakuOn: true, + log: [{ week: 0, kind: "sys", text: "你通过了练习生选拔,签约进入公司——同期的另外三人,将是你未来的队友。" }], + modal: null, + over: null, + }; +} + +/* ================= 出道 / 结局 ================= */ +function doDebut(st, entries) { + const total = st.stats.vocal + st.stats.dance + st.stats.visual + st.stats.variety; + let tier = null; + if (total >= 190) tier = { name: "C 位出道 · 顶级团体中心", mult: 1.6, fans: 120000 }; + else if (total >= 158) tier = { name: "主唱 / 主舞出道", mult: 1.1, fans: 40000 }; + else if (total >= 122) tier = { name: "组合普通成员出道", mult: 0.7, fans: 8000 }; + + if (!tier) { + st.over = { + title: "未能出道", sub: "DEBUT REJECTED", tone: "bad", + lines: [`综合实力值 ${total},没达到出道标准。`, "公司把资源给了别人,你被解约了。", "(下次记得平衡训练和休息,疲劳会吃掉收益)"], + }; + st.modal = { title: st.over.title, sub: st.over.sub, lines: st.over.lines, tone: "bad" }; + return; + } + + st.phase = "idol"; + st.tier = tier.name; + st.tierMult = tier.mult; + st.fans = tier.fans; + st.haters = Math.round(tier.fans * 0.06) + 300; + st.sasaeng = Math.round(tier.fans * 0.01) + 25; + st.money = 300; + st.energy = 3; + st.rivals = makeRivals(52); + st.lastRank = myRank(st); + + entries.push({ week: st.week, kind: "good", text: `🎉 出道!定位「${tier.name}」,初始粉丝 ${fmtNum(tier.fans)}、签约金 300 万。` }); + entries.push({ week: st.week, kind: "rival", text: `🏁 同期出道的还有 ${st.rivals.map((r) => r.name).join("、")}——打歌榜厮杀正式开始。` }); + + st.modal = { + title: "出 道", sub: tier.name, tone: "good", + lines: [ + `综合实力值:${total}`, + `初始粉丝:${fmtNum(tier.fans)}`, + `队友:${st.teammates.map((t) => t.name).join(" / ")}`, + `对手:${st.rivals.map((r) => r.name).join(" / ")}`, + "偶像生涯正式开始 —— 接下来 20 周,冲吧。", + ], + }; +} + +function finalEnding(st) { + const f = st.fans; + const w = st.wins; + const avg = Math.round(teamAvgOf(st)); + const base = `粉丝 ${fmtNum(f)},累计销量 ${fmtNum(st.albumSales)},一位 ${w} 次,队内关系 ${avg}`; + if (f >= 4000000 && w >= 5) { + return { title: "五 女 一", sub: "LEGEND · 5TH GEN NO.1", tone: "win", + lines: [`${base}。`, "你成了整个五代女团的代名词,热搜上永远有你的名字。", "有人把你的数据做成表格,用来赢下每一场掐架。"] }; + } + if (f >= 1800000) { + return { title: "顶流 TOP TIER", sub: "A-LIST IDOL", tone: "good", + lines: [`${base}。`, "你稳坐一线,是各大颁奖礼的常客。", "距离「五女一」,只差一次现象级回归。"] }; + } + if (f >= 600000) { + return { title: "大势偶像", sub: "RISING STAR", tone: "good", + lines: [`${base}。`, "你有稳定的死忠和不错的国民度。", "天花板还很高,下次继续冲。"] }; + } + if (f >= 150000) { + return { title: "稳定活动中的成员", sub: "STEADY IDOL", tone: "info", + lines: [`${base}。`, "没有大爆,但你在舞台上很开心。", "这也没什么不好。"] }; + } + return { title: "查 无 此 人", sub: "NUGU ENDING", tone: "bad", + lines: [`${base}。`, "团糊了,公司准备解散。", "深夜你刷到别人拿一位的视频,沉默了很久。"] }; +} + +/* ================= 主组件 ================= */ +export default function IdolSimulator() { + const [s, setS] = useState(() => initState(false)); + const [danmaku, setDanmaku] = useState([]); + const stateRef = useRef(s); + + useEffect(() => { stateRef.current = s; }, [s]); + + const commit = (next) => { stateRef.current = next; setS(next); }; + + const pushDM = (texts, kind, count) => { + const items = makeBullets(texts, kind, count); + setDanmaku((d) => [...d.slice(-45), ...items]); + }; + + /* 弹幕自动生成 */ + useEffect(() => { + if (!s.started) return; + let alive = true; let timer = null; + const tick = () => { + if (!alive) return; + const st = stateRef.current; + if (!st.over && st.danmakuOn) ambientBullets(st).forEach((g) => pushDM(g.texts, g.kind, g.count)); + timer = setTimeout(tick, 900 + Math.random() * 900); + }; + timer = setTimeout(tick, 600); + return () => { alive = false; if (timer) clearTimeout(timer); }; + }, [s.started]); + + /* 弹幕清理 */ + useEffect(() => { + const id = setInterval(() => setDanmaku((d) => d.filter((b) => Date.now() - b.born < 16000)), 1000); + return () => clearInterval(id); + }, []); + + const clone = (prev) => ({ + ...prev, + stats: { ...prev.stats }, + teammates: prev.teammates.map((t) => ({ ...t })), + rivals: prev.rivals.map((r) => ({ ...r })), + log: [...prev.log], + }); + + /* ================= 行动 ================= */ + function act(id) { + const prev = stateRef.current; + if (!prev.started || prev.over || prev.modal) return; + const list = prev.phase === "trainee" ? TRAINEE_ACTIONS : IDOL_ACTIONS; + const a = list.find((x) => x.id === id); + if (!a || prev.energy < a.cost) return; + if (id === "comeback" && prev.cooldown > 0) return; + if (id === "pr" && prev.money < Math.round(getPop(prev) * 3)) return; + if (id === "security" && prev.money < Math.round(getPop(prev) * 2 + 80)) return; + + const st = clone(prev); + const entries = []; + const mult = clamp(1 - st.fatigue / 240, 0.4, 1) * (0.85 + st.mood / 400); + const gain = (amount) => Math.max(1, Math.round(amount * mult)); + st.energy -= a.cost; + + if (id === "vocal") { + const g = gain(rnd(6, 11)); + st.stats.vocal = clamp(st.stats.vocal + g); st.fatigue = clamp(st.fatigue + 11); + entries.push({ week: st.week, kind: "info", text: `🎤 声乐课:唱功 +${g}(疲劳 +11)` }); + } else if (id === "dance") { + const g = gain(rnd(6, 11)); + st.stats.dance = clamp(st.stats.dance + g); st.fatigue = clamp(st.fatigue + 13); + entries.push({ week: st.week, kind: "info", text: `💃 舞蹈课:舞蹈 +${g}(疲劳 +13)` }); + } else if (id === "visual") { + const g = gain(rnd(5, 9)); + st.stats.visual = clamp(st.stats.visual + g); st.fatigue = clamp(st.fatigue + 7); + entries.push({ week: st.week, kind: "info", text: `✨ 形象管理:颜值 +${g}(疲劳 +7)` }); + } else if (id === "variety") { + const g = gain(rnd(5, 9)); + st.stats.variety = clamp(st.stats.variety + g); st.fatigue = clamp(st.fatigue + 9); + entries.push({ week: st.week, kind: "info", text: `🎬 综艺训练:综艺感 +${g}(疲劳 +9)` }); + } else if (id === "rest") { + st.fatigue = clamp(st.fatigue - 34); st.mood = clamp(st.mood + 9); + entries.push({ week: st.week, kind: "good", text: "🛌 好好睡了一整天,疲劳 -34、心情 +9。" }); + } else if (id === "teambuild") { + if (!st.teammates.length) return; + const d = rnd(7, 13); + st.teammates.forEach((t) => { t.rel = clamp(t.rel + d); }); + st.mood = clamp(st.mood + 7); st.fatigue = clamp(st.fatigue + 8); + entries.push({ week: st.week, kind: "good", text: `🍜 全队聚餐 + 游戏之夜,全员关系 +${d}、心情 +7。` }); + pushDM(["这团感情是真的好吧", "磕到了磕到了", "团魂这词不是白叫的", "好想加入他们宿舍"], "fans", 3); + } else if (id === "security") { + const cost = Math.round(getPop(st) * 2 + 80); + const before = st.sasaeng; + st.money -= cost; st.security = Math.min(4, st.security + 1); + st.sasaeng = Math.round(st.sasaeng * 0.55); + st.fatigue = clamp(st.fatigue + 5); + entries.push({ week: st.week, kind: "good", text: `🛡️ 安保团队升级到 Lv.${st.security},私生粉 ${fmtNum(before)} → ${fmtNum(st.sasaeng)},花费 ${cost} 万。` }); + } else if (id === "pr") { + const cost = Math.round(getPop(st) * 3); + const before = st.haters; + st.money -= cost; st.haters = Math.round(st.haters * 0.62); + st.mood = clamp(st.mood + 8); st.fatigue = clamp(st.fatigue + 6); + entries.push({ week: st.week, kind: "good", text: `🧯 公关团队下场,撤热搜 + 控评:黑粉 ${fmtNum(before)} → ${fmtNum(st.haters)},花费 ${cost} 万。` }); + pushDM(["终于有点公关的样子了", "黑粉这就哑了?", "控评速度可以"], "fans", 2); + } else if (id === "comeback") { + const pop = getPop(st); + const hr = hateRatioOf(st); + const tf = teamFactorOf(st); + const cp = cpHeatOf(st); + st.cooldown = 2; + + const eraSales = Math.round( + (st.fans * 0.015 + 15000 * st.tierMult + pop * 200) * + tf * (1 + cp / 250) * (1 - hr * 0.4) + ); + const beforeSales = st.albumSales; + st.albumSales += eraSales; + st.money += Math.round(eraSales / 220); + + let g = Math.round(eraSales * 0.95 + st.fans * 0.06 + pop * 250); + g += Math.round(cp * st.fans * 0.0012); + st.fans += g; + st.fatigue = clamp(st.fatigue + 24); + st.mood = clamp(st.mood + 7); + st.haters += Math.round(g * 0.1); + st.sasaeng += Math.round(g * 0.012); + + entries.push({ week: st.week, kind: "good", + text: `🎶 回归打歌!专辑首周销量 ${fmtNum(eraSales)} 张,粉丝 +${fmtNum(g)}(团魂 ×${tf.toFixed(2)},CP加成 +${Math.round(cp / 2.5)}%)。` }); + + MILESTONES.forEach((m, i) => { + if (beforeSales < m && st.albumSales >= m) { + st.fans += Math.round(st.fans * 0.03); + entries.push({ week: st.week, kind: "win", text: `🏅 累计销量突破 ${fmtNum(m)} 张,获「${MILE_NAMES[i]}」!粉丝 +3%。` }); + } + }); + + pushDM(FAN_DM, "fans", 5); + pushDM(HOT_DM, "hot", 2); + if (cp > 40) pushDM(CP_DM, "cp", 2); + + const rank = myRank(st); + const rankMult = [1.5, 0.95, 0.55, 0.28][rank - 1] || 0.2; + const p = clamp( + (0.06 + pop / 300 + (st.stats.vocal + st.stats.dance) / 900 + + st.wins * 0.006 - hr * 0.45 + clamp(Math.log10(st.albumSales + 1) * 0.03, 0, 0.15)) * rankMult, + 0, 0.88 + ); + if (Math.random() < p) { + st.wins += 1; + const bonus = Math.round(st.fans * 0.06); + st.fans += bonus; + entries.push({ week: st.week, kind: "win", text: `🏆 拿下音乐节目一位!累计 ${st.wins} 个,额外粉丝 +${fmtNum(bonus)}。` }); + pushDM(["一位!!!!!!", "哭了,终于", "数据屠榜了", "妈妈为你骄傲"], "win", 6); + pushDM(FAN_DM, "fans", 5); + } else { + entries.push({ week: st.week, kind: "info", text: `…这次只拿到候补(打歌榜第 ${rank} 位),与一位擦肩而过。` }); + pushDM(["差一点啊啊啊", "下次一定", "票投起来"], "fans", 3); + } + } else if (id === "show") { + const g = gain(rnd(3, 6)); + st.stats.variety = clamp(st.stats.variety + g); + const f = Math.round(getPop(st) * 400 + rnd(3000, 9000)); + st.fans += f; st.fatigue = clamp(st.fatigue + 12); st.mood = clamp(st.mood + 4); + st.haters += Math.round(f * 0.08); + entries.push({ week: st.week, kind: "info", text: `📺 综艺出演:综艺感 +${g}、粉丝 +${fmtNum(f)}` }); + } else if (id === "cf") { + const m = Math.round(getPop(st) * 4 + rnd(40, 260)); + const f = Math.round(getPop(st) * 150 + rnd(1000, 5000)); + st.money += m; st.fans += f; st.fatigue = clamp(st.fatigue + 9); + st.haters += Math.round(f * 0.1); + entries.push({ week: st.week, kind: "good", text: `💼 接下品牌代言:收入 +${m} 万、粉丝 +${fmtNum(f)}` }); + } else if (id === "practice") { + const k = pick(STATS); + const g = gain(rnd(4, 8)); + st.stats[k.key] = clamp(st.stats[k.key] + g); + st.fatigue = clamp(st.fatigue + 13); + entries.push({ week: st.week, kind: "info", text: `🎧 练习室加练:${k.name} +${g}(疲劳 +13)` }); + } else if (id === "fanmeet") { + const f = Math.round(getPop(st) * 300 + rnd(2000, 7000)); + st.fans += f; st.mood = clamp(st.mood + 11); st.fatigue = clamp(st.fatigue + 10); + entries.push({ week: st.week, kind: "good", text: `💞 粉丝见面会:粉丝 +${fmtNum(f)}、心情 +11` }); + } + + st.log = [...st.log, ...entries]; + commit(st); + } + + /* 谈心 */ + function talk(id) { + const prev = stateRef.current; + if (!prev.started || prev.over || prev.modal || prev.energy < 1) return; + const st = clone(prev); + const t = st.teammates.find((x) => x.id === id); + if (!t) return; + const d = rnd(14, 24); + t.rel = clamp(t.rel + d); + st.energy -= 1; st.mood = clamp(st.mood + 7); st.fatigue = clamp(st.fatigue + 5); + st.log = [...st.log, { week: st.week, kind: "good", text: `🫂 你和${t.name}单独聊了很久,把话说开了。关系 +${d}、心情 +7。` }]; + commit(st); + pushDM([`${t.name}和 TA 关系好好`, "这对我磕了", "队内关系看起来很暖"], "fans", 2); + } + + /* 营业CP */ + function cpBusy(id) { + const prev = stateRef.current; + if (!prev.started || prev.over || prev.modal) return; + if (prev.phase !== "idol" || prev.energy < 1) return; + const st = clone(prev); + const t = st.teammates.find((x) => x.id === id); + if (!t) return; + const d = rnd(16, 28); + t.cp = clamp(t.cp + d); + t.rel = clamp(t.rel + 2); + st.teammates.forEach((o) => { if (o.id !== id) o.rel = clamp(o.rel - rnd(2, 4)); }); + st.energy -= 1; st.mood = clamp(st.mood + 5); st.fatigue = clamp(st.fatigue + 6); + const f = Math.round(getPop(st) * 180 + rnd(1500, 6000)); + st.fans += f; + st.haters += Math.round(f * 0.16); + st.log = [...st.log, { week: st.week, kind: "cp", + text: `💕 你和${t.name}营业CP:CP热度 +${d}、粉丝 +${fmtNum(f)}(唯粉不满,其他队友关系微降)` }]; + commit(st); + pushDM(CP_DM, "cp", 3); + pushDM(SOLO_DM, "solo", 2); + } + + /* ================= 单飞抉择 ================= */ + function resolveChoice(c) { + const prev = stateRef.current; + if (!prev || prev.over || !c) return; + const st = clone(prev); + const entries = []; + st.modal = null; + + const t = st.teammates.find((x) => x.id === c.id); + if (!t) { commit(st); return; } + + if (c.act === "keep") { + if (st.money < c.cost) return; + st.money -= c.cost; + t.ambition = 26; + t.rel = clamp(t.rel + 14); + st.mood = clamp(st.mood + 6); + entries.push({ week: st.week, kind: "good", text: `🤝 你自掏 ${c.cost} 万违约金,把${t.name}留了下来。关系 +14、野心归零。` }); + } else { + const wasPartner = t.cp >= 50; + st.teammates = st.teammates.filter((x) => x.id !== t.id); + const solo = { + name: t.name + "(单飞)", emoji: t.emoji, color: t.color, + id: 100 + t.id, power: clamp(Math.round(myPower(st) * 0.85) + rnd(-6, 8)), wins: 0, isSolo: true, gone: false, + }; + st.rivals = [...st.rivals, solo]; + const loseFans = Math.round(st.fans * 0.09); + st.fans -= loseFans; + st.mood = clamp(st.mood - 10); + st.haters += Math.round(loseFans * 0.3); + entries.push({ week: st.week, kind: "bad", + text: `🚪 ${t.name}宣布单飞解约,带走了一批粉丝(-${fmtNum(loseFans)}),并且成了一位新的竞争对手。` }); + if (wasPartner) { + const riot = Math.round(st.fans * 0.06); + st.fans -= riot; + st.mood = clamp(st.mood - 12); + st.haters += Math.round(riot * 0.6); + entries.push({ week: st.week, kind: "bad", + text: `💔 你们的CP粉彻底塌房,集体脱粉回踩。粉丝再 -${fmtNum(riot)}、心情 -12。` }); + pushDM(["我的CP没了……", "塌房了塌房了", "再也不磕CP了", "谁负责啊"], "hater", 5); + } + pushDM(RIVAL_DM, "rival", 3); + } + + if (!st.teammates.length) { + st.over = { + title: "组合解散", sub: "GROUP DISBANDED", tone: "bad", + lines: ["队友全部离开,公司宣布组合活动终止。", "你成了没有团的「前偶像」——热搜挂了三天,然后没人再提。", "(关系值跌破 40 时,野心会加速膨胀,要早点谈心和团建)"], + }; + st.log = [...st.log, ...entries]; + st.modal = { title: st.over.title, sub: st.over.sub, lines: st.over.lines, tone: "bad" }; + commit(st); + return; + } + if (st.teammates.length === 1) { + st.fans = Math.round(st.fans * 0.94); + entries.push({ week: st.week, kind: "bad", text: "⚠️ 只剩一名队友,组合活动难度激增。粉丝 -6%。" }); + } + + st.log = [...st.log, ...entries]; + commit(st); + } + + /* ================= 进入下一周 ================= */ + function endWeek() { + const prev = stateRef.current; + if (!prev.started || prev.over || prev.modal) return; + + const st = clone(prev); + const entries = []; + let modal = null; + + /* 1. 健康崩溃 */ + if (st.fatigue >= 100) { + st.collapses += 1; st.fatigue = 25; st.energyPenalty = 1; st.mood = clamp(st.mood - 12); + entries.push({ week: st.week, kind: "bad", text: `💥 长期透支,你在练习室晕倒被送医。下周行动力 -1。(累计 ${st.collapses}/3 次)` }); + if (st.collapses >= 3) { + st.over = { title: "身体先垮了", sub: "BURNOUT ENDING", tone: "bad", + lines: ["连续三次健康崩溃,医生要求你立刻停止所有活动。", "公司宣布你因健康原因暂停全部行程。", "(人气没有命重要,下次记得睡觉)"] }; + st.modal = { title: st.over.title, sub: st.over.sub, lines: st.over.lines, tone: "bad" }; + st.log = [...st.log, ...entries]; + commit(st); return; + } + } + + /* 2. 自然恢复 */ + st.fatigue = clamp(st.fatigue - (9 + Math.floor(st.mood / 25))); + st.mood = clamp(st.mood + 3); + + /* 3. 偶像期系统 */ + if (st.phase === "idol") { + const pop = getPop(st); + + /* 3a. 私生粉 */ + if (st.sasaeng > 0) { + st.fatigue = clamp(st.fatigue + clamp(Math.round(st.sasaeng / 400), 0, 16)); + st.mood = clamp(st.mood - clamp(Math.round(st.sasaeng / 600), 0, 12)); + } + let saeGrow = Math.round(st.fans * 0.0025 + pop * 1.5 + rnd(0, 40)); + saeGrow = Math.max(0, Math.round(saeGrow * (1 - st.security * 0.15))); + st.sasaeng += saeGrow; + + /* 3b. 黑粉 */ + st.haters += Math.round(st.fans * 0.012 + pop * 30 + rnd(0, 600)); + const hr = hateRatioOf(st); + if (hr > 0.28) { + const drop = Math.round(st.fans * (hr - 0.28) * 0.9); + st.fans -= drop; st.mood = clamp(st.mood - 10); + entries.push({ week: st.week, kind: "bad", text: `🕳️ 黑粉占比升到 ${Math.round(hr * 100)}%,评论区失控。粉丝 -${fmtNum(drop)}、心情 -10。` }); + pushDM(HATER_DM, "hater", 4); + } else if (hr > 0.18) { + st.mood = clamp(st.mood - 4); + entries.push({ week: st.week, kind: "info", text: `⚠️ 黑粉占比 ${Math.round(hr * 100)}%,评论区开始出现负评。` }); + } + + /* 3c. 队友:关系衰减 + CP衰减 + 野心 */ + st.teammates.forEach((t) => { + t.rel = clamp(t.rel - 2); + t.cp = clamp(t.cp - 3); + t.ambition = clamp(t.ambition + rnd(1, 4) + (st.fans > 500000 ? 2 : 0) + (t.rel < 45 ? 3 : 0)); + }); + checkTeamBond(st, entries); + + /* 3d. CP 反噬 */ + st.teammates.forEach((t) => { + if (t.cp >= 75 && t.rel < 38 && Math.random() < 0.4) { + const loss = Math.round(st.fans * 0.08); + st.fans -= loss; st.mood = clamp(st.mood - 14); + st.haters += Math.round(loss * 0.4); + t.cp = Math.round(t.cp * 0.5); + entries.push({ week: st.week, kind: "bad", + text: `💔 CP粉塌房:你和${t.name}被拍到全程零互动,粉丝 -${fmtNum(loss)}、心情 -14。` }); + pushDM(["塌房塌房塌房", "我磕的是假的吗", "脱粉了", "CP粉集体自闭"], "hater", 4); + } + }); + const cpH = cpHeatOf(st); + if (cpH > 60 && Math.random() < 0.3) { + st.haters += Math.round(st.fans * 0.006 + 300); + st.mood = clamp(st.mood - 8); + entries.push({ week: st.week, kind: "bad", text: "⚔️ 团粉 / 唯粉 / CP粉三方混战,超话一片混乱。心情 -8、黑粉上升。" }); + pushDM(SOLO_DM, "solo", 3); + pushDM(CP_DM, "cp", 2); + } + + /* 3e. 竞争团体 */ + st.rivals.forEach((r) => { + r.power = clamp(r.power + rnd(0, 2)); + if (Math.random() < 0.12) r.power = clamp(r.power + rnd(2, 5)); + if (Math.random() < 0.15) r.wins += 1; + }); + const rank = myRank(st); + if (rank > 1) { + const drift = Math.round(st.fans * 0.005 * (rank - 1)); + st.fans = Math.max(0, st.fans - drift); + } + if (rank !== st.lastRank) { + entries.push({ week: st.week, kind: "rival", + text: rank < st.lastRank + ? `📈 打歌榜上升到第 ${rank} 位,气势正盛。` + : `📉 打歌榜跌到第 ${rank} 位,部分粉丝流向竞争对手。` }); + st.lastRank = rank; + } + + /* 3f. 单飞危机 */ + const rebel = st.teammates.find((t) => t.ambition >= 80 && t.rel < 70); + if (rebel && Math.random() < 0.42) { + const keepCost = Math.round(getPop(st) * 8 + 200); + modal = { + title: "单飞危机", + sub: "SOLO CRISIS", // 修复:原先误写成 t => t,会直接崩组件 + tone: "bad", + lines: [ + `${rebel.name}的经纪约快到期了。`, + "TA说:「我想试试一个人站在舞台上是什么感觉。」", + `当前队内关系:${Math.round(rebel.rel)}(偏低会加速 TA 的决定)`, + `你可以支付 ${keepCost} 万违约金挽留,或者祝福 TA。`, + ], + choices: [ + { label: `🤝 支付 ${keepCost} 万挽留`, act: "keep", id: rebel.id, cost: keepCost }, + { label: "🚪 祝福 TA 单飞", act: "letgo", id: rebel.id }, + ], + }; + entries.push({ week: st.week, kind: "bad", text: `⚠️ ${rebel.name}提出想要单飞,你们在练习室谈了很久。` }); + } + } + + /* 4. 随机事件 */ + if (!modal && Math.random() < 0.62) { + const ev = rollEvent(st); + const text = ev.fn(st); + entries.push({ week: st.week, kind: ev.kind || "info", text }); + if (ev.kind === "bad" && Math.random() < 0.4) pushDM(HATER_DM, "hater", 3); + if (ev.kind === "good" && Math.random() < 0.4) pushDM(FAN_DM, "fans", 2); + if (ev.kind === "rival") pushDM(RIVAL_DM, "rival", 2); + } + + /* 5. 月末考核(lastExam 双保险:同一周只结算一次) */ + if (st.phase === "trainee" && EXAM_WEEKS.includes(st.week) && st.lastExam !== st.week) { + st.lastExam = st.week; + const total = st.stats.vocal + st.stats.dance + st.stats.visual + st.stats.variety; + const score = Math.round(total / 4 + rnd(-3, 3)); + const line = st.week === EXAM_WEEKS[0] ? 24 : 42; + if (score >= line) { + entries.push({ week: st.week, kind: "good", text: `📋 月末考核评分 ${score}(及格线 ${line}),顺利通过。` }); + modal = { title: "月末考核 · 通过", sub: "MONTHLY EVALUATION", tone: "good", + lines: [`你的评分:${score}`, `及格线:${line}`, "老师点了点头,你暂时安全。"] }; + } else { + st.warnings += 1; + entries.push({ week: st.week, kind: "bad", text: `📋 月末考核评分 ${score}(及格线 ${line}),未达标!警告 ${st.warnings}/2。` }); + if (st.warnings >= 2) { + st.over = { title: "被劝退了", sub: "TRAINEE DROPPED", tone: "bad", + lines: [`你的评分:${score},及格线 ${line}。`, "两次考核未达标,公司终止了你的练习生合约。", "(先堆属性、再靠休息控疲劳,会稳很多)"] }; + modal = { title: st.over.title, sub: st.over.sub, lines: st.over.lines, tone: "bad" }; + } else { + modal = { title: "月末考核 · 未通过", sub: "MONTHLY EVALUATION", tone: "bad", + lines: [`你的评分:${score}`, `及格线:${line}`, `警告次数:${st.warnings} / 2`, "再来一次就要走人了。"] }; + } + } + } + + /* 6. 推进周数(无条件推进,避免考核弹窗把周数卡住) */ + if (!st.over) { + st.week += 1; + st.energy = Math.max(1, st.maxEnergy - st.energyPenalty); + st.energyPenalty = 0; + st.cooldown = Math.max(0, st.cooldown - 1); + } + + /* 7. 出道 / 终局 */ + if (!st.over && st.phase === "trainee" && st.week > TRAINEE_WEEKS) { + const examModal = modal; // 第 8 周考核弹窗 + doDebut(st, entries); + if (st.modal && examModal) { // 撞车时合并,不丢弃考核结果 + st.modal = { + ...st.modal, + lines: [...examModal.lines, "————", ...st.modal.lines], + }; + } + if (st.modal) modal = st.modal; + } else if (!st.over && st.phase === "idol" && st.week > TOTAL_WEEKS) { + const e = finalEnding(st); + st.over = e; + modal = { title: e.title, sub: e.sub, lines: e.lines, tone: e.tone }; + pushDM(["陪你走完了这一程", "谢谢你出道", "下一个五年也一起", "永远支持你"], "fans", 5); + } + + st.log = [...st.log, ...entries]; + if (modal) st.modal = modal; + commit(st); + } + + function dismiss() { commit({ ...stateRef.current, modal: null }); } + function restart() { setDanmaku([]); commit(initState(true)); } + + /* ================= 派生值 ================= */ + const pop = getPop(s); + const actions = s.phase === "trainee" ? TRAINEE_ACTIONS : IDOL_ACTIONS; + const totalStats = STATS.reduce((a, x) => a + s.stats[x.key], 0); + const hateRatio = hateRatioOf(s); + const teamAvg = teamAvgOf(s); + const teamFactor = teamFactorOf(s); + const cpHeat = cpHeatOf(s); + const prCost = Math.round(pop * 3); + const secCost = Math.round(pop * 2 + 80); + const rank = myRank(s); + const accent = + s.modal && s.modal.tone === "bad" ? "#f87171" + : s.modal && s.modal.tone === "win" ? "#fbbf24" + : s.modal && s.modal.tone === "info" ? "#a78bfa" + : "#4ade80"; + const goldBtn = { background: "linear-gradient(90deg,#22d3ee,#a855f7,#f472b6)" }; + + const chart = [ + { key: "me", name: "我(本团)", emoji: "⭐", color: "#f472b6", power: myPower(s), isMe: true }, + ...s.rivals.map((r) => ({ key: "r" + r.id, name: r.name, emoji: r.emoji, color: r.color, power: r.power, isMe: false, wins: r.wins })), + ].sort((a, b) => b.power - a.power); + + /* ================= 开始页 ================= */ + if (!s.started) { + return ( +
+ +
+
+
IDOL SIMULATOR · FULL
+

+ 爱豆模拟器 +

+
练习生 → 出道 → 顶流,共 {TOTAL_WEEKS} 周
+
+ +
+
🎯 前 8 周:练属性、过月末考核(第 4、8 周),同时和同期练习生打好关系。
+
👯 队友关系:均值决定团魂倍率 ×0.85~1.15,直接影响回归销量与一位概率。
+
💕 CP粉:营业CP换粉丝和销量加成,但唯粉会反噬;CP高而关系低会塌房。
+
💿 专辑销量:回归才产生,转化为收入与人气,五档认证可解锁。
+
🚪 单飞危机:队友野心值会增长,爆表时提出单飞,可花钱挽留——放走就成对手。
+
📸 私生粉:每周扣疲劳和心情,靠安保升级压制。
+
🏆 竞争团体:3 个对手实时成长,打歌榜排名直接决定一位概率。
+
+ + +
+
+ ); + } + + const disabledBase = !!s.over; + + /* ================= 主界面 ================= */ + return ( +
+ + + {/* 弹幕层 */} + {s.danmakuOn && ( +
+ {danmaku.map((b) => ( +
+ {b.text} +
+ ))} +
+ )} + +
+ {/* 标题 */} +
+
+

+ 爱豆模拟器 +

+
+ {s.phase === "trainee" ? "练 习 生 期" : "偶 像 期" + (s.tier ? " · " + s.tier : "")} +
+
+
+ +
+
总计 {TOTAL_WEEKS} 周
+
第 {s.week} 周
+
+
+
+ + {/* 资源 */} +
+ {[ + { label: "粉丝", value: fmtNum(s.fans), color: "#f472b6" }, + { label: "黑粉", value: fmtNum(s.haters), color: "#f87171" }, + { label: "私生粉", value: fmtNum(s.sasaeng), color: "#c084fc" }, + { label: "累计销量", value: fmtNum(s.albumSales), color: "#22d3ee" }, + { label: "一位", value: s.wins, color: "#fbbf24" }, + { label: "收入(万)", value: fmtNum(s.money), color: "#4ade80" }, + ].map((c) => ( +
+
{c.label}
+
{c.value}
+
+ ))} +
+ + {/* 舆论面板 */} +
+
+
🌐 舆论面板
+
+ 人气 {pop} + {" · "}黑粉 0.28 ? "#f87171" : hateRatio > 0.18 ? "#fbbf24" : "#4ade80" }}>{Math.round(hateRatio * 100)}% +
+
+
+
+
+
+
+ 粉丝 {fmtNum(s.fans)} + 黑粉 {fmtNum(s.haters)} +
+ + {s.phase === "idol" && ( +
+
+ 📸 私生粉压力 + {fmtNum(s.sasaeng)} · 安保 Lv.{s.security} +
+
+
+
+ {s.sasaeng > 2500 && ( +
⚠️ 私生粉过多,每周持续消耗疲劳与心情,建议安保升级。
+ )} +
+ )} +
+ + {/* 打歌榜 */} + {s.phase === "idol" && chart.length > 1 && ( +
+
+
🏆 打歌榜
+
+ 当前排名 第 {rank} 位 +
+
+
+ {chart.map((c, i) => ( +
+ {i + 1} + {c.emoji} + {c.name} + {!c.isMe && 一位 {c.wins}} +
+
+
+ {c.power} +
+ ))} +
+
+ )} + + {/* 属性面板 */} +
+
+
能力面板
+
综合实力值 {totalStats}
+
+
+ {STATS.map((x) => ( +
+
+ {x.icon} {x.name} + {Math.round(s.stats[x.key])} +
+
+
+
+
+ ))} +
+
+
+
+ 😵 疲劳 + 80 ? "#f87171" : "#fbbf24" }}>{Math.round(s.fatigue)}/100 +
+
+
80 ? "#f87171" : "linear-gradient(90deg,#fbbf24,#f97316)" }} /> +
+
+
+
+ 🙂 心情 + {Math.round(s.mood)}/100 +
+
+
+
+
+
+
+ + {/* 队友 */} + {s.teammates.length > 0 && ( +
+
+
👯 队友关系
+
+ 均值 {Math.round(teamAvg)} + 团魂 ×{teamFactor.toFixed(2)} + {s.phase === "idol" && CP {Math.round(cpHeat)}} +
+
+
+ {s.teammates.map((t) => { + const tier = relTier(t.rel); + const canAct = !disabledBase && !s.modal && s.energy >= 1; + const ambRisk = t.ambition >= 65; + return ( +
+
+
{t.emoji}
+
+
{t.name}
+
{t.role} · {t.trait}
+
+
+ +
+ {tier.name} + {Math.round(t.rel)} +
+
+
+
+ + {s.phase === "idol" && ( + <> +
+ 💕 CP热度 + {Math.round(t.cp)} +
+
+
+
+
+ 🔥 野心 + {Math.round(t.ambition)} +
+
+
+
+ {ambRisk && t.rel < 70 && ( +
⚠️ 野心过高且关系一般,有单飞风险
+ )} + + )} + +
+ + {s.phase === "idol" && ( + + )} +
+
+ ); + })} +
+ {teamAvg >= 82 &&
💫 团魂 MAX:回归收益与一位概率获得最大加成。
} + {teamAvg < 25 &&
💢 关系已到冰点,随时可能爆发队内不和,快去团建。
} +
+ )} + + {/* 行动区 */} +
+
+
本周安排
+
+ 行动点 +
+ {Array.from({ length: s.maxEnergy }).map((_, i) => ( +
+ ))} +
+
+
+ +
+ {actions.map((a) => { + let disabled = disabledBase || !!s.modal || s.energy < a.cost || (a.id === "comeback" && s.cooldown > 0); + if (a.id === "pr" && s.money < prCost) disabled = true; + if (a.id === "security" && s.money < secCost) disabled = true; + if (a.id === "teambuild" && !s.teammates.length) disabled = true; + return ( + + ); + })} +
+ + +
+ + {/* 行程记录 */} +
+
+
📰 行程记录
+
最新在上
+
+
+ {[...s.log].reverse().slice(0, 70).map((l, i) => ( +
+ {l.week ? W{l.week} : null} + {l.text} +
+ ))} +
+
+ +
从练习生到五女一 · 每一步都算数
+
+ + {/* 弹窗 */} + {s.modal && ( +
+
+ {typeof s.modal.sub === "string" && s.modal.sub && ( +
{s.modal.sub}
+ )} +
{s.modal.title}
+
+ {(s.modal.lines || []).filter((l) => typeof l === "string").map((l, i) => ( +
{l}
+ ))} +
+ + {s.modal.choices && !s.over ? ( +
+ {s.modal.choices.map((c, i) => { + const dis = c.cost != null && s.money < c.cost; + return ( + + ); + })} +
+ ) : ( + + )} +
+
+ )} +
+ ); +}