tutorial2.html
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"><title>OI推理模式教程</title><style>:root{--bg:#f5f5f5;--surface:#fff;--text:#222;--t2:#555;--ac:#444;--cor:#555;--inc:#888;--tf:#666;--td:#333;--sf:#999;--border:#ccc;--shadow:0 4px 20px rgba(0,0,0,.06);--brbg:#444;--brh:#333;--cbbg:#555;--cbb:#3a3a3a;--cbh:#444}*{margin:0;padding:0;box-sizing:border-box}body{background:var(--bg);font-family:'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif;display:flex;justify-content:center;align-items:flex-start;min-height:100vh;padding:10px;user-select:none;-webkit-user-select:none}.main-wrapper{display:flex;flex-direction:row;align-items:flex-start;justify-content:center;gap:20px;max-width:1400px;width:100%;flex-wrap:wrap}.game-container{background:var(--surface);border-radius:20px;padding:10px 18px 14px;box-shadow:var(--shadow);display:flex;flex-direction:column;align-items:center;gap:10px;flex:1;min-width:0;border:3px solid transparent;position:relative;transition:border-color .15s}.game-container.correct-flash{border-color:#4caf50!important;box-shadow:0 0 28px rgba(76,175,80,.55)!important;animation:cf .5s ease-out forwards}@keyframes cf{0%{border-color:#4caf50;box-shadow:0 0 28px rgba(76,175,80,.55)}100%{border-color:transparent;box-shadow:0 4px 20px rgba(0,0,0,.06)}}.game-container.blue-flash{border-color:#39f!important;box-shadow:0 0 28px rgba(51,153,255,.55)!important;animation:bf .5s ease-out forwards}@keyframes bf{0%{border-color:#39f;box-shadow:0 0 28px rgba(51,153,255,.55)}100%{border-color:transparent;box-shadow:0 4px 20px rgba(0,0,0,.06)}}.tutorial-side-panel{background:var(--surface);border-radius:16px;padding:12px;box-shadow:var(--shadow);border:1px solid var(--border);width:240px;font-size:.8rem;position:sticky;top:10px;display:flex;flex-direction:column;gap:6px;flex-shrink:0;max-height:90vh;overflow-y:auto}.tutorial-msg{width:100%;padding:10px 14px;border-radius:12px;font-size:.82rem;font-weight:600;text-align:center;min-height:20px;transition:.3s;color:#2b5f8a;background:#e8f2fa;border:2px solid #5b9bd5;line-height:1.5;white-space:pre-line}.tutorial-msg.highlight{color:#8a6d14;background:#fffcf0;border-color:#e6a817;animation:pt 1.5s infinite}@keyframes pt{0%,100%{box-shadow:0 0 8px rgba(230,168,23,.3)}50%{box-shadow:0 0 20px rgba(230,168,23,.6)}}.tutorial-msg.success{color:#3d6b30;background:#e8f5e9;border-color:#5a9a4b}.tutorial-msg.info{color:#2b5f8a;background:#e8f2fa;border-color:#5b9bd5}.tutorial-msg.warning{color:#8a6d14;background:#fffcf0;border-color:#e6a817}.global-message{width:100%;padding:8px 14px;border-radius:10px;font-size:.78rem;font-weight:600;text-align:center;min-height:20px;transition:.3s;color:#555;background:#fafafa;border:1px solid #e0e0e0;margin-top:2px}.global-message.warning{color:#8a6d14;background:#fffcf0;border-color:#e6a817}.global-message.success{color:#3d6b30;background:#e8f5e9;border-color:#5a9a4b}.global-message.info{color:#2b5f8a;background:#e8f2fa;border-color:#5b9bd5}.side-panel{background:var(--surface);border-radius:16px;padding:16px 14px;box-shadow:var(--shadow);border:1px solid var(--border);width:260px;font-size:.8rem;display:flex;flex-direction:column;gap:10px;position:sticky;top:10px;max-height:90vh;overflow-y:auto}.side-panel.collapsed{display:none}.side-panel-title{font-weight:700;font-size:.95rem;color:#333;text-align:center;border-bottom:1px solid #ddd;padding-bottom:6px}.side-attr-row{display:flex;align-items:center;justify-content:space-between;background:#fafafa;border-radius:12px;padding:8px 14px;gap:8px}.side-attr-label{font-weight:700;color:#444;font-size:.85rem}.side-attr-value{font-weight:700;font-size:1rem;color:#222;min-width:28px;text-align:center}.focus-btn-inline{background:#ddd;border:1px solid #bbb;border-radius:50%;width:32px;height:32px;font-size:1.1rem;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.2s;position:relative;flex-shrink:0}.focus-btn-inline:hover{background:#ccc;border-color:#999}.focus-btn-inline.active{background:#f9a825;border-color:#f57f17;color:#fff}.focus-btn-inline.has-cost::after{content:attr(data-cost);position:absolute;top:-14px;left:50%;transform:translateX(-50%);font-size:.65rem;font-weight:800;color:#777;pointer-events:none;white-space:nowrap}.attr-focus-bonus{font-size:.65rem;font-weight:800;color:#f57f17;background:#fff3e0;padding:1px 6px;border-radius:8px;white-space:nowrap;transition:.2s;display:inline-block;margin-left:4px}.side-stock-row{display:flex;align-items:center;justify-content:space-between;background:#fafafa;border-radius:10px;padding:6px 10px;font-size:.73rem;gap:6px}.side-stock-icon{font-size:1rem}.side-stock-name{font-weight:600;color:#555;min-width:36px}.side-stock-count{font-weight:700;color:#333;min-width:20px;text-align:center}.side-stock-bar{flex:1;height:6px;background:#e8e8e8;border-radius:4px;overflow:hidden}.side-stock-fill{height:100%;border-radius:4px;transition:width .3s}.side-stock-fill.time-fill{background:#5b9bd5}.side-stock-fill.mind-fill{background:#e8943a}.side-stock-fill.boost-fill{background:#9b59b6}.side-stock-fill.inspire-fill{background:#d4a017}.level-banner{position:absolute;top:-2px;left:50%;transform:translateX(-50%);background:linear-gradient(135deg,#3a3a3a,#555);color:#fff;padding:6px 22px;border-radius:0 0 16px 16px;font-weight:800;font-size:.9rem;letter-spacing:.5px;box-shadow:0 3px 16px rgba(0,0,0,.25);z-index:10;white-space:nowrap;transition:.3s;display:flex;align-items:center;gap:8px}.attrs-panel{width:100%;display:flex;gap:8px;flex-wrap:wrap;justify-content:center;padding:6px 10px;background:#fafafa;border-radius:14px;border:1px solid #e0e0e0;margin-top:6px;align-items:center;font-size:.78rem;color:#888;min-height:20px}.score-progress-panel{width:100%;display:flex;align-items:center;gap:10px;padding:5px 14px;background:#fafafa;border-radius:30px;border:1px solid #e0e0e0}.score-progress-label{font-size:.8rem;font-weight:700;color:#444;white-space:nowrap;min-width:40px}.score-bar-outer{flex:1;height:12px;background:#e8e8e8;border-radius:8px;overflow:hidden;position:relative}.score-bar-inner{position:absolute;top:0;left:0;height:100%;border-radius:8px;transition:width .5s,background-color .5s;background:#1a1a1a}.score-number{font-size:.85rem;font-weight:700;color:#333;min-width:50px;text-align:right;white-space:nowrap;transition:color .3s}.time-panel{width:100%;display:flex;align-items:center;gap:10px;padding:6px 12px;background:#fafafa;border-radius:30px;border:1px solid #e0e0e0;flex-wrap:wrap}.time-icon{font-size:1.2rem}.time-label{font-size:.8rem;font-weight:700;color:#444;white-space:nowrap;min-width:50px}.time-bars-group{display:flex;flex-direction:column;gap:3px;flex:1;min-width:80px}.time-bar-outer{height:10px;background:#e8e8e8;border-radius:8px;overflow:hidden;position:relative;width:100%}.stamina-bar,.time-bar-inner{position:absolute;top:0;left:0;height:100%;border-radius:8px;transition:width .5s}.time-bar-inner{background:var(--tf)}.time-bar-inner.danger{background:var(--td)}.stamina-bar{background:var(--sf)}.time-number{font-size:1.3rem;font-weight:800;color:#222;min-width:40px;text-align:center;transition:color .3s,transform .15s}.map-selector{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;align-items:center}.map-btn{background:#f5f5f5;border:2px solid #d5d5d5;color:#666;border-radius:20px;padding:5px 12px;font-weight:600;font-size:.78rem;cursor:pointer;transition:.2s;display:flex;align-items:center;gap:4px}.map-btn.active{background:#444;border-color:#333;color:#fff;box-shadow:0 0 12px rgba(0,0,0,.2)}.map-btn.win{background:#e8e8e8;border-color:#999;color:#333}.map-btn.lose{background:#f5f5f5;border-color:#ccc;color:#888}.map-btn.correct-found{background:#e0e0e0;border-color:#555;color:#222}.canvas-wrapper{background:#fcfcfc;border-radius:14px;border:2px solid #ddd;display:flex;justify-content:center;width:100%}.canvas-wrapper.inference{border-color:#f90;box-shadow:0 0 20px rgba(255,153,0,.5)}canvas{display:block;max-width:100%;height:auto}.info-bar{width:100%;display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;font-size:.8rem;color:#777}.legend{display:flex;gap:10px;flex-wrap:wrap}.legend-item{display:flex;align-items:center;gap:4px;font-size:.73rem}.legend-dot{width:12px;height:12px;border-radius:50%;border:1.5px solid #999;background:#d0d0d0}.legend-dot.important{background:#666;border-color:#444}.legend-dot.result{background:#888;border-radius:2px;border-color:#666}.legend-dot.skill-node{background:#ccc;border-radius:1px;border:2px solid #999;transform:rotate(45deg);width:10px;height:10px;display:inline-block}.legend-dot.check-ring{background:0 0;border-radius:50%;border:3px solid #444;width:10px;height:10px}.legend-dot.correct-box{background:#555;border-radius:2px;border:2px solid #bbb;width:10px;height:10px}.legend-dot.broken{background:#fff;border-radius:50%;border:1.5px dashed #999;width:10px;height:10px}.legend-dot.upgrade-node{background:#fff;border-radius:3px;border:2px solid #f90;width:10px;height:10px;display:inline-block}.btn{padding:10px 22px;border-radius:25px;border:none;font-weight:700;font-size:.9rem;cursor:pointer;letter-spacing:.5px;transition:.2s}.btn-restart{background:var(--brbg);color:#fff}.btn-restart:hover{background:var(--brh);transform:translateY(-2px);box-shadow:0 6px 20px rgba(0,0,0,.2)}.active-skills-bar{width:100%;display:flex;gap:6px;flex-wrap:wrap;justify-content:center;padding:4px 8px;font-size:.7rem;color:#777;min-height:20px}.active-skill-tag{background:#e8e8e8;color:#444;padding:2px 8px;border-radius:10px;font-weight:600;font-size:.68rem;white-space:nowrap}.correct-found-hint{display:inline-block;background:#e0e0e0;color:#222;padding:4px 10px;border-radius:12px;font-weight:600;font-size:.75rem}.hidden{display:none!important}#topNotice{position:fixed;top:10px;left:50%;transform:translateX(-50%);background:#333;color:#fff;padding:10px 20px;border-radius:8px;z-index:9999;display:none;font-size:.85rem;font-weight:600;box-shadow:0 4px 12px rgba(0,0,0,.3);white-space:nowrap}</style></head><body><div id="topNotice"></div><div class="main-wrapper"><div class="game-container" id="gameContainer"><div class="level-banner">🏆 <span id="levelName">推理模式教程</span></div><div class="global-message" id="globalMessage"></div><div class="attrs-panel" id="attrsPanel"></div><div class="active-skills-bar" id="activeSkillsBar"></div><div class="score-progress-panel"><span class="score-progress-label">📊总分</span><div class="score-bar-outer"><div class="score-bar-inner" id="scoreBarInner"></div></div><span class="score-number" id="scoreNumber">0/100</span></div><div class="time-panel"><span class="time-icon">⏱️</span><span class="time-label">精力/时间</span><div class="time-bars-group"><div class="time-bar-outer"><div class="stamina-bar" id="staminaBar"></div></div><div class="time-bar-outer"><div class="time-bar-inner" id="timeBarInner"></div></div></div><span class="time-number" id="timeNumber">30</span><span style="font-size:.7rem;color:#888;">/精力<span id="staminaRef">35</span></span></div><div class="map-selector" id="mapSelector"></div><div class="canvas-wrapper" id="canvasWrapper"><canvas id="treeCanvas"></canvas></div><div class="info-bar"><div class="legend"><span class="legend-item"><span class="legend-dot process"></span>过程</span><span class="legend-item"><span class="legend-dot important"></span>重要</span><span class="legend-item"><span class="legend-dot result"></span>结果</span><span class="legend-item"><span class="legend-dot skill-node"></span>技能点</span><span class="legend-item"><span class="legend-dot check-ring"></span>可检查</span><span class="legend-item"><span class="legend-dot correct-box"></span>正确</span><span class="legend-item"><span class="legend-dot broken"></span>错误</span><span class="legend-item"><span class="legend-dot upgrade-node"></span>升级存量</span></div><div>地图<span id="mapIndexDisplay">1</span>/<span id="totalMapsDisplay">1</span> | 解锁<span id="unlockedCount">0</span> | 最高分<span id="maxScoreDisplay">-</span><span id="correctFoundHint" class="correct-found-hint" style="display:none">✅正确路径已找到</span></div></div><button class="btn btn-restart" id="btnRestart">🔄 重新开始</button></div><div class="tutorial-side-panel" id="tutorialSidePanel"><div class="tutorial-msg highlight" id="tutorialMsg">欢迎来到推理模式教程!</div></div><div class="side-panel" id="sidePanel"><div class="side-panel-title">🧠属性面板</div><div class="side-attr-row"><span class="side-attr-label">🧠思维</span><span class="side-attr-value" id="sideMindValue">4</span><span class="attr-focus-bonus" id="sideFocusBonus" style="display:none">+0</span></div><div class="side-attr-row"><span class="side-attr-label">👁️凝聚</span><button id="btnFocusSide" class="focus-btn-inline has-cost" data-cost="1⏰2⚡" title="聚焦(消耗1时间2精力,思维临时+1)">👁️</button></div><div class="side-attr-row"><span class="side-attr-label">🔍推理</span><button id="btnInferSide" class="focus-btn-inline" title="推理模式切换">🔍</button></div><div style="border-top:1px solid #eee;padding-top:6px;margin-top:2px;"><div style="font-weight:700;font-size:.78rem;color:#555;text-align:center;margin-bottom:4px;">📦升级存量</div><div class="side-stock-row"><span class="side-stock-icon">⏰</span><span class="side-stock-name">时间</span><span class="side-stock-count" id="sideTimeStock">0</span><div class="side-stock-bar"><div class="side-stock-fill time-fill" id="sideTimeStockBar" style="width:0%"></div></div></div><div class="side-stock-row"><span class="side-stock-icon">🧠</span><span class="side-stock-name">思维</span><span class="side-stock-count" id="sideMindStock">0</span><div class="side-stock-bar"><div class="side-stock-fill mind-fill" id="sideMindStockBar" style="width:0%"></div></div></div><div class="side-stock-row"><span class="side-stock-icon">💠</span><span class="side-stock-name">提升</span><span class="side-stock-count" id="sideBoostStock">0</span><div class="side-stock-bar"><div class="side-stock-fill boost-fill" id="sideBoostStockBar" style="width:0%"></div></div></div><div class="side-stock-row"><span class="side-stock-icon">⚡</span><span class="side-stock-name">振奋</span><span class="side-stock-count" id="sideInspireStock">0</span><div class="side-stock-bar"><div class="side-stock-fill inspire-fill" id="sideInspireStockBar" style="width:0%"></div></div></div></div><div style="border-top:1px solid #eee;padding-top:6px;margin-top:6px;"><div style="font-weight:700;font-size:.78rem;color:#555;text-align:center;margin-bottom:4px;">📖 图例</div><div class="legend" style="flex-direction:column;gap:3px;"><div class="legend-item"><span class="legend-dot process"></span> 过程</div><div class="legend-item"><span class="legend-dot important"></span> 重要</div><div class="legend-item"><span class="legend-dot result"></span> 结果</div><div class="legend-item"><span class="legend-dot skill-node"></span> 技能点</div><div class="legend-item"><span class="legend-dot check-ring"></span> 可检查</div><div class="legend-item"><span class="legend-dot correct-box"></span> 正确</div><div class="legend-item"><span class="legend-dot broken"></span> 错误</div><div class="legend-item"><span class="legend-dot upgrade-node"></span> 升级存量</div></div></div></div></div><script>
(function(){
const LW=1200,LH=700,canvas=document.getElementById('treeCanvas'),ctx=canvas.getContext('2d');canvas.width=LW;canvas.height=LH;
let map,remTime=30,remStamina=35,maxStamina=35,focusStacks=0,inferMode=!1,inferResults=new Map(),nodeAnimations={},gm=5,tutorialStep=0,gameStarted=!0;
let timeStock=0,mindStock=0,boostStock=0,inspireStock=0,timeBonus=0,mindBonus=0,boostLevel=0,inspireCount=0,lastMouseCanvasPos=null;
const tutEl=document.getElementById('tutorialMsg'),gmEl=document.getElementById('globalMessage'),topNoticeEl=document.getElementById('topNotice');
function setTut(t,cls){tutEl.innerHTML=t;tutEl.className='tutorial-msg';if(cls)tutEl.classList.add(cls)}
function setGM(t,ty){gmEl.textContent=t;gmEl.className='global-message';if(ty)gmEl.classList.add(ty);if(t){clearTimeout(gmEl._t);gmEl._t=setTimeout(()=>{gmEl.textContent='';gmEl.className='global-message'},5000)}}
function showTopNotice(text,duration=3000){topNoticeEl.textContent=text;topNoticeEl.style.display='block';clearTimeout(topNoticeEl._t);topNoticeEl._t=setTimeout(()=>{topNoticeEl.style.display='none'},duration)}
function getEffMind(){return gm+focusStacks+mindBonus}
function staminaCost(n){return Math.max(1,(n.req||0)-getEffMind())}
function getMaxSub(node){if(node.type==='result'||node.type==='skill')return node.score||0;let m=0;function dfs(n){if((n.type==='result'||n.type==='skill')&&n.score>m)m=n.score;n.children.forEach(dfs)}dfs(node);return m}
function hasCorrectDescendant(n){if(n===map.correctResult)return!0;for(const c of n.children)if(hasCorrectDescendant(c))return!0;return!1}
function hasSkillDescendant(n){if(n.type==='skill')return!0;for(const c of n.children)if(hasSkillDescendant(c))return!0;return!1}
function getInferenceBaseReq(node){const correctNode=map.correctResult;const trueDepth=correctNode?correctNode.depth:0;const nowDepth=node.depth!=null?node.depth:0;return 1+Math.abs(trueDepth-nowDepth)*4+(node.infExtraReq||0)}
function flashCorrectBorder(){const gc=document.getElementById('gameContainer');gc.classList.add('correct-flash');setTimeout(()=>gc.classList.remove('correct-flash'),550)}
function flashBlueBorder(){const gc=document.getElementById('gameContainer');gc.classList.add('blue-flash');setTimeout(()=>gc.classList.remove('blue-flash'),550)}
function toggleInferMode(){if(!gameStarted||map.gameOver)return;inferMode=!inferMode;document.getElementById('canvasWrapper').classList.toggle('inference',inferMode);const btn=document.getElementById('btnInferSide');if(btn){btn.classList.toggle('active',inferMode);btn.textContent=inferMode?'🔍✓':'🔍';}updateActBar();refreshUI();checkTutorialProgress();if(inferMode)showTopNotice('推理模式已开启');else showTopNotice('推理模式已关闭');}
function createTutorialMap(){
const defs=[{id:'R',name:'R',type:'process',isCorrect:!1,childIds:['A','B','D','E','F'],req:2,score:null,depth:0},{id:'A',name:'A',type:'process',isCorrect:!1,childIds:['A1','A2'],req:3,score:null,depth:1},{id:'A1',name:'A1',type:'result',isCorrect:!1,childIds:[],req:3,score:40,depth:2},{id:'A2',name:'A2',type:'result',isCorrect:!1,childIds:[],req:4,score:55,depth:2},{id:'B',name:'B',type:'process',isCorrect:!1,childIds:['B1','C','B2'],req:4,score:null,depth:1},{id:'B1',name:'B1',type:'result',isCorrect:!1,childIds:[],req:4,score:50,depth:2},{id:'C',name:'C',type:'result',isCorrect:!0,childIds:[],req:5,score:100,depth:2},{id:'B2',name:'B2',type:'result',isCorrect:!1,childIds:[],req:4,score:35,depth:2},{id:'D',name:'D',type:'process',isCorrect:!1,childIds:['D1','D2'],req:4,score:null,depth:1},{id:'D1',name:'D1',type:'result',isCorrect:!1,childIds:[],req:4,score:35,depth:2},{id:'D2',name:'D2',type:'result',isCorrect:!1,childIds:[],req:4,score:80,depth:2},{id:'E',name:'E',type:'process',isCorrect:!1,childIds:['E1'],req:3,score:null,depth:1},{id:'E1',name:'E1',type:'process',isCorrect:!1,childIds:[],req:3,score:null,depth:2},{id:'F',name:'F',type:'process',isCorrect:!1,childIds:['F1','F_skill'],req:7,score:null,depth:1,infExtraReq:1},{id:'F1',name:'F1',type:'result',isCorrect:!1,childIds:[],req:5,score:45,depth:2},{id:'F_skill',name:'💎F奖励',type:'skill',isCorrect:!1,childIds:[],req:4,score:0,depth:2,upgradeType:'boost'}];
const nm={};defs.forEach(d=>nm[d.id]={...d,children:[],parent:null,state:'hidden',x:0,y:0,isFork:!1,_b:null,_cb:null,upgradeType:d.upgradeType||null,infExtraReq:d.infExtraReq||0});
Object.values(nm).forEach(n=>{n.childIds.forEach(cid=>{const c=nm[cid];if(c){n.children.push(c);c.parent=n}});if(n.type==='process'&&n.children.length>1)n.isFork=!0});
const root=nm['R'];Object.values(nm).forEach(n=>n.state='hidden');root.state='visible_locked';
return{nodeMap:nm,root,correctResult:nm['C'],totalUnlocked:0,gameOver:!1,gameResult:null,maxResultScore:0,hasSkillNode:!0,skillNodeId:'F_skill',totalStaminaSpent:0,inferResults:new Map(),inferReqs:new Map()}
}
function computeLayout(md){const{nodeMap,root}=md;const lvls={},nlvl={};function assignLv(n,lv){n.depth=lv;nlvl[n.id]=lv;if(!lvls[lv])lvls[lv]=[];lvls[lv].push(n);n.children.forEach(c=>assignLv(c,lv+1))}assignLv(root,0);const maxLv=Math.max(...Object.keys(lvls).map(Number),0);const lvH=LH/(maxLv+2),topM=lvH*0.9;function leafCnt(n){if(!n.children.length)return 1;return n.children.reduce((s,c)=>s+leafCnt(c),0)}const lc={};Object.values(nodeMap).forEach(n=>lc[n.id]=leafCnt(n));const totalL=lc[root.id]||1,margin=60;function assignX(n,left,right){const w=(right-left)*(lc[n.id]/totalL);n.x=n===root?LW/2:left+w/2;n.y=topM+nlvl[n.id]*lvH;let childLeft=left;n.children.forEach(c=>{const cw=(right-left)*(lc[c.id]/totalL);assignX(c,childLeft,childLeft+cw);childLeft+=cw})}assignX(root,margin,LW-margin);Object.values(lvls).forEach(lns=>{lns.sort((a,b)=>a.x-b.x);for(let i=1;i<lns.length;i++)if(lns[i].x-lns[i-1].x<70)lns[i].x=lns[i-1].x+70;const avg=lns.reduce((s,n)=>s+n.x,0)/lns.length;lns.forEach(n=>n.x+=LW/2-avg);lns.forEach(n=>n.x=Math.max(margin,Math.min(LW-margin,n.x)))})}
function canUnlock(n){return n.state==='visible_locked'&&!map.gameOver&&remTime>0&&remStamina>0&&(n===map.root||(n.parent&&(n.parent.state==='unlocked'||n.parent.state==='correct'||n.parent.state==='incorrect')))}
function canCheck(n){return n.state==='unlocked'&&!map.gameOver&&remTime>0&&remStamina>0&&(n.type==='result'||n.type==='skill')}
function markCorrect(n){if(n.state!=='correct')n.state='correct'}
function markIncorrect(n){if(n.state==='incorrect'||n.state==='correct')return;n.state='incorrect';n.children.forEach(c=>markIncorrect(c))}
function checkFork(f){if(!f.isFork||f.state==='incorrect'||f.state==='correct')return;if(f.children.every(c=>c.state==='incorrect')){markIncorrect(f);if(f.parent?.isFork)checkFork(f.parent)}}
function isActionAllowed(action,node){
const ts=tutorialStep;
if(ts>=9)return!0;
if(ts===0){if(action==='keyR')return!0;if(action==='unlock'&&node.id==='R')return!0;return!1}
if(ts===1){if(action==='unlock'&&node.id==='B')return!0;if(action==='infer'&&node.id==='B')return!0;if(action==='unlock'&&node.id!=='B'){setGM('⚠️请先解锁节点B','warning');return!1}return!1}
if(ts===2){if(action==='unlock'&&node.id==='C')return!0;if(action==='check'&&node.id==='C')return!0;if(action==='unlock'&&node.id!=='C'){setGM('⚠️请先解锁并检查节点C(B的子节点)','warning');return!1}return!1}
if(ts===3){if(action==='unlock'&&node.id==='D')return!0;if(action==='infer'&&node.id==='D')return!0;if(action==='keyR')return!0;return!1}
if(ts===4){if(action==='unlock'&&node.id==='E')return!0;if(action==='infer'&&node.id==='E')return!0;return!1}
if(ts===5){if(action==='unlock'&&node.id==='F')return!0;return!1}
if(ts===6){if(action==='focus')return!0;return!1}
if(ts===7){if(action==='infer'&&node.id==='F')return!0;return!1}
if(ts===8)return!0;return!1
}
function unlockNode(node){if(!canUnlock(node)){if(node.state!=='visible_locked')setGM('⚠️节点无法解锁','warning');else if(map.gameOver)setGM('⚠️地图已结束','warning');else if(remTime<=0)setGM('⏰时间不足','warning');else if(remStamina<=0)setGM('⚡精力不足','warning');return!1}if(!isActionAllowed('unlock',node))return!1;remTime=Math.max(0,remTime-1);const sc=staminaCost(node);remStamina=Math.max(0,remStamina-sc);map.totalStaminaSpent=(map.totalStaminaSpent||0)+sc;map.totalUnlocked++;node.state='unlocked';nodeAnimations[node.id]={type:'unlock',start:performance.now(),dur:300};node.children.forEach(c=>{if(c.state==='hidden')c.state='visible_locked'});refreshUI();checkTutorialProgress();return!0}
function performCheck(node){if(!canCheck(node)){if(node.state!=='unlocked')setGM('⚠️节点不可检查','warning');else if(map.gameOver)setGM('⚠️地图已结束','warning');else if(remTime<=0)setGM('⏰时间不足','warning');else if(remStamina<=0)setGM('⚡精力不足','warning');return!1}if(!isActionAllowed('check',node))return!1;remTime=Math.max(0,remTime-1);const stc=staminaCost(node);remStamina=Math.max(0,remStamina-stc);map.totalStaminaSpent=(map.totalStaminaSpent||0)+stc;if(node.isCorrect){markCorrect(node);flashCorrectBorder();let fork=node.parent;while(fork&&!fork.isFork)fork=fork.parent;if(fork){let cur=node;while(cur&&cur!==fork){if(cur.type==='process'||cur.type==='skill')markCorrect(cur);cur=cur.parent}}}else{node.state='incorrect';let fork=node.parent;while(fork&&!fork.isFork)fork=fork.parent;if(fork){let cur=node;while(cur&&cur!==fork){if(cur.type==='process'||cur.type==='skill')cur.state='incorrect';cur=cur.parent}checkFork(fork)}}if(node.upgradeType){switch(node.upgradeType){case'time':timeStock++;setGM('⏰获得时间存量!','success');break;case'mind':mindStock++;setGM('🧠获得思维存量!','success');break;case'boost':boostStock++;setGM('💠获得提升存量!','success');break;case'inspire':inspireStock++;setGM('⚡获得振奋存量!','success');break}}map.maxResultScore=Math.max(map.maxResultScore||0,node.score||0);refreshUI();checkTutorialProgress();return!0}
function performInference(node){const effMind=getEffMind();const baseReq=getInferenceBaseReq(node);if(effMind<baseReq){setGM('思维不足,无法推理(需≥'+baseReq+')','warning');return!1}if(!isActionAllowed('infer',node))return!1;const cost=Math.max(1,baseReq+4-effMind);if(remStamina<cost){setGM('精力不足(需'+cost+')','warning');return!1}remStamina-=cost;const res={containsCorrect:hasCorrectDescendant(node),maxScoreZero:getMaxSub(node)===0,highReq:!1,hasSkillNode:hasSkillDescendant(node),upgradeStocks:[]};map.inferResults.set(node.id,res);refreshUI();checkTutorialProgress();return!0}
function refreshUI(){document.getElementById('timeNumber').textContent=remTime;document.getElementById('staminaRef').textContent=maxStamina;document.getElementById('unlockedCount').textContent=map.totalUnlocked;document.getElementById('mapIndexDisplay').textContent='1';document.getElementById('totalMapsDisplay').textContent='1';document.getElementById('maxScoreDisplay').textContent=map.maxResultScore>0?map.maxResultScore:'-';document.getElementById('correctFoundHint').style.display=(map.correctResult&&map.correctResult.state==='correct'&&!map.gameOver)?'inline-block':'none';const ts=map.maxResultScore||0;document.getElementById('scoreBarInner').style.width=Math.min(1,ts/100)*100+'%';document.getElementById('scoreNumber').textContent=ts+'/100';const tR=remTime/Math.max(1,30),sR=remStamina/Math.max(1,maxStamina);document.getElementById('timeBarInner').style.width=(tR*100)+'%';document.getElementById('staminaBar').style.width=(sR*100)+'%';document.getElementById('sideMindValue').textContent=getEffMind();document.getElementById('sideFocusBonus').style.display=focusStacks>0?'inline-block':'none';if(focusStacks>0)document.getElementById('sideFocusBonus').textContent='+'+focusStacks;updateMapBtns();drawTree(map);updateActBar();updateSideStocks()}
function updateSideStocks(){document.getElementById('sideTimeStock').textContent=timeStock;document.getElementById('sideMindStock').textContent=mindStock;document.getElementById('sideBoostStock').textContent=boostStock;document.getElementById('sideInspireStock').textContent=inspireStock;const mx=Math.max(timeStock,mindStock,boostStock,inspireStock,1);document.getElementById('sideTimeStockBar').style.width=(timeStock/mx*100)+'%';document.getElementById('sideMindStockBar').style.width=(mindStock/mx*100)+'%';document.getElementById('sideBoostStockBar').style.width=(boostStock/mx*100)+'%';document.getElementById('sideInspireStockBar').style.width=(inspireStock/mx*100)+'%'}
function updateMapBtns(){document.querySelectorAll('.map-btn').forEach(b=>{b.classList.add('active')})}
function updateActBar(){const b=document.getElementById('activeSkillsBar');let p=[];if(inferMode)p.push('<span class="active-skill-tag" style="color:#f90">推理模式·点击按钮或按R退出</span>');if(focusStacks)p.push('<span class="active-skill-tag">👁️聚焦+'+focusStacks+'</span>');b.innerHTML=p.join(' ')}
function drawTree(md){ctx.clearRect(0,0,LW,LH);ctx.fillStyle='#fcfcfc';ctx.fillRect(0,0,LW,LH);const vis=Object.values(md.nodeMap).filter(n=>{if(inferMode)return n.state==='unlocked'||n.state==='correct'||n.state==='incorrect'||n.state==='visible_locked';return n.state!=='hidden'});vis.forEach(n=>n.children.forEach(c=>{if(vis.includes(c))drawEdge(n,c)}));vis.forEach(n=>drawNode(n,md))}
function drawEdge(p,c){let col='#999';if(p.state==='correct'&&c.state==='correct')col='#555';else if(p.state==='incorrect'||c.state==='incorrect')col='#bbb';ctx.strokeStyle=col;ctx.lineWidth=2.5;ctx.beginPath();ctx.moveTo(p.x,p.y);ctx.lineTo(c.x,c.y);ctx.stroke()}
function drawNode(node,md){let cx=node.x,cy=node.y;const baseR=node.type==='important'?22:20;let r=baseR;const anim=nodeAnimations[node.id];if(anim&&anim.type==='unlock'){const elapsed=performance.now()-anim.start;const p=Math.min(1,elapsed/anim.dur);if(p<1){const scale=1+0.35*Math.sin(p*Math.PI);r=baseR*scale}else{delete nodeAnimations[node.id]}}const effMind=getEffMind();const baseInferReq=getInferenceBaseReq(node);const isGrayInfer=inferMode&&node.state==='unlocked'&&effMind<baseInferReq;let fill,stroke,tc,alpha=1;switch(node.state){case'visible_locked':fill=node.type==='process'?'#d5d5d5':'#999';stroke='#b0b0b0';tc='#444';break;case'unlocked':if(isGrayInfer){fill='#c8c8c8';stroke='#a0a0a0';tc='#888';alpha=0.45}else{fill='#3a3a3a';stroke='#1a1a1a';tc='#fff'}break;case'correct':fill='#3a3a3a';stroke='#1a1a1a';tc='#fff';break;case'incorrect':fill='#fff';stroke='#999';tc='#555';break;default:return}
if(node.upgradeType&&(node.state==='unlocked'||node.state==='correct'||node.state==='incorrect'||node.state==='visible_locked')){ctx.save();ctx.globalAlpha=alpha;let ugCol='#f90';if(node.upgradeType==='time')ugCol='#5b9bd5';else if(node.upgradeType==='mind')ugCol='#e8943a';else if(node.upgradeType==='boost')ugCol='#9b59b6';else if(node.upgradeType==='inspire')ugCol='#d4a017';ctx.strokeStyle=ugCol;ctx.lineWidth=3;ctx.setLineDash([3,2]);ctx.beginPath();ctx.arc(cx,cy,r+7,0,Math.PI*2);ctx.stroke();ctx.setLineDash([]);ctx.restore()}
const ir=md.inferResults.get(node.id);
if(ir&&node.state==='unlocked'&&!isGrayInfer){
if(ir.containsCorrect){ctx.save();ctx.globalAlpha=alpha;ctx.strokeStyle='#f90';ctx.lineWidth=2;ctx.setLineDash([4,4]);ctx.beginPath();if(node.type==='result'){const hs=r*0.85;ctx.rect(cx-hs-4,cy-hs-4,(hs+4)*2,(hs+4)*2)}else if(node.type==='skill'){ctx.moveTo(cx,cy-r-4);ctx.lineTo(cx+r+4,cy);ctx.lineTo(cx,cy+r+4);ctx.lineTo(cx-r-4,cy);ctx.closePath()}else{ctx.arc(cx,cy,r+4,0,Math.PI*2)}ctx.stroke();ctx.setLineDash([]);ctx.restore()}
if(ir.maxScoreZero){ctx.save();ctx.globalAlpha=alpha;ctx.strokeStyle='#d00';ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(cx-r,cy-r);ctx.lineTo(cx+r,cy+r);ctx.moveTo(cx+r,cy-r);ctx.lineTo(cx-r,cy+r);ctx.stroke();ctx.restore()}
if(ir.hasSkillNode){ctx.save();ctx.globalAlpha=alpha;ctx.fillStyle='#3399ff';ctx.strokeStyle='#1a5276';ctx.lineWidth=1.5;ctx.beginPath();const d=6;ctx.moveTo(cx+r+4,cy+r+4);ctx.lineTo(cx+r+4+d,cy+r+4);ctx.lineTo(cx+r+4,cy+r+4+d);ctx.lineTo(cx+r+4-d,cy+r+4);ctx.closePath();ctx.fill();ctx.stroke();ctx.restore()}
}
ctx.save();ctx.globalAlpha=alpha;
if(node.type==='skill'){stroke=node.state==='incorrect'?'#999':(node.state==='correct'?'#1a1a1a':(isGrayInfer?'#a0a0a0':'#aaa'));ctx.fillStyle=fill;ctx.strokeStyle=stroke;ctx.lineWidth=2.5;if(node.state==='incorrect')ctx.setLineDash([5,3]);ctx.beginPath();ctx.moveTo(cx,cy-r);ctx.lineTo(cx+r,cy);ctx.lineTo(cx,cy+r);ctx.lineTo(cx-r,cy);ctx.closePath();ctx.fill();ctx.stroke();ctx.setLineDash([]);node._b={x:cx-r,y:cy-r,w:r*2,h:r*2}}
else if(node.type==='result'){const hs=r*0.85;ctx.fillStyle=fill;ctx.strokeStyle=stroke;ctx.lineWidth=2.5;if(node.state==='incorrect')ctx.setLineDash([5,3]);ctx.beginPath();ctx.rect(cx-hs,cy-hs,hs*2,hs*2);ctx.fill();ctx.stroke();ctx.setLineDash([]);node._b={x:cx-hs,y:cy-hs,w:hs*2,h:hs*2}}
else{ctx.fillStyle=fill;ctx.strokeStyle=stroke;ctx.lineWidth=2.5;if(node.state==='incorrect')ctx.setLineDash([5,3]);ctx.beginPath();ctx.arc(cx,cy,r,0,Math.PI*2);ctx.fill();ctx.stroke();ctx.setLineDash([]);node._b=null}
if(node.state==='unlocked'){const showRing=node.type==='result'||node.type==='skill';if(showRing&&!map.gameOver&&!isGrayInfer){const rr=(node.type==='result'?r*0.85:r)+5;ctx.strokeStyle='#333';ctx.lineWidth=2.8;ctx.beginPath();ctx.arc(cx,cy,rr,0,Math.PI*2);ctx.stroke();node._cb={x:cx-rr-3,y:cy-rr-3,w:(rr+3)*2,h:(rr+3)*2}}else node._cb=null}else node._cb=null;
if(node.state==='visible_locked'&&!map.gameOver&&!isGrayInfer){const rr=(node.type==='result'?r*0.85:r)+5;node._cb={x:cx-rr-3,y:cy-rr-3,w:(rr+3)*2,h:(rr+3)*2}}
if(inferMode&&node.state==='unlocked'){const inferCost=Math.max(1,baseInferReq+4-effMind);ctx.fillStyle=isGrayInfer?'#999':'#f90';ctx.font='bold 10px sans-serif';ctx.textAlign='center';ctx.fillText('精力消耗:'+inferCost,cx,cy-r-20)}
if(ir&&!inferMode&&node.state==='unlocked'){ctx.save();ctx.fillStyle='#f90';ctx.font='bold 8px sans-serif';ctx.textAlign='center';let tag='';if(ir.containsCorrect)tag+='✓';if(ir.maxScoreZero)tag+='✗';if(ir.highReq)tag+='⚠';if(tag)ctx.fillText(tag,cx,cy+r+24);ctx.restore()}
if(node.state==='incorrect'){const sc=getMaxSub(node);ctx.fillStyle='#888';ctx.font='bold 14px sans-serif';ctx.textAlign='center';ctx.fillText(sc,cx,cy)}
else{ctx.fillStyle=tc;ctx.font='bold 11px sans-serif';ctx.textAlign='center';ctx.fillText(node.name,cx,cy);if((node.type==='result'||node.type==='skill')&&node.score!==null&&(node.state==='unlocked'||node.state==='correct')){ctx.font='bold 9px sans-serif';ctx.fillText(node.score,cx,cy+12)}}
const stCost=staminaCost(node);ctx.fillStyle=stCost<=1?'#aaa':(stCost<=3?'#777':(stCost===4?'#444':'#222'));ctx.font='bold 10px sans-serif';ctx.textAlign='center';ctx.fillText(stCost,cx,cy-r-3);ctx.fillStyle=(node.state==='correct'||node.state==='unlocked')?'#555':'#888';ctx.font='9px sans-serif';ctx.fillText('需≥'+node.req,cx,cy+r+12);ctx.restore()}
function hitTest(pos){const vis=Object.values(map.nodeMap).filter(n=>inferMode?(n.state==='unlocked'||n.state==='correct'||n.state==='incorrect'||n.state==='visible_locked'):n.state!=='hidden');if(inferMode){for(const n of vis){if(n.state==='visible_locked'){let inRange=!1;if(n._cb&&pos.x>=n._cb.x&&pos.x<=n._cb.x+n._cb.w&&pos.y>=n._cb.y&&pos.y<=n._cb.y+n._cb.h)inRange=!0;else if(n._b&&pos.x>=n._b.x&&pos.x<=n._b.x+n._b.w&&pos.y>=n._b.y&&pos.y<=n._b.y+n._b.h)inRange=!0;else{const rr=20+3;inRange=Math.hypot(pos.x-n.x,pos.y-n.y)<=rr}if(inRange&&canUnlock(n))return{node:n,target:'node'}}if(n.state==='unlocked'){const baseReq=getInferenceBaseReq(n);if(getEffMind()<baseReq)continue;let inRange=!1;if(n._cb&&pos.x>=n._cb.x&&pos.x<=n._cb.x+n._cb.w&&pos.y>=n._cb.y&&pos.y<=n._cb.y+n._cb.h)inRange=!0;else if(n._b&&pos.x>=n._b.x&&pos.x<=n._b.x+n._b.w&&pos.y>=n._b.y&&pos.y<=n._b.y+n._b.h)inRange=!0;else{const rr=20+3;inRange=Math.hypot(pos.x-n.x,pos.y-n.y)<=rr}if(inRange)return{node:n,target:'infer'}}}return null}
for(const n of vis){if(n._cb&&pos.x>=n._cb.x&&pos.x<=n._cb.x+n._cb.w&&pos.y>=n._cb.y&&pos.y<=n._cb.y+n._cb.h){if(n.state==='unlocked'&&canCheck(n))return{node:n,target:'check'};if(n.state==='visible_locked'&&canUnlock(n))return{node:n,target:'node'};return null}}
for(const n of vis){if(n._b){if(pos.x>=n._b.x&&pos.x<=n._b.x+n._b.w&&pos.y>=n._b.y&&pos.y<=n._b.y+n._b.h){if(n.state==='unlocked'&&canCheck(n))return{node:n,target:'check'};if(n.state==='visible_locked'&&canUnlock(n))return{node:n,target:'node'};return null}}else{const rr=20+3;if(Math.hypot(pos.x-n.x,pos.y-n.y)<=rr){if(n.state==='unlocked'&&canCheck(n))return{node:n,target:'check'};if(n.state==='visible_locked'&&canUnlock(n))return{node:n,target:'node'};return null}}}return null}
canvas.addEventListener('click',e=>{if(!gameStarted||map.gameOver)return;const rect=canvas.getBoundingClientRect();const pos={x:(e.clientX-rect.left)*(LW/canvas.clientWidth),y:(e.clientY-rect.top)*(LH/canvas.clientHeight)};const hit=hitTest(pos);if(hit){if(inferMode){if(hit.target==='node')unlockNode(hit.node);else if(hit.target==='infer')performInference(hit.node)}else{if(hit.target==='check')performCheck(hit.node);else if(hit.target==='node')unlockNode(hit.node)}}else{if(!inferMode){const vis=Object.values(map.nodeMap).filter(n=>n.state!=='hidden');for(const n of vis){if(n.state==='unlocked'&&n.type==='process'){const r=20+3;if(Math.hypot(pos.x-n.x,pos.y-n.y)<=r){showTopNotice('请按下 R 键或点击右侧按钮开启推理模式');break;}}}}}});
canvas.addEventListener('mousemove',e=>{if(!gameStarted||map.gameOver){canvas.style.cursor='default';lastMouseCanvasPos=null;return}const rect=canvas.getBoundingClientRect();const pos={x:(e.clientX-rect.left)*(LW/canvas.clientWidth),y:(e.clientY-rect.top)*(LH/canvas.clientHeight)};lastMouseCanvasPos=pos;const hit=hitTest(pos);canvas.style.cursor=hit?'pointer':'default'});
document.addEventListener('keydown',e=>{
if(e.key==='r'||e.key==='R'){if(gameStarted&&!map.gameOver){if(!isActionAllowed('keyR',null))return;toggleInferMode();}}
if(e.key==='e'||e.key==='E'){if(gameStarted&&!map.gameOver&&lastMouseCanvasPos){const hit=hitTest(lastMouseCanvasPos);if(hit){if(inferMode){if(hit.target==='node')unlockNode(hit.node);else if(hit.target==='infer')performInference(hit.node)}else{if(hit.target==='check')performCheck(hit.node);else if(hit.target==='node')unlockNode(hit.node)}}else if(!inferMode){const vis=Object.values(map.nodeMap).filter(n=>n.state!=='hidden');for(const n of vis){if(n.state==='unlocked'&&n.type==='process'){const r=20+3;if(Math.hypot(lastMouseCanvasPos.x-n.x,lastMouseCanvasPos.y-n.y)<=r){showTopNotice('请按下 R 键或点击右侧按钮开启推理模式');break;}}}}}}
if(e.key==='f'||e.key==='F'){document.getElementById('sidePanel').classList.toggle('collapsed');}
});
document.getElementById('btnFocusSide').addEventListener('click',()=>{if(!gameStarted||map.gameOver)return;if(!isActionAllowed('focus',null))return;if(remTime<1||remStamina<2){setGM('资源不足','warning');return}remTime--;remStamina-=2;focusStacks++;updateActBar();refreshUI();checkTutorialProgress()});
document.getElementById('btnInferSide').addEventListener('click',()=>{if(!gameStarted||map.gameOver)return;if(!isActionAllowed('keyR',null))return;toggleInferMode();});
document.getElementById('btnRestart').addEventListener('click',()=>{tutorialStep=0;gm=5;focusStacks=0;inferMode=!1;inferResults.clear();nodeAnimations={};timeStock=0;mindStock=0;boostStock=0;inspireStock=0;timeBonus=0;mindBonus=0;boostLevel=0;inspireCount=0;remTime=30;remStamina=35;maxStamina=35;document.getElementById('canvasWrapper').classList.remove('inference');document.getElementById('btnInferSide').classList.remove('active');document.getElementById('btnInferSide').textContent='🔍';initTutorial()});
function initTutorial(){map=createTutorialMap();computeLayout(map);remTime=30;remStamina=35;maxStamina=35;gm=5;focusStacks=0;inferMode=!1;inferResults.clear();nodeAnimations={};timeStock=0;mindStock=0;boostStock=0;inspireStock=0;timeBonus=0;mindBonus=0;boostLevel=0;inspireCount=0;tutorialStep=0;document.getElementById('canvasWrapper').classList.remove('inference');document.getElementById('levelName').textContent='推理模式教程';updateMapBtnsFromMap();setTut('欢迎来到推理模式教程!\n请点击右侧🔍按钮或按 R 键开启推理模式\n(推理模式可以帮你判断节点子树中是否有正确结果)','highlight');refreshUI();gameStarted=!0}
function updateMapBtnsFromMap(){const sel=document.getElementById('mapSelector');sel.innerHTML='';const b=document.createElement('button');b.className='map-btn active';b.dataset.index=0;b.textContent='📖教程地图';sel.appendChild(b)}
function checkTutorialProgress(){
switch(tutorialStep){
case 0:{if(inferMode){tutorialStep=1;setTut('推理模式已开启!🎯\n现在画布边框变为橙色,节点上显示精力消耗。\n请解锁节点B,然后点击或对它按下 E 键进行推理。\n💡在推理模式下:点击未解锁节点=解锁,点击已解锁节点=推理','highlight');refreshUI()}break}
case 1:{const bNode=map.nodeMap['B'];if(bNode&&bNode.state==='unlocked'){setTut('节点B已解锁!现在点击B进行推理\n(推理会分析B的子树结构并显示标记)','highlight')}const irB=map.inferResults.get('B');if(irB){tutorialStep=2;setTut('推理完成!🔍\n看B节点外面的橙色虚线边框——这表示B的子树中有正确结果节点(100分)!\n橙色虚线边框=子树内包含正确结果\n现在点击右侧🔍按钮或按R退出推理模式,然后解锁并检查节点C(B的子节点,100分结果)','highlight');inferMode=!1;document.getElementById('canvasWrapper').classList.remove('inference');document.getElementById('btnInferSide').classList.remove('active');document.getElementById('btnInferSide').textContent='🔍';refreshUI()}break}
case 2:{const cNode=map.nodeMap['C'];if(cNode&&(cNode.state==='correct'||cNode.state==='incorrect')){tutorialStep=3;setTut('节点C已检查!🎉\nC是100分正确结果节点!绿色边框闪烁表示找到了正确路径。\n现在点击右侧🔍按钮或按R重新进入推理模式,解锁并推理节点D\n(D是一个过程节点,推理它会显示其子树信息)','highlight');refreshUI()}break}
case 3:{if(inferMode&&map.nodeMap['D']&&map.nodeMap['D'].state==='unlocked'){setTut('节点D已解锁!现在点击D进行推理','highlight')}const irD=map.inferResults.get('D');if(irD){tutorialStep=4;setTut('推理D完成!你会发现它展示了棍母,这意味着它没有任何特殊性质\n现在请解锁节点E并推理它\n💡E的子树中没有结果节点,推理后会显示红叉','highlight');refreshUI()}break}
case 4:{const irE=map.inferResults.get('E');if(irE&&irE.maxScoreZero){tutorialStep=5;setTut('看到了吗?E节点上的红色✗!\n红叉=子树中没有结果节点(分数为0)\n这意味着探索E是浪费时间。\n现在请解锁节点F(右侧节点)','highlight');refreshUI()}break}
case 5:{const fNode=map.nodeMap['F'];if(fNode&&fNode.state==='unlocked'){tutorialStep=6;const baseReq=getInferenceBaseReq(fNode);setTut('节点F已解锁!但在推理模式下它变灰了...\nF的思维需求为≥'+baseReq+',而你当前思维为'+getEffMind()+'。\n思维不足时无法推理!请点击侧边栏的👁️聚焦按钮或者按 Q 键\n(消耗1时间2精力,思维临时+1)','highlight');refreshUI()}break}
case 6:{if(focusStacks>0){tutorialStep=7;const baseReq=getInferenceBaseReq(map.nodeMap['F']);setTut('聚焦成功!思维提升到'+getEffMind()+'。\n现在F节点应该亮起来了,点击F进行推理!\n💡F的子树中有特殊奖励节点','highlight');refreshUI()}break}
case 7:{const irF=map.inferResults.get('F');if(irF&&irF.hasSkillNode){tutorialStep=8;setTut('推理F完成!🔍\n看到F节点右下角的蓝色小三角了吗?\n蓝色三角=子树内有特殊奖励节点(技能点/升级存量)\n\n教程完成!准备关闭...','success');refreshUI();setTimeout(()=>{tutorialStep=9;setTut('🎉推理模式教程全部完成!\n总结:\n·点击🔍按钮或按R切换推理模式\n·橙色虚线边框=子树有正确结果\n·红叉=子树无结果节点\n·蓝色三角=子树有特殊奖励\n·思维不足时节点变灰,使用聚焦提升思维\n\n正在关闭教程...','success');setTimeout(()=>{try{window.close()}catch(e){setTut('教程完成!请关闭此标签页。','success')}},2500)},2000)}break}
case 8:break;case 9:break;
}
}
function animLoop(){let needsRedraw=!1;const now=performance.now();for(const k in nodeAnimations){const a=nodeAnimations[k];if(a.type==='unlock'&&now-a.start<a.dur){needsRedraw=!0}else if(now-a.start>=a.dur){delete nodeAnimations[k];needsRedraw=!0}}if(needsRedraw&&map)drawTree(map);if(Object.keys(nodeAnimations).length>0)requestAnimationFrame(animLoop)}setInterval(()=>{if(Object.keys(nodeAnimations).length>0)animLoop()},50);
initTutorial();
})();</script></body></html>