版本比较
oj运维模拟器(修改版)
正文
增加 179 行删除 173 行
27 行未改动2829303132323334353621 行未改动5859606162626364656610 行未改动77787980818182838485858687888990919293949595969798999910010110210310410510610710710810911011133 行未改动14514614714814914915015115215215315415515615715415515615715815916016116216316416516516616716816918 行未改动1881891901911921931941921931941951961971981992002002012022032042052052062072082096 行未改动2162172182192202202212222232242252262272282282292302312322332342352362372382382392402412422432442452462472482492482492502512522534 行未改动25825926026126226226326426526610 行未改动27727827928028128128228328428528628728828828929029029129229329411 行未改动30630730830931031031131231231331431431531631731831932032132132232332432532632732832832933033133233333433533533633733833933934034134234310 行未改动3543553563573583583593603613623623633643653663673683693703713723723733743753763773783793793803813823832 行未改动38638738838939039039139239339420 行未改动41541641741841941942042142242317 行未改动44144244344444544644544644744844945024 行未改动47547647747847947948048148248348348448548648748848949049149249249349449549619 行未改动5165175185195205205215225235235245255265275285295295305315325335345355365375385395395405415425435435445455455465475485495505515525525535545555565575585595605615625625635645645655665675688 行未改动57757857958058158258158258358458558611 行未改动5985996006016026026036046046056066076086096106116126136096106116126136146156166166176186196206216226236246246256266276283 行未改动63263363463563663763663763863964064064164264364364464564664664764864965065165265365465365465565665765865965966066166266366466466566666766827 行未改动6966976986997007007017027037037047057067074 行未改动7127137147157167177187167177187197207217227237237247257267267277287297307317327337347357367347357367377387397397407417417427437447457467477487487497507517527537547527537547557567577577587597607607617627637644 行未改动7697707717727737747737747757767777782 行未改动7817827837847857857867877887897897907917927937937947957967974 行未改动8028038048058068068078088098107 行未改动8188198208218228228238248258268278288258268278288298308318328338348358368368378388398408418428438438448458468478488488498508518528538548558568568578588598598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958966 行未改动90390490590690490790890991091191291391491591391691791891691992092192292313 行未改动9379389399409389419429439449459439469479489469499509519529533 行未改动9579589599609589619629639619649659669679689669699709719729739719749759769779785 行未改动9849859869879859889899909919899929939949959969979989999971000100110021003100110041005100310061007100810091007101010111012101310141015101610171015101610181019102010211022102310241025102310261027102810291030102810311032103310341035103610371035103810391040104110421043104110441045104310441045104610461047104810491050105110521053105410501055105610571058105910601061106210631059106410651066106710685 行未改动1074107510761077107310781079108010811077108210831084108510861082108710881089109010911087109210931094109510962 行未改动109911001101110210981103110411051106110711081109111011111112110811131114111511161112111711181119112011161121112211231119112411251126112711281129112511301131113211331134113511311136113711381134113911401141114211435 行未改动11491150115111521153115427 行未改动 } ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: var(--bg-color); } ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
#sidebar { width: 350px; background-color: var(--panel-bg); padding: 20px;21 行未改动 } .stat-row { display: flex; justify-content: space-between; margin-bottom: 4px; align-items: center; } .stat-val { font-weight: bold; color: #4fc3f7; font-family: monospace; font-size: 1.1em; } .sub-text { font-size: 0.8em; color: #888; }
.forecast-row { display: flex; justify-content: space-between; font-size: 0.85em; color: #aaa; border-bottom: 1px dashed #333; padding: 2px 0; } .forecast-val { font-family: monospace; } .income { color: #69f0ae; } .expense { color: #ff5252; }10 行未改动 font-size: 0.9em; } button:hover { background-color: var(--text); transform: translateY(-1px); } button:disabled { background-color: #333; cursor: not-allowed; opacity: 0.6; transform: none; }
.btn-group { display: flex; align-items: center; margin-bottom: 6px; } .btn-group label { width: 80px; font-size: 0.9em; color: #ccc; } .btn-small { padding: 4px 8px; font-size: 0.8em; background-color: #444; }
.tabs { display: flex; border-bottom: 2px solid #333; margin-bottom: 15px; } .tab { padding: 10px 20px; cursor: pointer; background: rgba(0,0,0,0.2); border-radius: 8px 8px 0 0; margin-right: 4px; } .tab.active { background: var(--text); color: white; font-weight: bold; }
.panel { display: none; animation: fadeIn 0.3s; } .panel.active { display: block; } @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.action-card { background: var(--panel-bg); border: 1px solid var(--border); padding: 15px; margin-bottom: 15px; border-radius: 8px; }
#log-area { height: 200px; background: #111; font-family: 'Consolas', monospace;33 行未改动 margin-bottom: 10px; border-radius: 8px; } #next-month-btn:hover { background-color: #43a047; }
.progress-container { width: 100%; background-color: #333; height: 6px; border-radius: 3px; margin-top: 8px; overflow: hidden; } .progress-bar { height: 100%; background-color: var(--success); width: 0%; transition: width 0.5s ease-out; }
.edu-card { background: #222; padding: 12px; margin-bottom: 10px; border-radius: 6px; background: #222; padding: 12px; margin-bottom: 10px; border-radius: 6px; border-left: 4px solid var(--text); } .edu-header { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 8px; } .edu-cost { font-size: 0.85em; color: #aaa; margin-bottom: 8px; line-height: 1.4; } .edu-actions { display: flex; gap: 8px; } .btn-run { background-color: #2e7d32; flex: 1; } .btn-up { background-color: #1565c0; flex: 1; }
/* 新增:资源转化按钮组样式优化 */ .convert-btn-group { display: flex; align-items: center;18 行未改动 <div style="font-size:0.8em; opacity:0.7;">目标: 存活至 2026-01</div> </div>
<div class="stat-box"> <div class="stat-row"><span>📅 日期</span> <span id="disp-date" class="stat-val">2013-01</span></div> <div class="stat-row"><span>💰 资金</span> <span id="disp-money" class="stat-val">5000</span></div> <div class="stat-row"><span>⭐ 声誉</span> <span id="disp-rep" class="stat-val">0.000</span></div> <div class="stat-row"><span>日期</span> <span id="disp-date" class="stat-val">2013-01</span></div> <div class="stat-row"><span>资金</span> <span id="disp-money" class="stat-val">5000</span></div> <div class="stat-row"><span>声誉</span> <span id="disp-rep" class="stat-val">0.000</span></div> <div class="progress-container"><div id="rep-bar" class="progress-bar" style="width: 50%;"></div></div> </div>
<!-- 故障监控 --> <div class="stat-box" style="border: 1px solid #555;"> <div class="stat-row"><span>⚠️ 连续故障月数</span> <span id="disp-fail-months" style="color:#aaa; font-weight:bold">0 / 6</span></div> <div class="stat-row"><span>连续故障月数</span> <span id="disp-fail-months" style="color:#aaa; font-weight:bold">0 / 6</span></div> <div style="font-size:0.75em; color:#888;">若连续6个月硬盘满或服务器/评测机过载,游戏强制结束。</div> </div>
<!-- 预测模块 --> <h3>🔮 下月预测</h3> <h3>下月预测</h3> <div class="stat-box"> <div class="forecast-row"><span>预计收入(低保+API)</span> <span id="fc-income" class="forecast-val income">+0</span></div> <div class="forecast-row"><span>预计工资支出</span> <span id="fc-salary" class="forecast-val expense">-0</span></div> <div class="forecast-row"><span>预计维护支出</span> <span id="fc-maint" class="forecast-val expense">-0</span></div>6 行未改动 社区需求: <span id="fc-comm-cost">0</span>/月 </div> </div>
<h3>⚡ 资源池</h3> <h3>资源池</h3> <div class="stat-box"> <div class="stat-row"><span>行动力 (AP)</span> <span id="disp-ap" class="stat-val" style="color: #ffca28;">100</span></div> <div class="stat-row"><span>研发点</span> <span id="disp-rd" class="stat-val">0</span></div> <div class="stat-row"><span>学术点</span> <span id="disp-acad" class="stat-val">0</span></div> <div class="stat-row"><span>社区点</span> <span id="disp-comm" class="stat-val">0</span></div> </div>
<h3>📊 运营数据</h3> <h3>运营数据</h3> <div class="stat-box"> <div class="stat-row"><span>总用户</span> <span id="disp-users-total" class="stat-val">50</span></div> <div class="stat-row"><span class="sub-text">上月新增提交</span> <span id="disp-last-subs" style="color:#fff">0</span></div> <div class="stat-row"><span class="sub-text">上月新增题解</span> <span id="disp-last-sols" style="color:#fff">0</span></div> <hr style="border-color:#444; margin: 8px 0;"> <div class="stat-row"><span>题库 (高/中/低)</span> <span><span id="disp-prob-high">0</span>/<span id="disp-prob-mid">0</span>/<span id="disp-prob-low">0</span></span></div> <div class="stat-row"><span class="sub-text">硬盘占用</span> <span id="disp-disk">0 GB</span></div> </div>
<h3>🖥️ 服务器</h3> <h3>服务器</h3> <div class="stat-box"> <div class="stat-row"><span>Web核心</span> <span><span id="disp-server-core" class="stat-val">2</span> 核 (Lv.<span id="disp-server-arch">1</span>)</span></div> <div class="stat-row"><span>评测核心</span> <span><span id="disp-judge-core" class="stat-val">1</span> 核 (Lv.<span id="disp-judge-arch">1</span>)</span></div> <div class="stat-row" style="justify-content: flex-end; font-size: 0.8em; color: #888;">Web负载: <span id="disp-server-load">0</span> / <span id="disp-server-cap">0</span></div> <div class="stat-row" style="justify-content: flex-end; font-size: 0.8em; color: #888;">评测负载: <span id="disp-judge-load">0</span> / <span id="disp-judge-cap">0</span></div> </div></div>
<div id="main"> <div id="warning-banner">⚠️ 警告:预计下个月将破产!请立即筹集资金!</div> <div id="warning-banner">警告:预计下个月将破产!请立即筹集资金!</div>
<button id="next-month-btn" onclick="game.nextMonth()">进入下个月</button>
<div class="tabs"> <div class="tab active" onclick="ui.switchTab('ops')">日常运营</div>4 行未改动
<!-- Operations Tab --> <div id="tab-ops" class="panel active"> <div class="action-card"> <h3>📢 资源转化 (每次 10 行动力)</h3> <h3>资源转化 (每次 10 行动力)</h3> <!-- 改造:资源转化按钮改为2行布局 --> <div class="convert-btn-group"> <button onclick="game.convertAP('rd')">转研发 (+10)</button> <button onclick="game.convertAP('acad')">转学术 (+10)</button>10 行未改动 </div> </div>
<div class="action-card"> <h3>🏆 赛事运营</h3> <h3>赛事运营</h3> <div class="card-desc">举办比赛可提升下月用户增长速度。</div> <button onclick="game.organizeContest('old')">原题赛 (需要$500, 学术40)<br><span style="font-size:0.8em">普通题目+4, 增长x1.05</span></button> <button onclick="game.organizeContest('water')">水赛 (需要$1000, 学术40)<br><span style="font-size:0.8em">低质题目+6, 增长x1.15</span></button> <button onclick="game.organizeContest('normal')">普通赛 (需要$3000, 学术80)<br><span style="font-size:0.8em">普通题目+4, 增长x1.1</span></button> <button onclick="game.organizeContest('grand')">优秀赛 (需要$8000, 学术200)<br><span style="font-size:0.8em">高质题目+3, 增长x1.1, 升声誉</span></button> </div>
<div class="action-card"> <h3>📝 题库扩充</h3> <h3>题库扩充</h3> <div class="card-desc" style="font-size:0.85em; color:#aaa; margin-bottom:5px;">搬运普通/低质试题可吸引 10~50 名新用户。</div> <!-- 基础题库扩充 --> <div style="margin-bottom:10px;"> <button onclick="game.addProblem('high')">高质量 (+3题, -20学术)</button>11 行未改动
<!-- R&D Tab --> <div id="tab-rd" class="panel"> <div class="action-card"> <h3>💻 基础设施</h3> <h3>基础设施</h3> <div style="color:#ff5252; font-size:0.85em; margin-bottom:10px; font-weight:bold;"> ⚠️ 注意:当核心数达到架构上限(32或64 × 架构等级)时,必须先升级架构才能继续购买。 注意:当核心数达到架构上限(32或64 × 架构等级)时,必须先升级架构才能继续购买。 </div>
<div class="btn-group"> <label>Web核心:</label> <button onclick="game.expandHardware('server', 1)">+1</button> <button onclick="game.expandHardware('server', 10)" class="btn-small">+10</button> <button onclick="game.expandHardware('server', 'max')" class="btn-small" style="background:#555">填满</button> </div>
<div class="btn-group"> <label>评测核心:</label> <button onclick="game.expandHardware('judge', 1)">+1</button> <button onclick="game.expandHardware('judge', 10)" class="btn-small">+10</button> <button onclick="game.expandHardware('judge', 'max')" class="btn-small" style="background:#555">填满</button> </div>
<div class="btn-group" style="margin-top:10px"> <button onclick="game.expandHardware('disk', 1)">加硬盘 (+40GB)</button> <button onclick="game.expandHardware('disk', 25)">加硬盘 (+1000GB)</button> </div> </div> <div class="action-card"> <h3>🚀 功能研发</h3> <h3>功能研发</h3> <div id="rd-list"></div> </div> <div class="action-card"> <h3>🏗️ 架构升级</h3> <h3>架构升级</h3> <div class="card-desc">架构升级后,每个核心可额外容纳 100 活跃用户。</div> <div style="font-size:0.85em; color:#aaa; margin-bottom:8px; line-height:1.5;"> Web下级需求: <span id="disp-up-server-cost" style="color:#ffb74d"></span><br> 评测下级需求: <span id="disp-up-judge-cost" style="color:#ffb74d"></span>10 行未改动 <h4 style="margin-top:0">研发团队 (产出: <span id="out-rd">0</span>/月)</h4> <button onclick="game.hire('rd_student')">高中生 ($1500, +20 研发)</button> <button onclick="game.hire('rd_uni')">大学生 ($5000, +75 研发)</button> <button onclick="game.hire('rd_full')">全职大牛 ($12000, +120 研发)</button>
<h4 style="margin-top:10px">学术团队 (产出: <span id="out-acad">0</span>/月)</h4> <button onclick="game.hire('acad_part')">现役选手 ($500, +50 学术)</button> <button onclick="game.hire('acad_full')">全职教练 ($15000, +400 学术)</button>
<h4 style="margin-top:10px">社区团队 (产出: <span id="out-comm">0</span>/月)</h4> <button onclick="game.hire('comm_part')">兼职版主 ($500, +50 社区)</button> <button onclick="game.hire('comm_full')">全职运营 ($7500, +400 社区)</button> </div> </div>
<!-- Edu Tab --> <div id="tab-edu" class="panel"> <div class="action-card"> <h3>🏫 网校管理</h3> <h3>网校管理</h3> <p style="font-size:0.85em; color:#aaa">研发[网校功能]后解锁。课程升级后带来更多收入,但升级成本也会增加。开课后有 3 个月冷却期。</p> <div id="edu-list"></div> </div> </div>
<div id="log-area"> <div class="log-entry" style="color:#4fc3f7">💡 欢迎来到 OJ 运维模拟器!</div> <div class="log-entry" style="color:#4fc3f7">欢迎来到 OJ 运维模拟器!</div> <div class="log-entry">请密切关注左侧的【下月预测】面板,避免破产。</div> </div></div>
2 行未改动 INITIAL: { YEAR: 2013, MONTH: 1, MONEY: 5000, AP: 100, USERS: 50, SERVER_CORES: 2, JUDGE_CORES: 1, DISK_MB: 20480 }, INCOME: { MONTHLY_GRANT: 500 }, COSTS: { SERVER_CORE_RENT: 200, JUDGE_CORE_RENT: 200, DISK_BLOCK_RENT: 100, DISK_BLOCK_SIZE_GB: 40, ADD_PROBLEM_ACAD: 20, ADD_PROBLEM_BATCH_ACAD: 200, ADD_PROBLEM_ACAD: 20, ADD_PROBLEM_BATCH_ACAD: 200, HIRE_AP: 10 }, HIRING: { rd_student: { name: "高中兼职", cost: 1500, gain: 20, limit: 5, type: 'rd' },20 行未改动 }, USER_BEHAVIOR: { SUBMISSIONS: { normal: 15, active: 65, core: 300 }, SOLUTIONS: { normal: 0.01, active: 1, core: 5 }, GROWTH_FACTOR: 0.25, GROWTH_FACTOR: 0.25, UPGRADE_N_A_BASE: 4, UPGRADE_N_A_MULT: 10, UPGRADE_A_C_MULT: 5 }, DISK_USAGE: { PROBLEM: 50, USER_DATA: 0.05, SUBMISSION: 0.002, SOLUTION: 0.005 }, CLASSES: {17 行未改动 total_solutions: 0, reputation: 0, last_month: { subs: 0, sols: 0 }, consecutive_failure_months: 0, comm_fail_months: 0, pending_user_bonus: 0 comm_fail_months: 0, pending_user_bonus: 0 }, hardware: { server_cores: GAME_PARAMS.INITIAL.SERVER_CORES, judge_cores: GAME_PARAMS.INITIAL.JUDGE_CORES, disk_extra_blocks: 0, disk_used: 0, server_arch: 1, judge_arch: 124 行未改动 for (let k in this.staff) { let count = this.staff[k], conf = GAME_PARAMS.HIRING[k]; if (count > 0) { salary += count * conf.cost; gain[conf.type] += count * conf.gain; } }
this.money += GAME_PARAMS.INCOME.MONTHLY_GRANT; this.money -= salary; this.resources.rd += gain.rd; this.resources.acad += gain.acad; this.resources.comm += gain.comm;
if(salary > 0) ui.log(`财务: 发放工资 ${salary}, 产出 R:${gain.rd} A:${gain.acad} C:${gain.comm}`);
// Maintenance let maintain_rd = 0; for (let k in GAME_PARAMS.FEATURES) if (this.features_unlocked[k]) maintain_rd += GAME_PARAMS.FEATURES[k].maintain; maintain_rd += 20 * (this.hardware.server_arch - 1); maintain_rd += 20 * (this.hardware.judge_arch - 1); this.resources.rd = Math.max(this.resources.rd - maintain_rd, 0);
// 硬件租金计算 let hw_cost = this.hardware.disk_extra_blocks * GAME_PARAMS.COSTS.DISK_BLOCK_RENT; hw_cost += this.hardware.server_cores * GAME_PARAMS.COSTS.SERVER_CORE_RENT; hw_cost += this.hardware.judge_cores * GAME_PARAMS.COSTS.JUDGE_CORE_RENT;19 行未改动 load_multiplier = 1.0; } let load = u.active + (u.normal / 3) + (u.core * 3); load *= load_multiplier;
if (this.features_unlocked.api) { let total_u = u.normal + u.active + u.core; this.money += Math.floor(total_u * 1.0); this.money += Math.floor(total_u * 1.0); }
// --- Growth Logic --- let rep = this.stats.reputation; let total_users = u.normal + u.active + u.core;
let pct_rate = (rep * 8 + 4) / 100; if (pct_rate < 0) pct_rate = 0; let growth_from_pct = total_users * pct_rate; let growth_from_fixed = (rep + 1) * 50; if (growth_from_fixed < 0) growth_from_fixed = 0;
let new_users = Math.floor(growth_from_pct + growth_from_fixed); if (this.flags.contest_growth_mult !== 1.0) { new_users = Math.floor(new_users * this.flags.contest_growth_mult); this.flags.contest_growth_mult = 1.0; this.flags.contest_growth_mult = 1.0; } // 讨论区新增1.1倍用户增长加成 if (this.features_unlocked.discuss) { new_users = Math.floor(new_users * 1.1); new_users = Math.floor(new_users * 1.05); }
// 搬题奖励发放 if (this.stats.pending_user_bonus > 0) { new_users += this.stats.pending_user_bonus; ui.log(`推广: 试题扩充吸引了额外 ${this.stats.pending_user_bonus} 名用户`); this.stats.pending_user_bonus = 0; }
u.normal += new_users; if (new_users > 0) ui.log(`用户: 新增 ${new_users} 人`);
// Flow let prob_n2a = (rep * GAME_PARAMS.USER_BEHAVIOR.UPGRADE_N_A_MULT + GAME_PARAMS.USER_BEHAVIOR.UPGRADE_N_A_BASE) / 100; if (this.features_unlocked.difficulty) prob_n2a *= 1.1; if (this.features_unlocked.solution) prob_n2a *= 1.25; if (this.features_unlocked.discuss) prob_n2a *= 1.1; if (this.features_unlocked.team) prob_n2a *= 1.1;
let delta_n2a = Math.floor(u.normal * prob_n2a); if (delta_n2a > 0) { u.normal -= delta_n2a; u.active += delta_n2a; } if (delta_n2a > 0) { u.normal -= delta_n2a; u.active += delta_n2a; } else { let delta_a2n = Math.floor(u.active * Math.abs(prob_n2a)); u.active -= delta_a2n; u.normal += delta_a2n; }
let prob_a2c = (rep * GAME_PARAMS.USER_BEHAVIOR.UPGRADE_A_C_MULT) / 100; let delta_a2c = Math.floor(u.active * prob_a2c);8 行未改动 (u.active * GAME_PARAMS.USER_BEHAVIOR.SUBMISSIONS.active) + (u.core * GAME_PARAMS.USER_BEHAVIOR.SUBMISSIONS.core); let subs_int = Math.floor(subs); this.stats.total_submissions += subs_int; this.stats.last_month.subs = subs_int; this.stats.last_month.subs = subs_int;
let sols = 0; // 修改点2:总题数为0时题解数强制为0 let total_prob = this.stats.problems.high + this.stats.problems.mid + this.stats.problems.low; if (total_prob > 0 && this.features_unlocked.solution) {11 行未改动 (total_users * GAME_PARAMS.DISK_USAGE.USER_DATA) + (this.stats.total_submissions * GAME_PARAMS.DISK_USAGE.SUBMISSION) + (this.stats.total_solutions * GAME_PARAMS.DISK_USAGE.SOLUTION); this.hardware.disk_used = disk;
let disk_cap = GAME_PARAMS.INITIAL.DISK_MB + (this.hardware.disk_extra_blocks * GAME_PARAMS.COSTS.DISK_BLOCK_SIZE_GB * 1024);
// System Failure Check let is_disk_full = disk > disk_cap; let is_server_overload = load > server_cap; let is_judge_overload = load > judge_cap; if (is_disk_full) ui.log("❌ 硬盘已满!数据写入失败!", "log-bad"); if (is_server_overload) ui.log("❌ Web服务器过载!", "log-bad"); if (is_judge_overload) ui.log("❌ 评测机过载!", "log-bad");
if (is_disk_full) ui.log("? 硬盘已满!数据写入失败!", "log-bad"); if (is_server_overload) ui.log("? Web服务器过载!", "log-bad"); if (is_judge_overload) ui.log("? 评测机过载!", "log-bad");
if (is_disk_full || is_server_overload || is_judge_overload) { this.stats.consecutive_failure_months++; ui.log(`⚠️ 系统故障!连续故障月数: ${this.stats.consecutive_failure_months}/6`, "log-bad"); ui.log(`?? 系统故障!连续故障月数: ${this.stats.consecutive_failure_months}/6`, "log-bad"); if (this.stats.consecutive_failure_months >= 6) { alert("由于长期维护不善(连续6个月故障),您的 OJ 被视作关停。游戏结束。"); document.getElementById('next-month-btn').disabled = true; return; } } else { if (this.stats.consecutive_failure_months > 0) { ui.log("✅ 系统状态已恢复正常,故障计数重置。", "log-good"); ui.log("? 系统状态已恢复正常,故障计数重置。", "log-good"); } this.stats.consecutive_failure_months = 0; }
3 行未改动 if (this.features_unlocked.solution) acad_need += total_prob * 0.1; // 社区维护需求公式调整 let comm_need = 0; if (this.features_unlocked.discuss) { comm_need = (this.stats.users.core * 0.02) + (this.stats.users.active * 0.01) + comm_need = (this.stats.users.core * 0.02) + (this.stats.users.active * 0.01) + (this.stats.users.normal * 0.003); }
this.resources.acad -= acad_need; this.resources.comm -= comm_need;
let acad_gap = (this.resources.acad < 0) ? Math.abs(this.resources.acad) : 0; let comm_gap = (this.resources.comm < 0) ? Math.abs(this.resources.comm) : 0;
// 社区缺口统计 if (comm_gap > 0) this.stats.comm_fail_months++; // 每年1月罚款逻辑 if (this.date.month === 1 && this.stats.comm_fail_months >= 12 && total_users >= 10000) { let fine = total_users; this.money -= fine; ui.log(`⚖️ 监管通知: 因长期社区维护不善,罚款 ${fine} 元!`, "log-bad"); this.stats.comm_fail_months = 0; ui.log(`?? 监管通知: 因长期社区维护不善,罚款 ${fine} 元!`, "log-bad"); this.stats.comm_fail_months = 0; }
let server_gap = Math.max(0, load - server_cap); let judge_gap = Math.max(0, load - judge_cap);
this.calculateReputation(acad_gap, comm_gap, server_gap, judge_gap, total_prob);
// Cooldowns for(let k in this.class_state) if (this.class_state[k].cooldown > 0) this.class_state[k].cooldown--;
if (this.flags.fundraising_penalty_val > 0) { this.flags.fundraising_penalty_val -= (0.2 / 12); if (this.flags.fundraising_penalty_val < 0) this.flags.fundraising_penalty_val = 0; }27 行未改动 if (acad_gap > 0) r_stable -= Math.log10(acad_gap) / 20; if (comm_gap > 0) r_stable -= Math.log10(comm_gap) / 20; if (server_gap > 0) r_stable -= Math.log10(server_gap) / 10; if (judge_gap > 0) r_stable -= Math.log10(judge_gap) / 10;
r_stable -= this.flags.fundraising_penalty_val; r_stable -= this.flags.temp_rep_penalty;
let total = r_acad + r_users + r_edu + r_stable; if (total > 1) total = 1; this.stats.reputation = total; },4 行未改动 ui.log(`行动: 10 AP -> 10 ${target}点`); ui.update(); },
convertAPAll: function(target) { if (this.ap < 10) { ui.log("AP不足(至少需要10点)", "log-bad"); return; if (this.ap < 10) { ui.log("AP不足(至少需要10点)", "log-bad"); return; } const convertTimes = Math.floor(this.ap / 10); const apCost = convertTimes * 10; const resourceGain = convertTimes * 10;
this.ap -= apCost; this.resources[target] += resourceGain;
ui.log(`行动: ${apCost} AP -> ${resourceGain} ${target}点(剩余AP: ${this.ap})`, "log-good"); ui.update(); },
addProblem: function(type) { // 基础加题 if (type === 'high' || type === 'mid' || type === 'low') { if (this.resources.acad < GAME_PARAMS.COSTS.ADD_PROBLEM_ACAD) { ui.log("学术不足", "log-bad"); return; if (this.resources.acad < GAME_PARAMS.COSTS.ADD_PROBLEM_ACAD) { ui.log("学术不足", "log-bad"); return; } this.resources.acad -= GAME_PARAMS.COSTS.ADD_PROBLEM_ACAD;
if (type === 'mid' || type === 'low') { let bonus = Math.floor(Math.random() * 41) + 10; let bonus = Math.floor(Math.random() * 41) + 10; this.stats.pending_user_bonus = (this.stats.pending_user_bonus || 0) + bonus; }
if (type === 'high') this.stats.problems.high += 3; if (type === 'mid') this.stats.problems.mid += 10; if (type === 'low') { this.stats.problems.low += 20; this.stats.reputation -= 0.001; } ui.log(`题库: 增加 ${type} 试题`); ui.log(`题库: 增加 ${type} 试题`); } // 批量加题 else if (type === 'high_batch' || type === 'mid_batch' || type === 'low_batch') { if (this.resources.acad < GAME_PARAMS.COSTS.ADD_PROBLEM_BATCH_ACAD) { ui.log("学术不足(需要200点)", "log-bad"); return; if (this.resources.acad < GAME_PARAMS.COSTS.ADD_PROBLEM_BATCH_ACAD) { ui.log("学术不足(需要200点)", "log-bad"); return; } this.resources.acad -= GAME_PARAMS.COSTS.ADD_PROBLEM_BATCH_ACAD;
// 批量题也有用户奖励 if (type === 'mid_batch' || type === 'low_batch') { let bonus = Math.floor(Math.random() * 201) + 50; let bonus = Math.floor(Math.random() * 201) + 50; this.stats.pending_user_bonus = (this.stats.pending_user_bonus || 0) + bonus; }
if (type === 'high_batch') {4 行未改动 this.stats.problems.mid += 100; ui.log(`题库: 批量增加普通试题 (+100题)`); } if (type === 'low_batch') { this.stats.problems.low += 200; this.stats.reputation -= 0.01; this.stats.problems.low += 200; this.stats.reputation -= 0.01; ui.log(`题库: 批量增加低质量试题 (+200题),声誉小幅下降`, "log-warn"); } } ui.update();2 行未改动 organizeContest: function(key) { let conf = GAME_PARAMS.CONTESTS[key]; if (this.money < conf.cost || this.resources.acad < conf.acad) { ui.log("资源不足", "log-bad"); return; } this.money -= conf.cost; this.resources.acad -= conf.acad;
if (conf.prob_mid) this.stats.problems.mid += conf.prob_mid; if (conf.prob_low) this.stats.problems.low += conf.prob_low; if (conf.prob_high) this.stats.problems.high += conf.prob_high;
if (conf.rep_pen) this.flags.temp_rep_penalty += conf.rep_pen; if (conf.rep_gain) this.stats.reputation += conf.rep_gain; if (conf.growth_mult) this.flags.contest_growth_mult = conf.growth_mult;
ui.log(`比赛: ${conf.name} (下月增长 x${conf.growth_mult})`); ui.update(); },
fundraising: function() {4 行未改动 // 修改点:新增随机数因子,范围 0.1 ~ 2 let random_factor = Math.random() * 1.9 + 0.1; // 生成 0.1 到 2 之间的随机数 let gain = Math.floor((this.stats.reputation + 1) * total_users * random_factor); if (gain < 0) gain = 0;
this.money += gain; this.flags.fundraising_penalty_val += 0.2; ui.log(`募捐: 获得 ${gain} 元,声誉受损`, "log-bad"); ui.update(); },7 行未改动 },
expandHardware: function(type, mode) { mode = mode || 1;
if (type === 'disk') { let count = (typeof mode === 'number') ? mode : 1; this.hardware.disk_extra_blocks += count; ui.log(`硬件: 硬盘扩容 (+${count * 40}GB)`); ui.update(); return; this.hardware.disk_extra_blocks += count; ui.log(`硬件: 硬盘扩容 (+${count * 40}GB)`); ui.update(); return; }
let isServer = (type === 'server'); let arch = isServer ? this.hardware.server_arch : this.hardware.judge_arch; let current = isServer ? this.hardware.server_cores : this.hardware.judge_cores; let limit_base = isServer ? 32 : 64; let limit = limit_base * arch;
let count = 0; if (mode === 'max') { count = limit - current; } else { count = mode; }
if (count <= 0) { ui.log("已达到架构上限,无法添加", "log-bad"); return; }
if (current + count > limit) { count = limit - current; if (count <= 0) { ui.log("核心数已达架构上限,请先升级架构", "log-bad"); return; } }
if (isServer) this.hardware.server_cores += count; else this.hardware.judge_cores += count;
ui.log(`硬件: ${isServer?'Web':'评测'}核心 +${count}`); ui.update(); },
// 修改点1:升级架构耗费改为200研发+$500*核心数 upgradeArch: function(type) { let isServer = (type === 'server'); let currentCores = isServer ? this.hardware.server_cores : this.hardware.judge_cores; let costMoney = 500 * currentCores; let costRD = 200; if (this.money < costMoney || this.resources.rd < costRD) { ui.log(`资源不足(需要$${costMoney} + ${costRD} 研发点)`, "log-bad"); return; } this.money -= costMoney; this.resources.rd -= costRD; if (isServer) { this.hardware.server_arch++; ui.log(`研发: Web架构升级至Lv.${this.hardware.server_arch}`, "log-good"); } else { this.hardware.judge_arch++; ui.log(`研发: 评测架构升级至Lv.${this.hardware.judge_arch}`, "log-good"); } ui.update(); }, upgradeArch: function(type) { let isServer = (type === 'server'); let currentCores = isServer ? this.hardware.server_cores : this.hardware.judge_cores; let costMoney = 500 * currentCores;
// 新规则:研发点 = 200 + 50 × (当前架构等级 - 1) let currentArch = isServer ? this.hardware.server_arch : this.hardware.judge_arch; let costRD = 200 + 50 * (currentArch - 1);
if (this.money < costMoney || this.resources.rd < costRD) { ui.log(`资源不足(需要$${costMoney} + ${costRD} 研发点)`, "log-bad"); return; }
this.money -= costMoney; this.resources.rd -= costRD;
if (isServer) { this.hardware.server_arch++; ui.log(`研发: Web架构升级至Lv.${this.hardware.server_arch}`, "log-good"); } else { this.hardware.judge_arch++; ui.log(`研发: 评测架构升级至Lv.${this.hardware.judge_arch}`, "log-good"); }
ui.update();},
unlockFeature: function(id) { let f = GAME_PARAMS.FEATURES[id]; if (this.money < f.cost || this.resources.rd < f.rd) { ui.log("资源不足", "log-bad"); return; } this.money -= f.cost; this.resources.rd -= f.rd;6 行未改动 let conf = GAME_PARAMS.CLASSES[id], st = this.class_state[id]; if (conf.season && !conf.season.includes(this.date.month)) { ui.log("季节不符 (需7-10月)", "log-bad"); return; } if (st.cooldown > 0) return; if (this.money < conf.req_money || this.resources.acad < conf.req_acad) { ui.log("无法开课 (资源不足)", "log-bad"); return; }
this.money -= conf.req_money; this.resources.acad -= conf.req_acad; this.money += conf.inc_base * st.level; st.cooldown = 3; ui.log(`网校: ${conf.name} 开课`, "log-good"); ui.update(); },
upgradeClass: function(id) { let conf = GAME_PARAMS.CLASSES[id], st = this.class_state[id]; if (st.level >= conf.max) return;
let cm = conf.cost_base * st.level; let ca = conf.acad_base * st.level;
if (this.money < cm || this.resources.acad < ca) { ui.log("升级资源不足", "log-bad"); return; } this.money -= cm; this.resources.acad -= ca; st.level++; ui.log(`网校: 升级 ${conf.name}`, "log-good"); ui.renderClasses(); ui.update(); },13 行未改动 document.getElementById('disp-date').innerText = `${game.date.year}-${String(game.date.month).padStart(2,'0')}`; document.getElementById('disp-money').innerText = game.money; document.getElementById('disp-rep').innerText = game.stats.reputation.toFixed(3); document.getElementById('rep-bar').style.width = Math.max(0, Math.min(100, (game.stats.reputation + 1)/2*100)) + '%';
document.getElementById('disp-ap').innerText = game.ap; document.getElementById('disp-rd').innerText = Math.floor(game.resources.rd); document.getElementById('disp-acad').innerText = Math.floor(game.resources.acad); document.getElementById('disp-comm').innerText = Math.floor(game.resources.comm);
let u = game.stats.users; document.getElementById('disp-users-total').innerText = u.normal + u.active + u.core;
let failSpan = document.getElementById('disp-fail-months'); failSpan.innerText = `${game.stats.consecutive_failure_months} / 6`; failSpan.style.color = game.stats.consecutive_failure_months > 0 ? '#ff5252' : '#aaa';
3 行未改动 let p = game.stats.problems; document.getElementById('disp-prob-high').innerText = p.high; document.getElementById('disp-prob-mid').innerText = p.mid; document.getElementById('disp-prob-low').innerText = p.low;
let disk_cap = GAME_PARAMS.INITIAL.DISK_MB + (game.hardware.disk_extra_blocks * GAME_PARAMS.COSTS.DISK_BLOCK_SIZE_GB * 1024); document.getElementById('disp-disk').innerText = `${(game.hardware.disk_used/1024).toFixed(1)} / ${(disk_cap/1024).toFixed(1)} GB`;
document.getElementById('disp-server-core').innerText = game.hardware.server_cores; document.getElementById('disp-server-arch').innerText = game.hardware.server_arch; document.getElementById('disp-judge-core').innerText = game.hardware.judge_cores; document.getElementById('disp-judge-arch').innerText = game.hardware.judge_arch;
// Load Calculation let server_arch_bonus = (game.hardware.server_arch - 1) * 100; let server_cap_unit = 500 - (game.features_unlocked.team?50:0) - (game.features_unlocked.api?50:0) + server_arch_bonus; let s_cap = game.hardware.server_cores * server_cap_unit;
let judge_arch_bonus = (game.hardware.judge_arch - 1) * 100; let judge_cap_unit = 500 + judge_arch_bonus; let j_cap = game.hardware.judge_cores * judge_cap_unit;
5 行未改动 } let load = u.active + (u.normal/3) + (u.core*3); load *= load_multiplier; load = Math.floor(load);
document.getElementById('disp-server-load').innerText = load; document.getElementById('disp-server-cap').innerText = s_cap; document.getElementById('disp-server-load').style.color = (load > s_cap) ? '#ff5252' : '#888';
document.getElementById('disp-judge-load').innerText = load; document.getElementById('disp-judge-cap').innerText = j_cap; document.getElementById('disp-judge-load').style.color = (load > j_cap) ? '#ff5252' : '#888';
// Forecast let salary = 0; for (let k in game.staff) salary += game.staff[k] * GAME_PARAMS.HIRING[k].cost;
let hw_cost = game.hardware.disk_extra_blocks * GAME_PARAMS.COSTS.DISK_BLOCK_RENT; hw_cost += game.hardware.server_cores * GAME_PARAMS.COSTS.SERVER_CORE_RENT; hw_cost += game.hardware.judge_cores * GAME_PARAMS.COSTS.JUDGE_CORE_RENT;
let total_expense = salary + hw_cost;
let api_income = 0; if (game.features_unlocked.api) api_income = Math.floor((u.normal+u.active+u.core) * 1.0); let total_income = GAME_PARAMS.INCOME.MONTHLY_GRANT + api_income;
let m_rd = 0, m_acad = 0, m_comm = 0; for (let k in GAME_PARAMS.FEATURES) if (game.features_unlocked[k]) m_rd += GAME_PARAMS.FEATURES[k].maintain; m_rd += 20 * (game.hardware.server_arch - 1) + 20 * (game.hardware.judge_arch - 1); let total_prob = p.high + p.mid + p.low; if (game.features_unlocked.difficulty) m_acad += total_prob * 0.05; if (game.features_unlocked.solution) m_acad += total_prob * 0.1; if (game.features_unlocked.discuss) { m_comm = (game.stats.users.core * 0.02) + (game.stats.users.active * 0.01) + m_comm = (game.stats.users.core * 0.02) + (game.stats.users.active * 0.01) + (game.stats.users.normal * 0.003); }
document.getElementById('fc-income').innerText = `+${total_income}`; document.getElementById('fc-salary').innerText = `-${salary}`; document.getElementById('fc-maint').innerText = `-${hw_cost}`;
let net = total_income - total_expense; let netEl = document.getElementById('fc-net'); netEl.innerText = (net >= 0 ? '+' : '') + net; netEl.style.color = (net >= 0 ? '#69f0ae' : '#ff5252');
document.getElementById('fc-rd-cost').innerText = m_rd; document.getElementById('fc-acad-cost').innerText = Math.floor(m_acad); document.getElementById('fc-comm-cost').innerText = Math.floor(m_comm);
let banner = document.getElementById('warning-banner'); banner.style.display = (game.money + net < 0) ? 'block' : 'none'; if (game.money + net < 0) banner.innerText = `⚠️ 严重警告:按当前收支,下个月将破产 (预计余额 ${game.money + net})!`; if (game.money + net < 0) banner.innerText = `?? 严重警告:按当前收支,下个月将破产 (预计余额 ${game.money + net})!`;
let staff = game.staff, h = GAME_PARAMS.HIRING; document.getElementById('out-rd').innerText = staff.rd_student*h.rd_student.gain + staff.rd_uni*h.rd_uni.gain + staff.rd_full*h.rd_full.gain; document.getElementById('out-acad').innerText = staff.acad_part*h.acad_part.gain + staff.acad_full*h.acad_full.gain; document.getElementById('out-comm').innerText = staff.comm_part*h.comm_part.gain + staff.comm_full*h.comm_full.gain;
// 更新架构升级成本显示 let s_cores = game.hardware.server_cores; let j_cores = game.hardware.judge_cores; document.getElementById('disp-up-server-cost').innerText = `$${500 * s_cores} + 200 研发`; document.getElementById('disp-up-judge-cost').innerText = `$${500 * j_cores} + 200 研发`;let s_cores = game.hardware.server_cores;let j_cores = game.hardware.judge_cores;let s_rd_cost = 200 + 50 * (game.hardware.server_arch - 1);let j_rd_cost = 200 + 50 * (game.hardware.judge_arch - 1);document.getElementById('disp-up-server-cost').innerText = `$${500 * s_cores} + ${s_rd_cost} 研发`;document.getElementById('disp-up-judge-cost').innerText = `$${500 * j_cores} + ${j_rd_cost} 研发`;
ui.renderClasses(); },
log: function(msg, cls) { let div = document.createElement('div'); div.className = 'log-entry ' + (cls||''); div.innerText = `[${game.date.year}-${game.date.month}] ` + msg; let area = document.getElementById('log-area'); area.appendChild(div); area.scrollTop = area.scrollHeight; },
switchTab: function(id) { document.querySelectorAll('.tab').forEach(t => t.classList.remove('active')); document.querySelectorAll('.panel').forEach(p => p.classList.remove('active')); document.querySelector(`.tab[onclick="ui.switchTab('${id}')"]`).classList.add('active');5 行未改动 for(let k in GAME_PARAMS.FEATURES) { let f = GAME_PARAMS.FEATURES[k]; let div = document.createElement('div'); div.className = 'edu-card';
let header = document.createElement('div'); header.className = 'edu-header'; header.innerHTML = `${f.name} <span style="color:#ffb74d">$${f.cost} / ${f.rd} 研发</span>`;
let desc = document.createElement('div'); desc.style.fontSize = '0.85em'; desc.style.margin = '8px 0'; desc.innerText = f.desc;
let btn = document.createElement('button'); btn.innerText = game.features_unlocked[k] ? '已解锁' : '研发'; btn.disabled = game.features_unlocked[k]; if (!game.features_unlocked[k]) btn.onclick = () => game.unlockFeature(k);
div.appendChild(header); div.appendChild(desc); div.appendChild(btn); list.appendChild(div);2 行未改动
renderClasses: function() { let list = document.getElementById('edu-list'); list.innerHTML = '';
if (!game.features_unlocked.school) { list.innerHTML = '<div style="padding:10px; color:#aaa;">需先研发【网校功能】解锁</div>'; return; }
for(let k in GAME_PARAMS.CLASSES) { let conf = GAME_PARAMS.CLASSES[k], st = game.class_state[k]; let div = document.createElement('div'); div.className = 'edu-card';
let header = document.createElement('div'); header.className = 'edu-header'; header.innerHTML = `${conf.name} Lv.${st.level} <span style="color:#ffb74d">收入: ${conf.inc_base * st.level}</span>`;
let cost = document.createElement('div'); cost.className = 'edu-cost'; cost.innerHTML = `开课: $${conf.req_money} / ${conf.req_acad} 学术 | 升级: $${conf.cost_base * st.level} / ${conf.acad_base * st.level} 学术`;
let actions = document.createElement('div'); actions.className = 'edu-actions';
let btnRun = document.createElement('button'); btnRun.className = 'btn-run'; btnRun.innerText = st.cooldown > 0 ? `冷却(${st.cooldown})` : '开课'; btnRun.disabled = st.cooldown > 0; btnRun.onclick = () => game.runClass(k);
let btnUp = document.createElement('button'); btnUp.className = 'btn-up'; btnUp.innerText = `升级 (max:${conf.max})`; btnUp.disabled = st.level >= conf.max; btnUp.onclick = () => game.upgradeClass(k);
actions.appendChild(btnRun); actions.appendChild(btnUp);
div.appendChild(header); div.appendChild(cost); div.appendChild(actions); list.appendChild(div);5 行未改动game.init();</script></body></html>
```