Files
idol-simulator/idol-simulator.html

1267 lines
67 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>爱豆模拟器 · Idol Simulator</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
html, body { background: #020617; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 8px; }
</style>
</head>
<body>
<div id="root"></div>
<div id="boot" style="color:#64748b;font:14px/1.6 system-ui;text-align:center;padding:80px 20px">
正在加载 React / Babel / Tailwind(需要联网)…
</div>
<script src="https://unpkg.com/@babel/standalone@7.24.7/babel.min.js"></script>
<script type="text/babel" data-type="module" data-presets="react">
import { useState, useEffect, useRef } from "https://esm.sh/react@18.3.1";
import { createRoot } from "https://esm.sh/react-dom@18.3.1/client";
/* ================= 工具 ================= */
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}。`, "团糊了,公司准备解散。", "深夜你刷到别人拿一位的视频,沉默了很久。"] };
}
/* ================= 主组件 ================= */
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);
}
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;
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;
}
}
st.fatigue = clamp(st.fatigue - (9 + Math.floor(st.mood / 25)));
st.mood = clamp(st.mood + 3);
if (st.phase === "idol") {
const pop = getPop(st);
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;
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)}%,评论区开始出现负评。` });
}
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);
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);
}
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;
}
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",
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}提出想要单飞,你们在练习室谈了很久。` });
}
}
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);
}
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`, "再来一次就要走人了。"] };
}
}
}
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);
}
if (!st.over && st.phase === "trainee" && st.week > TRAINEE_WEEKS) {
const examModal = modal;
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 (
<div className="min-h-screen bg-slate-950 text-slate-100 flex items-center justify-center p-6">
<style>{`@keyframes dmMove{from{transform:translateX(0)}to{transform:translateX(calc(-100vw - 100%))}}`}</style>
<div className="max-w-md w-full">
<div className="text-center mb-7">
<div className="text-xs tracking-widest text-slate-500 mb-3">IDOL SIMULATOR · FULL</div>
<h1 className="text-4xl font-black tracking-wider mb-2"
style={{ backgroundImage: "linear-gradient(90deg,#22d3ee,#a855f7,#f472b6,#fbbf24)", WebkitBackgroundClip: "text", backgroundClip: "text", color: "transparent" }}>
爱豆模拟器
</h1>
<div className="text-sm text-slate-400">练习生 → 出道 → 顶流,共 {TOTAL_WEEKS} 周</div>
</div>
<div className="rounded-2xl border border-white/10 bg-white/5 p-5 mb-6 space-y-2.5 text-sm text-slate-300 leading-relaxed">
<div>🎯 <b className="text-slate-100">前 8 周</b>:练属性、过月末考核(第 4、8 周),同时和同期练习生打好关系。</div>
<div>👯 <b className="text-slate-100">队友关系</b>:均值决定团魂倍率 ×0.85~1.15,直接影响回归销量与一位概率。</div>
<div>💕 <b className="text-slate-100">CP粉</b>:营业CP换粉丝和销量加成,但唯粉会反噬;CP高而关系低会<b className="text-slate-100">塌房</b>。</div>
<div>💿 <b className="text-slate-100">专辑销量</b>:回归才产生,转化为收入与人气,五档认证可解锁。</div>
<div>🚪 <b className="text-slate-100">单飞危机</b>:队友野心值会增长,爆表时提出单飞,可花钱挽留——放走就成对手。</div>
<div>📸 <b className="text-slate-100">私生粉</b>:每周扣疲劳和心情,靠安保升级压制。</div>
<div>🏆 <b className="text-slate-100">竞争团体</b>:3 个对手实时成长,打歌榜排名直接决定一位概率。</div>
</div>
<button onClick={() => commit(initState(true))}
className="w-full py-4 rounded-2xl font-black tracking-widest text-slate-950 text-lg hover:brightness-110 active:scale-95 transition"
style={goldBtn}>
开 始 练 习
</button>
</div>
</div>
);
}
const disabledBase = !!s.over;
return (
<div className="min-h-screen bg-slate-950 text-slate-100 antialiased pb-10"
style={{ fontFamily: '"PingFang SC","Microsoft YaHei",system-ui,sans-serif' }}>
<style>{`@keyframes dmMove{from{transform:translateX(0)}to{transform:translateX(calc(-100vw - 100%))}}`}</style>
{s.danmakuOn && (
<div className="fixed inset-0 z-40 pointer-events-none overflow-hidden">
{danmaku.map((b) => (
<div key={b.id} className="absolute whitespace-nowrap font-bold"
style={{
top: b.top + "%", left: "100%", fontSize: "13px", color: b.color,
textShadow: "0 0 8px rgba(0,0,0,.95), 0 1px 3px rgba(0,0,0,.95)",
animation: `dmMove ${b.dur}s linear forwards`, willChange: "transform",
}}>
{b.text}
</div>
))}
</div>
)}
<div className="max-w-3xl mx-auto px-4 py-5 sm:py-8 relative">
<div className="flex items-end justify-between gap-3 mb-4">
<div>
<h1 className="text-2xl sm:text-3xl font-black tracking-wider"
style={{ backgroundImage: "linear-gradient(90deg,#22d3ee,#a855f7,#f472b6)", WebkitBackgroundClip: "text", backgroundClip: "text", color: "transparent" }}>
爱豆模拟器
</h1>
<div className="text-xs tracking-widest text-slate-500 mt-1">
{s.phase === "trainee" ? "练 习 生 期" : "偶 像 期" + (s.tier ? " · " + s.tier : "")}
</div>
</div>
<div className="flex items-center gap-3">
<button onClick={() => commit({ ...s, danmakuOn: !s.danmakuOn })}
className="text-xs px-3 py-1.5 rounded-lg border border-white/15 bg-white/5 hover:bg-white/10 transition">
💬 弹幕 {s.danmakuOn ? "开" : "关"}
</button>
<div className="text-right shrink-0">
<div className="text-xs text-slate-500">总计 {TOTAL_WEEKS} 周</div>
<div className="text-xl sm:text-2xl font-black tabular-nums">第 {s.week} 周</div>
</div>
</div>
</div>
<div className="grid grid-cols-3 sm:grid-cols-6 gap-2 mb-3">
{[
{ 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) => (
<div key={c.label} className="rounded-xl border border-white/10 bg-white/5 px-2 py-2 text-center">
<div className="text-xs text-slate-500">{c.label}</div>
<div className="text-base sm:text-lg font-black tabular-nums" style={{ color: c.color }}>{c.value}</div>
</div>
))}
</div>
<div className="rounded-2xl border border-white/10 bg-white/5 p-4 mb-4">
<div className="flex items-center justify-between mb-2">
<div className="text-sm font-bold">🌐 舆论面板</div>
<div className="text-xs text-slate-500">
人气 <span className="text-cyan-300 font-bold tabular-nums">{pop}</span>
{" · "}黑粉 <span className="font-bold tabular-nums" style={{ color: hateRatio > 0.28 ? "#f87171" : hateRatio > 0.18 ? "#fbbf24" : "#4ade80" }}>{Math.round(hateRatio * 100)}%</span>
</div>
</div>
<div className="h-3 rounded-full bg-white/10 overflow-hidden flex">
<div className="h-full transition-all duration-500"
style={{ width: (100 - hateRatio * 100) + "%", background: "linear-gradient(90deg,#22d3ee,#f472b6)" }} />
<div className="h-full transition-all duration-500"
style={{ width: (hateRatio * 100) + "%", background: "linear-gradient(90deg,#ef4444,#7f1d1d)" }} />
</div>
<div className="flex justify-between text-xs mt-2">
<span className="text-pink-300">粉丝 {fmtNum(s.fans)}</span>
<span className="text-red-400">黑粉 {fmtNum(s.haters)}</span>
</div>
{s.phase === "idol" && (
<div className="mt-3 pt-3 border-t border-white/10">
<div className="flex items-center justify-between text-xs mb-1">
<span className="text-slate-400">📸 私生粉压力</span>
<span className="tabular-nums font-bold text-purple-300">{fmtNum(s.sasaeng)} · 安保 Lv.{s.security}</span>
</div>
<div className="h-2 rounded-full bg-white/10 overflow-hidden">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(s.sasaeng / 90) + "%", background: "linear-gradient(90deg,#a855f7,#c084fc)" }} />
</div>
{s.sasaeng > 2500 && (
<div className="text-xs text-purple-300 mt-1.5">⚠️ 私生粉过多,每周持续消耗疲劳与心情,建议安保升级。</div>
)}
</div>
)}
</div>
{s.phase === "idol" && chart.length > 1 && (
<div className="rounded-2xl border border-white/10 bg-white/5 p-4 mb-4">
<div className="flex items-center justify-between mb-3">
<div className="text-sm font-bold">🏆 打歌榜</div>
<div className="text-xs text-slate-500">
当前排名 <span className="font-bold tabular-nums" style={{ color: rank === 1 ? "#fbbf24" : "#94a3b8" }}>第 {rank} 位</span>
</div>
</div>
<div className="space-y-1.5">
{chart.map((c, i) => (
<div key={c.key} className={"flex items-center gap-2 rounded-lg px-2 py-1.5 " + (c.isMe ? "bg-pink-500/10 border border-pink-400/30" : "bg-white/5")}>
<span className="text-xs font-black tabular-nums w-5" style={{ color: i === 0 ? "#fbbf24" : "#64748b" }}>{i + 1}</span>
<span className="text-base">{c.emoji}</span>
<span className="text-xs font-bold flex-1 truncate" style={{ color: c.color }}>{c.name}</span>
{!c.isMe && <span className="text-xs text-slate-500 tabular-nums">一位 {c.wins}</span>}
<div className="w-20 sm:w-28 h-1.5 rounded-full bg-white/10 overflow-hidden">
<div className="h-full rounded-full transition-all duration-500" style={{ width: c.power + "%", background: c.color }} />
</div>
<span className="text-xs tabular-nums font-bold w-7 text-right" style={{ color: c.color }}>{c.power}</span>
</div>
))}
</div>
</div>
)}
<div className="rounded-2xl border border-white/10 bg-white/5 p-4 mb-4">
<div className="flex items-center justify-between mb-3">
<div className="text-sm font-bold">能力面板</div>
<div className="text-xs text-slate-500">综合实力值 <span className="text-slate-300 font-bold tabular-nums">{totalStats}</span></div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3">
{STATS.map((x) => (
<div key={x.key}>
<div className="flex justify-between text-xs mb-1">
<span className="text-slate-300">{x.icon} {x.name}</span>
<span className="tabular-nums font-bold" style={{ color: x.color }}>{Math.round(s.stats[x.key])}</span>
</div>
<div className="h-2 rounded-full bg-white/10 overflow-hidden">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(s.stats[x.key]) + "%", background: "linear-gradient(90deg," + x.color + "," + x.color + "88)" }} />
</div>
</div>
))}
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3 mt-4 pt-4 border-t border-white/10">
<div>
<div className="flex justify-between text-xs mb-1">
<span className="text-slate-300">😵 疲劳</span>
<span className="tabular-nums font-bold" style={{ color: s.fatigue > 80 ? "#f87171" : "#fbbf24" }}>{Math.round(s.fatigue)}/100</span>
</div>
<div className="h-2 rounded-full bg-white/10 overflow-hidden">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(s.fatigue) + "%", background: s.fatigue > 80 ? "#f87171" : "linear-gradient(90deg,#fbbf24,#f97316)" }} />
</div>
</div>
<div>
<div className="flex justify-between text-xs mb-1">
<span className="text-slate-300">🙂 心情</span>
<span className="tabular-nums font-bold" style={{ color: "#a78bfa" }}>{Math.round(s.mood)}/100</span>
</div>
<div className="h-2 rounded-full bg-white/10 overflow-hidden">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(s.mood) + "%", background: "linear-gradient(90deg,#a855f7,#6366f1)" }} />
</div>
</div>
</div>
</div>
{s.teammates.length > 0 && (
<div className="rounded-2xl border border-white/10 bg-white/5 p-4 mb-4">
<div className="flex items-center justify-between mb-3">
<div className="text-sm font-bold">👯 队友关系</div>
<div className="text-xs text-slate-500 flex gap-3">
<span>均值 <span className="font-bold tabular-nums" style={{ color: relTier(teamAvg).color }}>{Math.round(teamAvg)}</span></span>
<span>团魂 <span className="font-bold tabular-nums text-cyan-300">×{teamFactor.toFixed(2)}</span></span>
{s.phase === "idol" && <span>CP <span className="font-bold tabular-nums text-fuchsia-300">{Math.round(cpHeat)}</span></span>}
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
{s.teammates.map((t) => {
const tier = relTier(t.rel);
const canAct = !disabledBase && !s.modal && s.energy >= 1;
const ambRisk = t.ambition >= 65;
return (
<div key={t.id} className="rounded-xl border border-white/10 bg-white/5 p-3">
<div className="flex items-center gap-2 mb-2">
<div className="w-9 h-9 rounded-full flex items-center justify-center text-lg shrink-0"
style={{ background: t.color + "22", border: "1px solid " + t.color + "66" }}>{t.emoji}</div>
<div className="min-w-0">
<div className="font-bold text-sm truncate">{t.name}</div>
<div className="text-xs text-slate-500 truncate">{t.role} · {t.trait}</div>
</div>
</div>
<div className="flex justify-between text-xs mb-1">
<span style={{ color: tier.color }}>{tier.name}</span>
<span className="tabular-nums font-bold" style={{ color: tier.color }}>{Math.round(t.rel)}</span>
</div>
<div className="h-1.5 rounded-full bg-white/10 overflow-hidden mb-2">
<div className="h-full rounded-full transition-all duration-500" style={{ width: clamp(t.rel) + "%", background: tier.color }} />
</div>
{s.phase === "idol" && (
<>
<div className="flex justify-between text-xs mb-1">
<span className="text-fuchsia-300">💕 CP热度</span>
<span className="tabular-nums font-bold text-fuchsia-300">{Math.round(t.cp)}</span>
</div>
<div className="h-1.5 rounded-full bg-white/10 overflow-hidden mb-2">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(t.cp) + "%", background: "linear-gradient(90deg,#e879f9,#c084fc)" }} />
</div>
<div className="flex justify-between text-xs mb-1">
<span className={ambRisk ? "text-orange-300" : "text-slate-500"}>🔥 野心</span>
<span className="tabular-nums font-bold" style={{ color: ambRisk ? "#fb923c" : "#64748b" }}>{Math.round(t.ambition)}</span>
</div>
<div className="h-1.5 rounded-full bg-white/10 overflow-hidden mb-2">
<div className="h-full rounded-full transition-all duration-500"
style={{ width: clamp(t.ambition) + "%", background: ambRisk ? "#fb923c" : "#475569" }} />
</div>
{ambRisk && t.rel < 70 && (
<div className="text-xs text-orange-300 mb-2">⚠️ 野心过高且关系一般,有单飞风险</div>
)}
</>
)}
<div className="flex gap-1.5">
<button onClick={() => talk(t.id)} disabled={!canAct}
className={"flex-1 py-1.5 rounded-lg text-xs font-bold border border-white/10 transition " +
(canAct ? "bg-white/5 hover:bg-white/15 active:scale-95" : "opacity-30 cursor-not-allowed")}>
🫂 谈心
</button>
{s.phase === "idol" && (
<button onClick={() => cpBusy(t.id)} disabled={!canAct}
className={"flex-1 py-1.5 rounded-lg text-xs font-bold border transition " +
(canAct ? "bg-fuchsia-500/15 border-fuchsia-400/30 hover:bg-fuchsia-500/25 active:scale-95" : "opacity-30 cursor-not-allowed border-white/10")}>
💕 营业
</button>
)}
</div>
</div>
);
})}
</div>
{teamAvg >= 82 && <div className="text-xs text-pink-300 mt-3">💫 团魂 MAX:回归收益与一位概率获得最大加成。</div>}
{teamAvg < 25 && <div className="text-xs text-red-400 mt-3">💢 关系已到冰点,随时可能爆发队内不和,快去团建。</div>}
</div>
)}
<div className="rounded-2xl border border-white/10 bg-white/5 p-4 mb-4">
<div className="flex items-center justify-between mb-3">
<div className="text-sm font-bold">本周安排</div>
<div className="flex items-center gap-2">
<span className="text-xs text-slate-500">行动点</span>
<div className="flex gap-1.5">
{Array.from({ length: s.maxEnergy }).map((_, i) => (
<div key={i} className="w-3.5 h-3.5 rounded-full transition"
style={{ background: i < s.energy ? "#a855f7" : "rgba(255,255,255,0.12)", boxShadow: i < s.energy ? "0 0 10px #a855f7" : "none" }} />
))}
</div>
</div>
</div>
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2">
{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 (
<button key={a.id} onClick={() => act(a.id)} disabled={disabled}
className={"text-left rounded-xl border border-white/10 bg-white/5 p-3 transition " +
(disabled ? "opacity-30 cursor-not-allowed" : "hover:bg-white/10 active:scale-95")}>
<div className="text-xl mb-1">{a.icon}</div>
<div className="font-bold text-sm">{a.name}</div>
<div className="text-xs text-slate-400 leading-tight mt-0.5">{a.desc}</div>
<div className="text-xs text-slate-500 mt-1">
消耗 {a.cost}
{a.id === "comeback" && s.cooldown > 0 ? " · 冷却中" : ""}
{a.id === "pr" ? " · " + prCost + "万" : ""}
{a.id === "security" ? " · " + secCost + "万" : ""}
</div>
</button>
);
})}
</div>
<button onClick={endWeek} disabled={disabledBase || !!s.modal}
className={"w-full mt-3 py-3 rounded-xl font-black tracking-widest text-slate-950 transition " +
(disabledBase || !!s.modal ? "opacity-30 cursor-not-allowed" : "hover:brightness-110 active:scale-95")}
style={goldBtn}>
进入下一周 →
</button>
</div>
<div className="rounded-2xl border border-white/10 bg-white/5 p-4">
<div className="flex items-center justify-between mb-2">
<div className="text-sm font-bold">📰 行程记录</div>
<div className="text-xs text-slate-500">最新在上</div>
</div>
<div className="space-y-1.5 max-h-64 overflow-y-auto pr-1">
{[...s.log].reverse().slice(0, 70).map((l, i) => (
<div key={i} className="text-xs leading-relaxed" style={{ color: LOG_COLORS[l.kind] || "#cbd5e1" }}>
{l.week ? <span className="text-slate-600 mr-1">W{l.week}</span> : null}
{l.text}
</div>
))}
</div>
</div>
<div className="text-center text-xs text-slate-600 mt-6 tracking-widest">从练习生到五女一 · 每一步都算数</div>
</div>
{s.modal && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/85 p-5">
<div className="max-w-sm w-full rounded-2xl border border-white/15 bg-slate-900 p-6 text-center shadow-2xl">
{typeof s.modal.sub === "string" && s.modal.sub && (
<div className="text-xs tracking-widest mb-2" style={{ color: accent }}>{s.modal.sub}</div>
)}
<div className="text-2xl font-black mb-4 tracking-wide" style={{ color: accent }}>{s.modal.title}</div>
<div className="space-y-2 mb-5">
{(s.modal.lines || []).filter((l) => typeof l === "string").map((l, i) => (
<div key={i} className="text-sm text-slate-300 leading-relaxed">{l}</div>
))}
</div>
{s.modal.choices && !s.over ? (
<div className="space-y-2">
{s.modal.choices.map((c, i) => {
const dis = c.cost != null && s.money < c.cost;
return (
<button key={i} disabled={dis} onClick={() => resolveChoice(c)}
className={"w-full py-3 rounded-xl font-bold text-sm border transition " +
(dis
? "opacity-30 cursor-not-allowed border-white/10 bg-white/5"
: i === 0
? "text-slate-950 hover:brightness-110 active:scale-95 border-transparent"
: "border-white/15 bg-white/5 hover:bg-white/15 active:scale-95")}
style={i === 0 && !dis ? goldBtn : undefined}>
{c.label}{dis ? "(资金不足)" : ""}
</button>
);
})}
</div>
) : (
<button onClick={() => (s.over ? restart() : dismiss())}
className="w-full py-3 rounded-xl font-black tracking-widest text-slate-950 hover:brightness-110 active:scale-95 transition"
style={goldBtn}>
{s.over ? "重 新 开 始" : "确 认"}
</button>
)}
</div>
</div>
)}
</div>
);
}
const boot = document.getElementById("boot");
if (boot) boot.remove();
createRoot(document.getElementById("root")).render(<IdolSimulator />);
</script>
</body>
</html>