Files
student_management_system/deploy/site/_next/static/chunks/page-Xk19HOzS.js
T
2026-09-21 17:30:02 +08:00

1 line
15 KiB
JavaScript

import{r as e}from"./rolldown-runtime-C60lm6uB.js";import{i as t,r as n}from"./framework-D_rUT4EX.js";var r=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),i=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),a=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),o=e=>{let t=a(e);return t.charAt(0).toUpperCase()+t.slice(1)},s={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=e(t(),1),u=(0,l.createContext)({}),d=()=>(0,l.useContext)(u),f=(0,l.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:i,className:a=``,children:o,iconNode:u,...f},p)=>{let{size:m=24,strokeWidth:h=2,absoluteStrokeWidth:ee=!1,color:te=`currentColor`,className:g=``}=d()??{},_=i??ee?Number(n??h)*24/Number(t??m):n??h;return(0,l.createElement)(`svg`,{ref:p,...s,width:t??m??s.width,height:t??m??s.height,stroke:e??te,strokeWidth:_,className:r(`lucide`,g,a),...!o&&!c(f)&&{"aria-hidden":`true`},...f},[...u.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(o)?o:[o]])}),p=(e,t)=>{let n=(0,l.forwardRef)(({className:n,...a},s)=>(0,l.createElement)(f,{ref:s,iconNode:t,className:r(`lucide-${i(o(e))}`,`lucide-${e}`,n),...a}));return n.displayName=o(e),n},m=p(`circle-dollar-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]),h=p(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),ee=p(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),te=p(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),g=n(),_=[`♠`,`♥`,`♦`,`♣`],v=[`A`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`],y=[25,50,100,500],b=e=>new Promise(t=>window.setTimeout(t,e)),x=e=>e===`A`?11:[`J`,`Q`,`K`].includes(e)?10:Number(e),ne=e=>[`2`,`3`,`4`,`5`,`6`].includes(e)?1:[`10`,`J`,`Q`,`K`,`A`].includes(e)?-1:0;function S(e){let t=e.reduce((e,t)=>e+x(t.rank),0),n=e.filter(e=>e.rank===`A`).length;for(;t>21&&n;)t-=10,--n;return{total:t,soft:n>0}}function C(){let e=[];for(let t=0;t<6;t++)for(let n of _)for(let r of v)e.push({id:`${t}-${n}-${r}-${Math.random().toString(36).slice(2)}`,suit:n,rank:r});for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function re(e,t){let n=x(t.rank),{total:r,soft:i}=S(e);if(e.length===2&&x(e[0].rank)===x(e[1].rank)){let t=x(e[0].rank);if(t===11||t===8||[2,3].includes(t)&&n>=2&&n<=7||t===4&&[5,6].includes(n)||t===6&&n>=2&&n<=6||t===7&&n>=2&&n<=7||t===9&&(n>=2&&n<=6||[8,9].includes(n)))return`分牌`}return e.length===2&&(i&&(r===18&&n>=2&&n<=6||r===17&&n>=3&&n<=6||r>=15&&r<=16&&n>=4&&n<=6||r<=14&&n>=5&&n<=6)||!i&&(r===11&&n!==11||r===10&&n<=9||r===9&&n>=3&&n<=6))?`加倍`:i?r>=19?`停牌`:r===18?n>=9||n===11?`要牌`:`停牌`:`要牌`:r>=17?`停牌`:r>=13?n>=2&&n<=6?`停牌`:`要牌`:r===12&&n>=4&&n<=6?`停牌`:`要牌`}function ie({card:e,target:t}){let n=e.suit===`♥`||e.suit===`♦`;return(0,g.jsx)(`div`,{className:`playing-card deal-to-${t} ${e.hidden?`card-back`:``} ${e.flipping?`card-flip`:``} ${n?`red`:``}`,"data-card-id":e.id,children:e.hidden?(0,g.jsx)(`div`,{className:`back-medallion`,children:`21`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`card-corner`,children:[(0,g.jsx)(`b`,{children:e.rank}),(0,g.jsx)(`span`,{children:e.suit})]}),(0,g.jsx)(`div`,{className:`card-suit`,children:e.suit}),(0,g.jsxs)(`div`,{className:`card-corner bottom`,children:[(0,g.jsx)(`b`,{children:e.rank}),(0,g.jsx)(`span`,{children:e.suit})]})]})})}function w(){let[e,t]=(0,l.useState)(C),[n,r]=(0,l.useState)([]),[i,a]=(0,l.useState)([]),[o,s]=(0,l.useState)(0),[c,u]=(0,l.useState)(100),[d,f]=(0,l.useState)(0),[p,_]=(0,l.useState)(0),[v,w]=(0,l.useState)(0),[T,E]=(0,l.useState)(`betting`),[ae,D]=(0,l.useState)(`选择下注金额,开始新一局`),[O,oe]=(0,l.useState)(!1),[k,A]=(0,l.useState)(null),j=(0,l.useRef)(e),M=(0,l.useRef)([]),N=(0,l.useRef)([]),P=(0,l.useRef)(0),F=(0,l.useRef)(!1),I=(0,l.useRef)(!1),L=(0,l.useRef)(null),R=e=>{j.current=e,t(e)},z=e=>{M.current=e,r(e)},B=e=>{N.current=e,a(e)},V=e=>{P.current=e,s(e)},H=e=>{F.current=e,oe(e)};(0,l.useEffect)(()=>(queueMicrotask(()=>{let e=localStorage.getItem(`blackjack-ledger`);if(e)try{let t=JSON.parse(e);f(t.profit??0),_(t.rounds??0)}catch{localStorage.removeItem(`blackjack-ledger`)}}),()=>{L.current&&window.clearTimeout(L.current)}),[]),(0,l.useEffect)(()=>{localStorage.setItem(`blackjack-ledger`,JSON.stringify({profit:d,rounds:p}))},[d,p]);let U=n[o],W=U?S(U.cards):null,G=S(i.filter(e=>!e.hidden)),K=Math.max(e.length/52,.25),q=v/K,se=T===`player`&&n.length===1&&U?.cards.length===2&&x(U.cards[0].rank)===x(U.cards[1].rank),ce=T===`player`&&U&&i[0]?re(U.cards,i[0]):null,le=n.reduce((e,t)=>e+t.bet,0);function ue(){let e=[...j.current],t=e.pop();if(!t)throw Error(`牌靴为空`);return R(e),t}function J(e){w(t=>t+ne(e.rank))}async function Y(e){let t=ue();return z(M.current.map((n,r)=>r===e?{...n,cards:[...n.cards,t]}:n)),J(t),await b(430),t}async function X(e=!1){let t={...ue(),hidden:e};return B([...N.current,t]),e||J(t),await b(430),t}function Z(){L.current&&window.clearTimeout(L.current),L.current=null,A(null)}async function de(){let e=N.current.find(e=>e.hidden);e&&(B(N.current.map(t=>t.id===e.id?{...t,hidden:!1,flipping:!0}:t)),J(e),await b(480))}function fe(e){Z(),A(e),L.current=window.setTimeout(()=>{A(null),L.current=null},3e3)}function pe(e,t){if(I.current)return;I.current=!0;let n=S(e).total,r=e.length===2&&n===21,i=M.current.map(e=>{let t=S(e.cards).total,i=M.current.length===1&&e.cards.length===2&&t===21;return t>21?{delta:-e.bet,kind:`bust`}:i&&!r?{delta:e.bet*1.5,kind:`win`}:r&&!i?{delta:-e.bet,kind:`lose`}:n>21||t>n?{delta:e.bet,kind:`win`}:t<n?{delta:-e.bet,kind:`lose`}:{delta:0,kind:`push`}}),a=i.reduce((e,t)=>e+t.delta,0),o=i.every(e=>e.kind===`bust`),s=o?`爆牌`:a>0?`玩家胜利`:a<0?`庄家胜利`:`平局`,c=t===`dealer-blackjack`?`庄家 Blackjack`:o?`手牌点数超过 21`:n>21?`庄家爆牌 · 本局 ${a>=0?`+`:``}¥${a.toLocaleString()}`:`${M.current.length>1?`分牌合计`:`庄家 ${n} 点`} · 本局 ${a>=0?`+`:``}¥${a.toLocaleString()}`;f(e=>e+a),_(e=>e+1),E(`settled`),D(s),H(!1),fe({title:s,detail:c,tone:o?`bust`:a>0?`win`:a<0?`lose`:`push`})}async function Q(e){if(I.current)return;H(!0),E(`dealer`),D(`庄家行动中`),await de();let t=M.current.length>0&&M.current.every(e=>S(e.cards).total>21);if(!e&&!t)for(;S(N.current).total<17||S(N.current).total===17&&S(N.current).soft;)await X(!1);pe(N.current,e)}async function me(e){if(F.current||![`betting`,`settled`].includes(T))return;H(!0),I.current=!1,Z(),D(`正在发牌`),E(`dealing`),V(0),z([]),B([]),await b(180),j.current.length<52&&(R(C()),w(0));let t=e??c;u(t),z([{id:`hand-${Date.now()}`,cards:[],bet:t,done:!1}]),await Y(0),await X(!1),await Y(0),await X(!0);let n=S(M.current[0].cards).total===21,r=S(N.current).total===21;if(n||r){await Q(r?`dealer-blackjack`:void 0);return}E(`player`),D(`轮到玩家行动`),H(!1)}async function $(e=M.current[P.current].cards){let t=P.current,n=M.current.map((n,r)=>r===t?{...n,cards:e,done:!0}:n);z(n);let r=n.findIndex((e,n)=>n>t&&!e.done);if(r>=0){V(r),E(`player`),D(`轮到玩家第 ${r+1} 手`),H(!1);return}await Q()}async function he(){if(F.current||T!==`player`)return;H(!0),D(`玩家要牌`),await Y(P.current);let e=M.current[P.current].cards;S(e).total>21?(D(`本手爆牌`),await b(280),await $(e)):H(!1)}async function ge(){F.current||T!==`player`||(H(!0),D(`玩家停牌`),await $())}async function _e(){if(F.current||T!==`player`||!U||U.cards.length!==2)return;H(!0);let e=P.current;z(M.current.map((t,n)=>n===e?{...t,bet:t.bet*2}:t)),D(`加倍,只发一张`),await Y(e),await $()}async function ve(){if(F.current||!se||!U)return;H(!0),D(`正在分牌`);let[e,t]=U.cards;z([{id:`${U.id}-1`,cards:[e],bet:U.bet,done:!1},{id:`${U.id}-2`,cards:[t],bet:U.bet,done:!1}]),V(0),await Y(0),await Y(1),e.rank===`A`?(z(M.current.map(e=>({...e,done:!0}))),await Q()):(E(`player`),D(`轮到玩家第 1 手`),H(!1))}function ye(){F.current||(Z(),R(C()),z([]),B([]),V(0),w(0),I.current=!1,E(`betting`),D(`牌靴已重新洗牌`))}(0,l.useEffect)(()=>{let e=document.modelContext;if(!e?.registerTool)return;let t=new AbortController;return Promise.resolve(e.registerTool({name:`start_blackjack_round`,title:`开始一局 21 点`,description:`用指定筹码下注并开始一局新的 21 点。`,inputSchema:{type:`object`,properties:{wager:{type:`number`,enum:y}},required:[`wager`],additionalProperties:!1},annotations:{readOnlyHint:!1,untrustedContentHint:!1},execute(e){let t=e?.wager;if(!t||!y.includes(t))throw Error(`下注额必须是 25、50、100 或 500`);if(F.current||![`betting`,`settled`].includes(T))throw Error(`当前牌局尚未结束`);return me(t),{status:`dealing`,wager:t}}},{signal:t.signal})).catch(()=>void 0),()=>t.abort()},[T]);let be=(0,l.useMemo)(()=>O?`动画进行中`:ce??`等待发牌`,[O,ce]);return(0,g.jsxs)(`main`,{className:`game-shell`,children:[(0,g.jsxs)(`header`,{className:`topbar`,children:[(0,g.jsxs)(`div`,{className:`brand`,children:[(0,g.jsx)(`div`,{className:`brand-mark`,children:`21`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{children:`决战 21 点`}),(0,g.jsx)(`p`,{children:`BLACKJACK TRAINING TABLE`})]})]}),(0,g.jsxs)(`div`,{className:`rules`,children:[(0,g.jsx)(`span`,{children:`6 副牌`}),(0,g.jsx)(`i`,{}),(0,g.jsx)(`span`,{children:`Blackjack 3:2`}),(0,g.jsx)(`i`,{}),(0,g.jsx)(`span`,{children:`庄家 H17`})]}),(0,g.jsx)(`button`,{className:`icon-button`,onClick:ye,disabled:O,"aria-label":`重新洗牌`,children:(0,g.jsx)(h,{size:18})})]}),(0,g.jsx)(`section`,{className:`table-wrap`,children:(0,g.jsxs)(`div`,{className:`table`,children:[(0,g.jsx)(`div`,{className:`table-ring`}),(0,g.jsxs)(`div`,{className:`shoe-stack`,"aria-label":`牌堆`,children:[(0,g.jsx)(`span`,{children:`21`}),(0,g.jsx)(`small`,{children:e.length})]}),(0,g.jsxs)(`section`,{className:`play-zone dealer-zone ${T===`dealer`?`active-zone`:``}`,"aria-label":`庄家区域`,children:[(0,g.jsxs)(`div`,{className:`zone-heading`,children:[(0,g.jsx)(`span`,{className:`zone-dot`}),(0,g.jsx)(`strong`,{children:`庄家`}),i.length>0&&(0,g.jsxs)(`b`,{children:[G.total,G.soft?` · 软`:``]})]}),(0,g.jsxs)(`div`,{className:`hand dealer-hand`,children:[i.map(e=>(0,g.jsx)(ie,{card:e,target:`dealer`},e.id)),i.length===0&&(0,g.jsx)(`span`,{className:`empty-hand`,children:`等待发牌`})]})]}),(0,g.jsxs)(`div`,{className:`table-copy`,children:[(0,g.jsx)(`span`,{children:`BLACKJACK PAYS 3 TO 2`}),(0,g.jsx)(`small`,{children:`DEALER HITS SOFT 17`})]}),(0,g.jsxs)(`section`,{className:`play-zone player-zone ${T===`player`?`active-zone`:``}`,"aria-label":`玩家区域`,children:[(0,g.jsx)(`div`,{className:`player-hands`,children:n.map((e,t)=>(0,g.jsxs)(`div`,{className:`hand-wrap ${t===o&&T===`player`?`active-hand`:``}`,children:[(0,g.jsx)(`div`,{className:`hand`,children:e.cards.map(e=>(0,g.jsx)(ie,{card:e,target:`player`},e.id))}),n.length>1&&(0,g.jsxs)(`small`,{children:[`第 `,t+1,` 手 · `,S(e.cards).total,` 点 · ¥`,e.bet]})]},e.id))}),n.length===0&&(0,g.jsx)(`div`,{className:`hand`,children:(0,g.jsx)(`span`,{className:`empty-hand`,children:`选择筹码后发牌`})}),(0,g.jsxs)(`div`,{className:`zone-heading`,children:[(0,g.jsx)(`span`,{className:`zone-dot`}),(0,g.jsx)(`strong`,{children:`玩家`}),W&&(0,g.jsxs)(`b`,{children:[W.total,W.soft?` · 软`:``]})]}),le>0&&(0,g.jsxs)(`div`,{className:`wager-chip`,children:[`¥`,le]})]}),(0,g.jsxs)(`div`,{className:`status-pill`,children:[(0,g.jsx)(te,{size:15}),ae]}),k&&(0,g.jsxs)(`output`,{className:`round-result result-${k.tone}`,children:[(0,g.jsx)(`span`,{children:k.title}),(0,g.jsx)(`small`,{children:k.detail})]})]})}),(0,g.jsxs)(`section`,{className:`control-deck`,children:[(0,g.jsxs)(`div`,{className:`bet-panel`,children:[(0,g.jsxs)(`div`,{className:`panel-heading`,children:[(0,g.jsx)(`span`,{children:`本局下注`}),(0,g.jsxs)(`strong`,{children:[`¥`,c.toLocaleString()]})]}),(0,g.jsx)(`div`,{className:`chips`,children:y.map(e=>(0,g.jsxs)(`button`,{onClick:()=>u(e),className:`chip chip-${e} ${c===e?`selected`:``}`,disabled:O||T===`player`||T===`dealer`,children:[(0,g.jsx)(`span`,{children:`¥`}),e]},e))})]}),(0,g.jsx)(`div`,{className:`actions`,children:T===`betting`||T===`settled`?(0,g.jsxs)(`button`,{className:`deal-button`,onClick:()=>void me(),disabled:O,children:[`发牌 `,(0,g.jsx)(`span`,{children:`DEAL`})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`button`,{onClick:()=>void he(),disabled:O||T!==`player`,children:[`要牌`,(0,g.jsx)(`span`,{children:`HIT`})]}),(0,g.jsxs)(`button`,{onClick:()=>void ge(),disabled:O||T!==`player`,children:[`停牌`,(0,g.jsx)(`span`,{children:`STAND`})]}),(0,g.jsxs)(`button`,{onClick:()=>void _e(),disabled:O||T!==`player`||!U||U.cards.length!==2,children:[`加倍`,(0,g.jsx)(`span`,{children:`DOUBLE`})]}),(0,g.jsxs)(`button`,{onClick:()=>void ve(),disabled:O||!se,children:[`分牌`,(0,g.jsx)(`span`,{children:`SPLIT`})]})]})}),(0,g.jsxs)(`div`,{className:`ledger`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{children:`累计输赢`}),(0,g.jsxs)(`strong`,{className:d>=0?`positive`:`negative`,children:[d>=0?`+`:`-`,`¥`,Math.abs(d).toLocaleString()]})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{children:`已完成`}),(0,g.jsxs)(`b`,{children:[p,` 局`]})]}),(0,g.jsx)(`button`,{onClick:()=>{f(0),_(0)},disabled:O,children:`清零记录`})]})]}),(0,g.jsxs)(`aside`,{className:`coach-card`,"aria-live":`polite`,children:[(0,g.jsxs)(`div`,{className:`coach-top`,children:[(0,g.jsx)(ee,{size:17}),(0,g.jsx)(`span`,{children:`算牌助手 · HI-LO`}),(0,g.jsx)(`span`,{className:`live-dot`,children:`实时`})]}),(0,g.jsxs)(`div`,{className:`counts`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`small`,{children:`RUNNING COUNT`}),(0,g.jsxs)(`strong`,{children:[v>=0?`+`:``,v]})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`small`,{children:`TRUE COUNT`}),(0,g.jsxs)(`strong`,{children:[q>=0?`+`:``,q.toFixed(1)]})]})]}),(0,g.jsx)(`div`,{className:`deck-meter`,children:(0,g.jsx)(`span`,{style:{width:`${Math.min(100,e.length/312*100)}%`}})}),(0,g.jsxs)(`p`,{children:[`剩余约 `,K.toFixed(1),` 副牌`]}),(0,g.jsxs)(`div`,{className:`recommendation`,children:[(0,g.jsx)(`span`,{children:`建议动作`}),(0,g.jsx)(`strong`,{children:be})]})]}),(0,g.jsxs)(`div`,{className:`money-badge`,children:[(0,g.jsx)(m,{size:17}),`记录保存在本机`]})]})}export{w as default};