PageSourceSearch

https://chat1.ek21.com/assets/ScatterCherryGame-Df4LQOGM.js

js ek21.com collected 2026-10-02 11:28:14 UTC 5,549 bytes, 1 lines download raw bytes

1import{r as s,c as re,R as B,j as r,b as w}from"./index-BmUWOtyf.js";/* empty css                       */let te=0;function ae({socket:a,token:u,name:m,setApples:S}){const[N,d]=s.useState("idle"),[L,E]=s.useState(30),[q,P]=s.useState([]),[F,M]=s.useState(()=>new Set),[K,R]=s.useState([]),[I,O]=s.useState(1),[b,X]=s.useState(0),[_,D]=s.useState(0),[Y,A]=s.useState(0),[H,J]=s.useState(0),[Q,W]=s.useState(0),[z,T]=s.useState(null),k=s.useRef(u),x=s.useRef(null),h=s.useRef(null),o=s.useRef(new Map);s.useEffect(()=>{k.current=u},[u]);const G=s.useCallback(async()=>{if(!(!u||typeof S!="function"))try{const e=await fetch("".concat(re,"/auth/me?room=").concat(B),{headers:{Authorization:"Bearer ".concat(u)}});if(!e.ok)return;const t=await e.json();typeof t.gold_apples=="number"&&(S(t.gold_apples),sessionStorage.setItem("apples",t.gold_apples))}catch(e){}},[u,S]),$=s.useCallback((e,t,c,j)=>{const p=++te;R(f=>[...f,{id:p,x:e,y:t,text:c,kind:j}]),setTimeout(()=>R(f=>f.filter(C=>C.id!==p)),900)},[]),g=s.useCallback(e=>{M(t=>{if(t.has(e))return t;const c=new Set(t);return c.add(e),c})},[]);s.useEffect(()=>{const e=({secondsLeft:n})=>{let l=n||30;E(l),clearInterval(h.current),h.current=setInterval(()=>{l-=1,E(l),l<=0&&clearInterval(h.current)},1e3),d("warn")},t=({duration:n,cherries:l,reward:i,maxPerUser:y,total:ee})=>{clearInterval(h.current),o.current.clear(),P(l||[]),M(new Set),R([]),O(i||1),X(y||0),J(ee||(l||[]).length),D(0),A(0),T(null),d("playing"),clearInterval(x.current);let v=n;W(v),x.current=setInterval(()=>{v-=1,W(Math.max(0,v)),v<=0&&clearInterval(x.current)},1e3)},c=({id:n,name:l})=>{A(i=>i+1),g(n),l!==m&&o.current.delete(n)},j=({id:n,count:l})=>{D(l);const i=o.current.get(n);o.current.delete(n),i&&$(i.x,i.y,"+".concat(I),"ok")},p=({id:n,by:l,reason:i})=>{const y=o.current.get(n);o.current.delete(n),y&&$(y.x,y.y,i==="limit"?"已達上限":l?"被 ".concat(l," 搶走"):"沒搶到","miss")},f=()=>{clearInterval(x.current),d(n=>n==="playing"||n==="warn"?"result":n)},C=({catches:n})=>{T(n||{}),d(l=>l==="idle"?l:"result"),((n==null?void 0:n[m])||0)>0&&setTimeout(()=>{G()},300)};return a.on("scatterCherryWarn",e),a.on("scatterCherryStart",t),a.on("scatterCherryTaken",c),a.on("scatterCherryAck",j),a.on("scatterCherryMiss",p),a.on("scatterCherryEnd",f),a.on("scatterCherryResult",C),()=>{a.off("scatterCherryWarn",e),a.off("scatterCherryStart",t),a.off("scatterCherryTaken",c),a.off("scatterCherryAck",j),a.off("scatterCherryMiss",p),a.off("scatterCherryEnd",f),a.off("scatterCherryResult",C)}},[a,m,I,$,g,G]),s.useEffect(()=>()=>{clearInterval(x.current),clearInterval(h.current)},[]);const V=s.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),!o.current.has(t)&&(o.current.set(t,{x:e.clientX,y:e.clientY}),g(t),a.emit("scatterCherryClick",{token:k.current,room:B,id:t}))},[a,g]),U=()=>{d("idle"),clearInterval(h.current)},Z=()=>{d("idle"),T(null),P([])};if(N==="idle")return null;if(N==="warn")return r.jsx("div",{className:"ctg-warn-overlay",onClick:U,children:r.jsxs("div",{className:"ctg-warn-card",onClick:e=>e.stopPropagation(),children:[r.jsx("div",{className:"ctg-warn-countdown",children:L}),r.jsx("div",{className:"ctg-warn-unit",children:"秒後開始"}),r.jsx("h2",{className:"ctg-warn-title",children:"🍒 撒櫻桃"}),r.jsxs("ul",{className:"ctg-warn-rules",children:[r.jsxs("li",{children:["☁️ 天空會",r.jsx("strong",{children:"撒下一大把櫻桃"})]}),r.jsxs("li",{children:["🖱️ 必須用",r.jsx("strong",{children:"滑鼠點"}),"(手機用手指點)才撿得到"]}),r.jsxs("li",{children:["⚡ 全房間搶同一批,",r.jsx("strong",{children:"先點先得"})]}),r.jsxs("li",{children:["🏆 每撿到一顆獲得 ",w.currency_emoji," ",w.currency_name,"獎勵"]})]}),r.jsx("button",{className:"ctg-warn-close",onClick:U,children:"我知道了!"})]})});if(N==="result"){const e=Object.entries(z||{}).sort((t,c)=>c[1]-t[1]).slice(0,100);return r.jsx("div",{className:"ctg-overlay",onClick:Z,children:r.jsxs("div",{className:"ctg-result",onClick:t=>t.stopPropagation(),children:[r.jsx("h2",{children:"🍒 撒櫻桃結束!"}),z===null?r.jsxs("p",{children:["正在結算…(你撿到 ",_," 顆)"]}):e.length>0?r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"本次得獎名單(前百):"}),r.jsx("ul",{children:e.map(([t,c])=>r.jsxs("li",{className:t===m?"me":"",children:[t,":",c," 個",w.currency_name,t===m?" 🎉":""]},t))})]}):r.jsx("p",{children:"這次沒有人撿到櫻桃…"}),r.jsx("p",{className:"ctg-dismiss-hint",children:"點擊任意處關閉"})]})})}
1return r.jsxs("div",{className:"ctg-overlay scg-overlay",children:[r.jsxs("div",{className:"ctg-hud",children:[r.jsx("span",{className:"ctg-timer",children:Q}),r.jsx("span",{className:"ctg-timer-unit",children:"秒"}),r.jsxs("span",{className:"ctg-hint",children:["我撿到 ",_,b>0?" / ".concat(b):""," 顆"]}),r.jsxs("span",{className:"ctg-hint",children:["全場 ",Y," / ",H]}),r.jsxs("span",{className:"ctg-hint",children:["每顆 ",I," 個",w.currency_emoji]})]}),r.jsx("div",{className:"scg-cloud",children:"☁️🍒☁️"}),q.map(e=>F.has(e.id)?null:r.jsx("div",{className:"scg-cherry",style:{left:"".concat(e.x*100,"%"),fontSize:e.size,animationDuration:"".concat(e.fall,"ms"),animationDelay:"".concat(e.delay,"ms"),"--scg-drift":"".concat(e.size*7%60-30,"px")},onPointerDown:t=>V(t,e.id),onAnimationEnd:()=>g(e.id),children:"🍒"},e.id)),K.map(e=>r.jsx("div",{className:"scg-pop scg-pop-".concat(e.kind),style:{left:e.x,top:e.y},children:e.text},e.id))]})}export{ae as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.