From 79eda0da45d00d795c5e9640cd353d23d041efc4 Mon Sep 17 00:00:00 2001 From: Alireza Rezaei Date: Thu, 15 Oct 2026 11:17:29 +0330 Subject: [PATCH] vfx and animations vite build --- client/assets/index-BJNpcCwx.css | 1 + client/assets/index-BquRMbQ0.css | 1 - client/assets/index-Cj8AUTlf.js | 122 +++++++++++++++++++++++++++++++ client/assets/index-D5ThqQkE.js | 10 --- client/index.html | 4 +- 5 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 client/assets/index-BJNpcCwx.css delete mode 100644 client/assets/index-BquRMbQ0.css create mode 100644 client/assets/index-Cj8AUTlf.js delete mode 100644 client/assets/index-D5ThqQkE.js diff --git a/client/assets/index-BJNpcCwx.css b/client/assets/index-BJNpcCwx.css new file mode 100644 index 0000000..eaf8720 --- /dev/null +++ b/client/assets/index-BJNpcCwx.css @@ -0,0 +1 @@ +:root{--bg-primary: #14151b;--bg-card: #1e2029;--bg-card-hover: #282a36;--text-main: #f3f4f6;--text-muted: #9ca3af;--gold-accent: #f59e0b;--gold-light: #fbbf24;--danger: #ef4444;--board-light: #f0d9b5;--board-dark: #b58863;--board-border: #3b2818;--coord-light: #b58863;--coord-dark: #f0d9b5}*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%;background:radial-gradient(circle at center,#1b1c26,#101117);color:var(--text-main);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Vazirmatn,sans-serif;overflow:hidden;user-select:none;-webkit-user-select:none}#app{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:8px 12px;gap:8px}.player-bar{width:min(88vmin,540px);display:flex;align-items:center;justify-content:space-between;padding:6px 12px;background:#1e2029d9;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:8px;border:1px solid rgba(255,255,255,.08);box-shadow:0 4px 12px #0000004d;transition:border-color .25s ease,box-shadow .25s ease}.player-bar.active{border-color:var(--gold-accent);box-shadow:0 0 14px #f59e0b59}.player-profile{display:flex;align-items:center;gap:10px}.player-badge{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:16px;box-shadow:0 2px 4px #0003}.player-badge.w{background:#f8fafc;color:#1e293b;border:1px solid #cbd5e1}.player-badge.b{background:#1e2029;color:#f8fafc;border:1px solid #475569}.player-meta{display:flex;flex-direction:column;gap:2px}.player-name{font-size:14px;font-weight:700;display:flex;align-items:center;gap:6px}.bot-tag{font-size:10px;font-weight:800;padding:1px 5px;background:#334155;color:#94a3b8;border-radius:4px;letter-spacing:.5px}.bot-tag.you-tag{background:#1e3a8a;color:#60a5fa;border:1px solid rgba(96,165,250,.4)}.player-status{font-size:11px;color:var(--text-muted)}.captured-tray{display:flex;align-items:center;gap:2px;min-height:22px;flex-wrap:wrap}.captured-tray .mini-piece{width:18px;height:18px;opacity:.85}.advantage-score{font-size:11px;font-weight:800;color:var(--gold-accent);margin-inline-start:4px}.board-container{position:relative;width:min(88vmin,540px);aspect-ratio:1;border-radius:8px;box-shadow:0 12px 32px #0009,0 2px 6px #0006;padding:4px;background:var(--board-border);direction:ltr!important}.board-grid{display:grid;grid-template-columns:repeat(8,1fr);grid-template-rows:repeat(8,1fr);width:100%;height:100%;border-radius:6px;overflow:hidden;direction:ltr!important}.cell{position:relative;aspect-ratio:1;padding:0;margin:0;border:0;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;outline:none;transition:background-color .15s ease}.cell.light{background-color:var(--board-light)}.cell.dark{background-color:var(--board-dark)}.cell.selected{background-color:#baca44!important}.cell.last-move{background-color:#f59e0b6b!important}.cell.in-check{background:radial-gradient(circle at center,rgba(239,68,68,.95) 0%,rgba(220,38,38,.4) 60%,transparent 75%)!important;animation:king-check-pulse 1.2s ease-in-out infinite}@keyframes king-check-pulse{0%,to{filter:drop-shadow(0 0 4px rgba(239,68,68,.8))}50%{filter:drop-shadow(0 0 14px rgba(239,68,68,1))}}.coord-rank,.coord-file{position:absolute;font-size:10px;font-weight:800;pointer-events:none;opacity:.75;line-height:1}.coord-rank{top:3px;left:4px}.coord-file{bottom:3px;right:4px}.cell.light .coord-rank,.cell.light .coord-file{color:var(--coord-light)}.cell.dark .coord-rank,.cell.dark .coord-file{color:var(--coord-dark)}.piece-wrapper{width:90%;height:90%;display:flex;align-items:center;justify-content:center;pointer-events:none;transition:transform .2s cubic-bezier(.34,1.56,.64,1),filter .2s ease}.piece-svg{width:100%;height:100%;filter:drop-shadow(0 2px 3px rgba(0,0,0,.28));display:block}.cell:not(:disabled):hover .piece-wrapper{transform:translateY(-3px) scale(1.06);filter:drop-shadow(0 6px 8px rgba(0,0,0,.35))}.cell.selected .piece-wrapper{transform:translateY(-5px) scale(1.14);filter:drop-shadow(0 8px 14px rgba(0,0,0,.45));animation:piece-hover-breath 1.8s ease-in-out infinite alternate}@keyframes piece-hover-breath{0%{transform:translateY(-5px) scale(1.14)}to{transform:translateY(-7px) scale(1.18)}}.piece-wrapper.anim-land{animation:piece-land-squash .22s ease-out}@keyframes piece-land-squash{0%{transform:scale(1.12,.88)}50%{transform:scale(.96,1.04)}to{transform:scale(1)}}.piece-wrapper.anim-knight{animation:knight-arc-leap .28s cubic-bezier(.25,.46,.45,.94)}@keyframes knight-arc-leap{0%{transform:translateY(0) scale(1)}50%{transform:translateY(-16px) scale(1.22)}85%{transform:translateY(0) scale(1.08,.92)}to{transform:translateY(0) scale(1)}}.move-dot{position:absolute;width:32%;height:32%;border-radius:50%;background:#0000003d;pointer-events:none;animation:dot-spawn .18s cubic-bezier(.34,1.56,.64,1);transition:transform .15s ease,background-color .15s ease}.cell:hover .move-dot{transform:scale(1.3);background:#0000005c}@keyframes dot-spawn{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}.capture-ring{position:absolute;top:0;right:0;bottom:0;left:0;border:4px solid rgba(239,68,68,.72);border-radius:50%;pointer-events:none;animation:ring-spawn .2s cubic-bezier(.34,1.56,.64,1)}@keyframes ring-spawn{0%{transform:scale(.5);opacity:0}to{transform:scale(1);opacity:1}}#vfx-canvas{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:10}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000a6;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:50;animation:fade-in .2s ease}.promo-card{background:var(--bg-card);border:1px solid rgba(255,255,255,.12);border-radius:12px;padding:16px 20px;display:flex;flex-direction:column;align-items:center;gap:14px;box-shadow:0 16px 36px #000000b3;animation:modal-spring .26s cubic-bezier(.34,1.56,.64,1)}.promo-title{font-size:15px;font-weight:700;color:var(--text-main)}.promo-options{display:flex;gap:10px}.promo-piece-btn{width:58px;height:58px;background:#2a2c38;border:1px solid rgba(255,255,255,.1);border-radius:10px;cursor:pointer;padding:6px;display:flex;align-items:center;justify-content:center;transition:transform .18s cubic-bezier(.34,1.56,.64,1),background-color .15s ease,box-shadow .18s ease}.promo-piece-btn:hover{transform:translateY(-4px) scale(1.12);background:#373a4a;box-shadow:0 8px 18px #0006}.promo-cancel-btn{background:transparent;border:0;color:var(--text-muted);font-size:13px;font-weight:600;cursor:pointer;padding:4px 12px;transition:color .15s ease}.promo-cancel-btn:hover{color:var(--text-main)}@keyframes modal-spring{0%{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.game-over-banner{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#181922f0;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:2px solid var(--gold-accent);border-radius:14px;padding:16px 28px;display:flex;flex-direction:column;align-items:center;gap:8px;box-shadow:0 16px 40px #000c,0 0 24px #f59e0b66;z-index:40;animation:banner-spring .35s cubic-bezier(.34,1.56,.64,1);text-align:center}.game-over-title{font-size:22px;font-weight:800;color:var(--gold-light);display:flex;align-items:center;gap:8px}.game-over-subtitle{font-size:14px;color:var(--text-muted);font-weight:600}@keyframes banner-spring{0%{transform:translate(-50%,-50%) scale(.4);opacity:0}to{transform:translate(-50%,-50%) scale(1);opacity:1}} diff --git a/client/assets/index-BquRMbQ0.css b/client/assets/index-BquRMbQ0.css deleted file mode 100644 index 91cd1eb..0000000 --- a/client/assets/index-BquRMbQ0.css +++ /dev/null @@ -1 +0,0 @@ -html,body{margin:0;height:100%;background:#1a1a2e;color:#f1f3f5;font-family:system-ui,sans-serif}#app{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:16px}.status{font-size:22px;font-weight:700}.info{font-size:14px;opacity:.8}.board{display:grid;grid-template-columns:repeat(8,min(10vmin,60px));grid-template-rows:repeat(8,min(10vmin,60px));gap:1px;border:3px solid #c5a065;border-radius:4px;overflow:hidden}.cell{aspect-ratio:1;font-size:min(6vmin,36px);font-weight:800;border:0;border-radius:0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center}.cell.light{background:#d18b47}.cell.dark{background:#8b5e3c}.cell:disabled{cursor:default;opacity:.85}.cell.selected{outline:3px solid #ffd43b;outline-offset:-3px}.hint{font-size:14px;font-weight:600;color:#ffd43b}.promo{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:700;background:#2b2b45;border-radius:10px;padding:8px 12px}.promo-btn{font-size:30px;line-height:1;border:0;border-radius:8px;background:#d18b47;color:#1a1a2e;cursor:pointer;padding:4px 10px}.promo-cancel{font-size:13px;border:0;border-radius:8px;background:transparent;color:#f1f3f5;cursor:pointer;padding:6px 8px}.cell[data-color=w]{color:#f0f0f0;text-shadow:1px 1px 2px #333}.cell[data-color=b]{color:#222;text-shadow:1px 1px 2px #ddd}.legend{font-size:12px;opacity:.7} diff --git a/client/assets/index-Cj8AUTlf.js b/client/assets/index-Cj8AUTlf.js new file mode 100644 index 0000000..d2c7dfd --- /dev/null +++ b/client/assets/index-Cj8AUTlf.js @@ -0,0 +1,122 @@ +(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))t(o);new MutationObserver(o=>{for(const e of o)if(e.type==="childList")for(const a of e.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&t(a)}).observe(document,{childList:!0,subtree:!0});function r(o){const e={};return o.integrity&&(e.integrity=o.integrity),o.referrerPolicy&&(e.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?e.credentials="include":o.crossOrigin==="anonymous"?e.credentials="omit":e.credentials="same-origin",e}function t(o){if(o.ep)return;o.ep=!0;const e=r(o);fetch(o.href,e)}})();function Z(n){const s=new URLSearchParams(location.search).get("host")??"*",r=o=>window.parent.postMessage({m3:1,...o},s);let t=0;return window.addEventListener("message",o=>{var a,f,h;if(o.source!==window.parent||s!=="*"&&o.origin!==s)return;const e=o.data;if(!(!e||e.m3!==1))switch(e.type){case"init":n.onInit(e),r({type:"ready"});break;case"state":n.onState(e.env);break;case"ack":(a=n.onAck)==null||a.call(n,e);break;case"view_changed":(f=n.onViewChanged)==null||f.call(n,e.view);break;case"cmd_failed":(h=n.onCmdFailed)==null||h.call(n,e.req_id,e.code);break}}),r({type:"loaded"}),{cmd(o,e={}){const a=++t;return r({type:"cmd",cmd_type:o,payload:e,req_id:a}),a},toast(o,e,a="info"){r({type:"toast",text_fa:o,text_en:e,kind:a})}}}const tt={k:{w:` + + + + + + + `,b:` + + + + + + + `},q:{w:` + + + + + + + + `,b:` + + + + + + + + `},r:{w:` + + + + + + + `,b:` + + + + + + + `},b:{w:` + + + + + + + + + `,b:` + + + + + + + + + `},n:{w:` + + + + + + + `,b:` + + + + + + + `},p:{w:` + + `,b:` + + `}};function S(n,s){var r;return!n||!s?"":((r=tt[n])==null?void 0:r[s])??""}class et{constructor(s){this.particles=[],this.shockwaves=[],this.animId=null,this.lastTime=0,this.canvas=s,this.ctx=s.getContext("2d"),this.resize(),window.addEventListener("resize",()=>this.resize()),this.startLoop()}resize(){var t,o,e;const s=(t=this.canvas.parentElement)==null?void 0:t.getBoundingClientRect();if(!s)return;const r=window.devicePixelRatio||1;this.canvas.width=Math.round(s.width*r),this.canvas.height=Math.round(s.height*r),this.canvas.style.width=`${s.width}px`,this.canvas.style.height=`${s.height}px`,(e=(o=this.ctx).resetTransform)==null||e.call(o),this.ctx.scale(r,r)}startLoop(){if(this.animId)return;const s=r=>{const t=this.lastTime?Math.min((r-this.lastTime)/1e3,.1):.016;this.lastTime=r,this.update(t),this.render(),this.animId=requestAnimationFrame(s)};this.animId=requestAnimationFrame(s)}update(s){for(let r=this.shockwaves.length-1;r>=0;r--){const t=this.shockwaves[r];t.radius+=(t.maxRadius-t.radius)*12*s,t.alpha-=t.decay*s,(t.alpha<=0||t.radius>=t.maxRadius*.98)&&this.shockwaves.splice(r,1)}for(let r=this.particles.length-1;r>=0;r--){const t=this.particles[r];t.x+=t.vx*s,t.y+=t.vy*s,t.vx*=Math.pow(t.drag,s*60),t.vy*=Math.pow(t.drag,s*60),t.vy+=t.gravity*s,t.vRot&&t.rotation!==void 0&&(t.rotation+=t.vRot*s),t.alpha-=t.decay*s,t.alpha<=0&&this.particles.splice(r,1)}}render(){const s=this.canvas.width/(window.devicePixelRatio||1),r=this.canvas.height/(window.devicePixelRatio||1);this.ctx.clearRect(0,0,s,r);for(const t of this.shockwaves)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(1,t.radius),0,Math.PI*2),this.ctx.strokeStyle=t.color,this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.lineWidth=t.lineWidth,this.ctx.stroke(),this.ctx.restore();for(const t of this.particles){if(this.ctx.save(),this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.fillStyle=t.color,t.shape==="rect"||t.shape==="spark"){this.ctx.translate(t.x,t.y),t.rotation!==void 0&&this.ctx.rotate(t.rotation);const o=t.size||t.radius*2;t.shape==="spark"?this.ctx.fillRect(-o,-o*.25,o*2,o*.5):this.ctx.fillRect(-o*.5,-o*.5,o,o)}else this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(.5,t.radius),0,Math.PI*2),this.ctx.fill();this.ctx.restore()}}captureImpact(s,r,t="w"){this.shockwaves.push({x:s,y:r,radius:4,maxRadius:48,color:t==="w"?"rgba(255, 235, 180, 0.9)":"rgba(120, 140, 180, 0.9)",alpha:.9,decay:2.8,lineWidth:3});const o=t==="w"?["#ffffff","#fef08a","#f59e0b","#fbbf24"]:["#94a3b8","#cbd5e1","#64748b","#38bdf8"],e=18;for(let a=0;a{if(i<0||i>7||p<0||p>7)return!1;const g=w(i,p),c=t.get(g);return!c||!c.color?(f.push({target:g,isCapture:!1}),!0):(c.color!==r&&f.push({target:g,isCapture:!0}),!1)};switch(o.type){case"p":{const i=r==="w"?1:-1,p=r==="w"?1:6,g=w(e,a+i),c=t.get(g);if(c&&!c.color&&(f.push({target:g,isCapture:!1}),a===p)){const d=w(e,a+i*2),u=t.get(d);u&&!u.color&&f.push({target:d,isCapture:!1})}for(const d of[-1,1])if(e+d>=0&&e+d<=7){const u=w(e+d,a+i),v=t.get(u);v&&v.color&&v.color!==r&&f.push({target:u,isCapture:!0})}break}case"n":{const i=[[-2,-1],[-2,1],[-1,-2],[-1,2],[1,-2],[1,2],[2,-1],[2,1]];for(const[p,g]of i){const c=e+p,d=a+g;if(c>=0&&c<=7&&d>=0&&d<=7){const u=w(c,d),v=t.get(u);!v||!v.color?f.push({target:u,isCapture:!1}):v.color!==r&&f.push({target:u,isCapture:!0})}}break}case"b":{const i=[[-1,-1],[-1,1],[1,-1],[1,1]];for(const[p,g]of i){let c=e+p,d=a+g;for(;h(c,d);)c+=p,d+=g}break}case"r":{const i=[[-1,0],[1,0],[0,-1],[0,1]];for(const[p,g]of i){let c=e+p,d=a+g;for(;h(c,d);)c+=p,d+=g}break}case"q":{const i=[[-1,-1],[-1,1],[1,-1],[1,1],[-1,0],[1,0],[0,-1],[0,1]];for(const[p,g]of i){let c=e+p,d=a+g;for(;h(c,d);)c+=p,d+=g}break}case"k":{for(let p=-1;p<=1;p++)for(let g=-1;g<=1;g++){if(p===0&&g===0)continue;const c=e+p,d=a+g;if(c>=0&&c<=7&&d>=0&&d<=7){const u=w(c,d),v=t.get(u);!v||!v.color?f.push({target:u,isCapture:!1}):v.color!==r&&f.push({target:u,isCapture:!0})}}const i=r==="w"?0:7;if(a===i&&e===4){const p=t.get(w(5,i)),g=t.get(w(6,i)),c=t.get(w(7,i));p&&!p.color&&g&&!g.color&&(c==null?void 0:c.type)==="r"&&c.color===r&&f.push({target:w(6,i),isCapture:!1});const d=t.get(w(3,i)),u=t.get(w(2,i)),v=t.get(w(1,i)),m=t.get(w(0,i));d&&!d.color&&u&&!u.color&&v&&!v.color&&(m==null?void 0:m.type)==="r"&&m.color===r&&f.push({target:w(2,i),isCapture:!1})}break}}return f.filter(i=>!ot(n,i.target,s,r))}function ot(n,s,r,t){const o=r.map(c=>{if(c.square===n)return{square:n,type:null,color:null};if(c.square===s){const d=r.find(u=>u.square===n);return{square:s,type:(d==null?void 0:d.type)??null,color:t}}return{...c}}),e=o.find(c=>c.type==="k"&&c.color===t);if(!e)return!1;const{f:a,r:f}=_(e.square),h=t==="w"?"b":"w",i=new Map;for(const c of o)i.set(c.square,c);const p=[[-2,-1],[-2,1],[-1,-2],[-1,2],[1,-2],[1,2],[2,-1],[2,1]];for(const[c,d]of p){const u=a+c,v=f+d;if(u>=0&&u<=7&&v>=0&&v<=7){const m=i.get(w(u,v));if(m&&m.color===h&&m.type==="n")return!0}}const g=h==="w"?1:-1;for(const c of[-1,1]){const d=a-c,u=f-g;if(d>=0&&d<=7&&u>=0&&u<=7){const v=i.get(w(d,u));if(v&&v.color===h&&v.type==="p")return!0}}for(const[c,d]of[[-1,0],[1,0],[0,-1],[0,1]]){let u=a+c,v=f+d;for(;u>=0&&u<=7&&v>=0&&v<=7;){const m=i.get(w(u,v));if(m&&m.color){if(m.color===h&&(m.type==="r"||m.type==="q"))return!0;break}u+=c,v+=d}}for(const[c,d]of[[-1,-1],[-1,1],[1,-1],[1,1]]){let u=a+c,v=f+d;for(;u>=0&&u<=7&&v>=0&&v<=7;){const m=i.get(w(u,v));if(m&&m.color){if(m.color===h&&(m.type==="b"||m.type==="q"))return!0;break}u+=c,v+=d}}for(let c=-1;c<=1;c++)for(let d=-1;d<=1;d++){if(c===0&&d===0)continue;const u=a+c,v=f+d;if(u>=0&&u<=7&&v>=0&&v<=7){const m=i.get(w(u,v));if(m&&m.color===h&&m.type==="k")return!0}}return!1}let l=null,H=null,E=null,C=null,k="",y=[],x=null,R=null,V=!1;const b=(n,s)=>(E==null?void 0:E.locale)==="en"?s:n,T=Z({onInit(n){E=n,document.documentElement.lang=n.locale,document.documentElement.dir=n.dir,document.getElementById("board-grid")||O(),z()},onState(n){n.t==="snap"&&(document.getElementById("board-grid")||O(),H=l,l=n.body,st(H,l),l.turn!==l.me&&(k="",y=[],x=null),z())},onAck(n){n.status==="rejected"&&T.toast("حرکت پذیرفته نشد","Move not accepted","warn")}});function st(n,s){var f;if(!n||!s||!C)return;const r=new Map(n.board.map(h=>[h.square,h])),t=new Map(s.board.map(h=>[h.square,h]));let o="",e="",a=null;for(const[h,i]of t.entries()){const p=r.get(h);p&&(p.color&&!i.color?o=h:i.color&&(!p.color||p.color!==i.color||p.type!==i.type)&&(e=h,p.color&&p.color!==i.color&&(a=p)))}if(o&&e){R={from:o,to:e};const h=document.querySelector(`[data-square="${e}"]`);if(h){const i=h.getBoundingClientRect(),p=(f=document.getElementById("vfx-canvas"))==null?void 0:f.getBoundingClientRect();if(p){const c=i.left-p.left+i.width/2,d=i.top-p.top+i.height/2;a?C.captureImpact(c,d,a.color):C.landingPuff(c,d)}const g=h.querySelector(".piece-wrapper");g&&(g.classList.remove("anim-land"),g.offsetWidth,g.classList.add("anim-land"))}}s.phase==="over"&&s.winner!==null&&!V&&(V=!0,setTimeout(()=>C==null?void 0:C.victoryConfetti(),350))}function O(){const n=document.getElementById("app");n.innerHTML=` +
+
+ +
+
+
+ + `;const s=document.getElementById("vfx-canvas");C=new et(s);const r=document.getElementById("board-grid");r.addEventListener("click",t=>{const o=t.target.closest(".cell");o&&o.dataset.square&&!o.disabled&&it(o.dataset.square)});for(let t=0;t<64;t++){const o=document.createElement("button");o.className="cell",o.dataset.index=String(t),r.appendChild(o)}}function z(){var m;if(!l)return;const n=l.me,s=n!=null&&l.players[n]!==void 0;let r,t;s?(r=l.players[n],t=l.players.find(M=>M.seat!==n)||l.players[1-n]):(r=l.players.find(M=>M.color==="w")||l.players[0],t=l.players.find(M=>M.color==="b")||l.players[1]);const o=(r==null?void 0:r.color)||"w",e=o==="b",a=r?l.turn===r.seat&&l.phase==="play":!1,f=t?l.turn===t.seat&&l.phase==="play":!1;N("top-bar",t,f,!1),N("bottom-bar",r,a,s);const h=new Map;for(const M of l.board)h.set(M.square,M);const i=e?[7,6,5,4,3,2,1,0]:[0,1,2,3,4,5,6,7],p=e?[0,1,2,3,4,5,6,7]:[7,6,5,4,3,2,1,0],g=document.getElementById("board-grid");if(!g)return;const c=g.children;let d=0;const u=l.phase==="play"&&l.turn===n,v=l.check&&l.phase==="play"?(m=l.board.find(M=>{var q;return M.type==="k"&&M.color===((q=l.players[l.turn])==null?void 0:q.color)}))==null?void 0:m.square:null;for(const M of p)for(const q of i){const B=String.fromCharCode(97+q)+(M+1),I=h.get(B)||{type:null,color:null},$=c[d++];$.dataset.square=B,$.dataset.color=I.color||"";const F=(q+M)%2===0?"dark":"light",j=k===B,W=R&&(R.from===B||R.to===B),D=v===B;$.className=`cell ${F}`+(j?" selected":"")+(W?" last-move":"")+(D?" in-check":"");const U=y.some(P=>P.target===B),K=y.some(P=>P.target===B&&P.isCapture);let L="";const Y=e?q===7:q===0,G=e?M===7:M===0;if(Y&&(L+=`${M+1}`),G&&(L+=`${String.fromCharCode(97+q)}`),I.type&&I.color){const P=S(I.type,I.color),X=I.type==="n"&&j?" anim-knight":"";L+=`
${P}
`}K?L+='
':U&&(L+='
'),$.innerHTML=L;const J=u&&!0&&I.color===o,Q=k?u:J;$.disabled=!Q}at()}function N(n,s,r,t){const o=document.getElementById(n);if(!o||!s||!l)return;o.className="player-bar"+(r?" active":"");const e=rt(s.color),a=nt(s.color),f=a>0?`+${a}`:"",h=s.bot?'BOT':"",i=t?`${b("شما","YOU")}`:"",p=l.phase==="over"?l.winner===s.seat?b("برنده 🏆","Winner 🏆"):"":r?t?b("نوبت شماست","Your turn"):b("در حال تفکر…","Thinking…"):"";o.innerHTML=` +
+
+ ${s.color==="w"?"♔":"♚"} +
+
+
${s.name} ${h} ${i}
+
${p}
+
+
+
+ ${e.map(g=>`
${S(g.type,g.color)}
`).join("")} + ${f} +
+ `}function rt(n){if(!l)return[];const s=n==="w"?"b":"w",r={p:8,n:2,b:2,r:2,q:1},t={p:0,n:0,b:0,r:0,q:0};for(const e of l.board)e.color===s&&e.type&&t[e.type]!==void 0&&t[e.type]++;const o=[];for(const e of["q","r","b","n","p"]){const a=r[e]-(t[e]||0);for(let f=0;f +
+
${b("ارتقای پیاده به:","Promote pawn to:")}
+
+ ${["q","r","b","n"].map(e=>` + + `).join("")} +
+ +
+ + `,n.querySelectorAll("[data-promo]").forEach(e=>{e.addEventListener("click",()=>{var f;const a=e.dataset.promo;if(x&&a){T.cmd("move",{from:x.from,to:x.to,promotion:a});const h=document.querySelector(`[data-square="${x.to}"]`);if(h){const i=h.getBoundingClientRect(),p=(f=document.getElementById("vfx-canvas"))==null?void 0:f.getBoundingClientRect();p&&(C==null||C.promotionBurst(i.left-p.left+i.width/2,i.top-p.top+i.height/2))}x=null,k="",y=[],z()}})}),(r=n.querySelector("[data-cancel-promo]"))==null||r.addEventListener("click",()=>{x=null,z()});return}if(l.phase==="over"){l.winner!==null&&(l.winner,l.me);const o=l.winner===null;let e="",a="";o?(e=l.result_reason==="stalemate"?b("پات — مساوی!","Stalemate — Draw!"):b("بازی مساوی شد","Draw!"),a=b("هیچ‌کدام از طرفین برنده نشد","No side achieved victory")):(e=`${(t=l.players[l.winner])==null?void 0:t.name} ${b("برنده شد! 🏆","Wins! 🏆")}`,a=l.result_reason==="checkmate"?b("با کیش و مات حریف","By checkmate"):l.result_reason==="abandoned"?b("به دلیل ترک حریف","By abandonment"):""),n.innerHTML=` +
+
${e}
+
${a}
+
+ `;return}n.innerHTML=""}}function it(n){var o;if(!l||l.phase!=="play"||x)return;const s=l.me;if(s==null||l.turn!==s)return;const r=(o=l.players[s])==null?void 0:o.color;if(!r)return;const t=l.board.find(e=>e.square===n);if(k){if(k===n){k="",y=[],z();return}if(t!=null&&t.color&&t.color===r){k=n;try{y=A(n,l.board,r)}catch{y=[]}z();return}const e=l.board.find(f=>f.square===k),a=r==="b"?"1":"8";if((e==null?void 0:e.type)==="p"&&n[1]===a){x={from:k,to:n},k="",y=[],z();return}T.cmd("move",{from:k,to:n}),k="",y=[],z()}else if(t&&t.color===r){k=n;try{y=A(n,l.board,r)}catch{y=[]}z()}} diff --git a/client/assets/index-D5ThqQkE.js b/client/assets/index-D5ThqQkE.js deleted file mode 100644 index c8a998f..0000000 --- a/client/assets/index-D5ThqQkE.js +++ /dev/null @@ -1,10 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))d(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const s of n.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&d(s)}).observe(document,{childList:!0,subtree:!0});function a(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function d(t){if(t.ep)return;t.ep=!0;const n=a(t);fetch(t.href,n)}})();function I(o){const r=new URLSearchParams(location.search).get("host")??"*",a=t=>window.parent.postMessage({m3:1,...t},r);let d=0;return window.addEventListener("message",t=>{var s,l,u;if(t.source!==window.parent||r!=="*"&&t.origin!==r)return;const n=t.data;if(!(!n||n.m3!==1))switch(n.type){case"init":o.onInit(n),a({type:"ready"});break;case"state":o.onState(n.env);break;case"ack":(s=o.onAck)==null||s.call(o,n);break;case"view_changed":(l=o.onViewChanged)==null||l.call(o,n.view);break;case"cmd_failed":(u=o.onCmdFailed)==null||u.call(o,n.req_id,n.code);break}}),a({type:"loaded"}),{cmd(t,n={}){const s=++d;return a({type:"cmd",cmd_type:t,payload:n,req_id:s}),s},toast(t,n,s="info"){a({type:"toast",text_fa:t,text_en:n,kind:s})}}}let e=null,w=null;const i=(o,r)=>(w==null?void 0:w.locale)==="en"?r:o,k=I({onInit(o){w=o,document.documentElement.lang=o.locale,document.documentElement.dir=o.dir,p()},onState(o){o.t==="snap"&&(e=o.body,e.turn!==e.me&&(c="",m=null),p())},onAck(o){o.status==="rejected"&&k.toast("حرکت پذیرفته نشد","Move not accepted","warn")}});function p(){var q,h,C,L;const o=document.getElementById("app");if(!e){o.innerHTML=`
${i("در حال بارگذاری…","Loading…")}
`;return}const r=e.me,a=r!=null?(q=e.players[r])==null?void 0:q.color:null,d=a==="b",t={};for(const f of e.board)t[f.square]=f;const n=d?[7,6,5,4,3,2,1,0]:[0,1,2,3,4,5,6,7],s=d?[0,1,2,3,4,5,6,7]:[7,6,5,4,3,2,1,0],l=e.phase==="play"&&e.turn===r,u=s.map(f=>n.map(_=>{const g=String.fromCharCode(97+_)+(f+1),y=t[g]||{type:null,color:null},P=y.color?`${M(y.type,y.color)}`:"",O=l&&!!a&&y.color===a,E=c===g,H=c?l:O;return``}).join("")).join(""),b=c?`
${i("مبدا","From")}: ${c} — ${i("یک خانه مقصد را بزنید (برای لغو، دوباره همان خانه)","click a target square (click it again to cancel)")}
`:"",$=m?`
${m.from} → ${m.to}: ${i("ارتقا به","Promote to")} - ${["q","r","b","n"].map(f=>``).join("")} -
`:"",v=e.phase==="over"?e.result_reason==="abandoned"?i("بازی رها شد","Abandoned"):e.winner===null?e.result_reason==="stalemate"?i("پات — مساوی!","Stalemate — draw!"):i("مساوی!","Draw!"):e.result_reason==="checkmate"?`${(h=e.players[e.winner])==null?void 0:h.name} ${i("مات کرد! 🏆","wins by checkmate 🏆")}`:`${(C=e.players[e.winner])==null?void 0:C.name} ${i("برنده شد 🏆","wins 🏆")}`:(e.turn===r?i("نوبت شماست","Your turn"):`${i("نوبت","Turn")}: ${(L=e.players[e.turn])==null?void 0:L.name}`)+(e.check?` · ${i("کیش!","Check!")}`:"");o.innerHTML=` -
${v}
-
${e.moves_played!==void 0?`حرکت‌ها: ${e.moves_played}`:""}
-
${u}
- ${b} - ${$} -
${i("سفید حرکت می‌کند","White moves")}
- `}function M(o,r){return o?r==="b"?{k:"♚",q:"♛",r:"♜",b:"♝",n:"♞",p:"♟"}[o]??"":{k:"♔",q:"♕",r:"♖",b:"♗",n:"♘",p:"♙"}[o]??"":""}let c="",m=null;document.addEventListener("click",o=>{var n,s;const r=o.target,a=r.closest("[data-promo]");if(a&&m){k.cmd("move",{from:m.from,to:m.to,promotion:a.dataset.promo}),m=null,c="",p();return}if(r.closest("[data-cancel-promo]")){m=null,p();return}const d=r.closest("[data-from]");if(!d)return;const t=d.dataset.from;if(!m)if(c){if(c===t){c="",p();return}const l=((e==null?void 0:e.board)||[]).find(v=>v.square===t),u=(e==null?void 0:e.me)!==null&&(e==null?void 0:e.me)!==void 0?(n=e==null?void 0:e.players[e.me])==null?void 0:n.color:null;if(l!=null&&l.color&&u&&l.color===u){c=t,p();return}const b=((e==null?void 0:e.board)||[]).find(v=>v.square===c),$=u==="b"?"1":"8";if((b==null?void 0:b.type)==="p"&&t[1]===$){m={from:c,to:t},c="",p();return}k.cmd("move",{from:c,to:t}),c="",p()}else{const l=((e==null?void 0:e.board)||[]).find($=>$.square===t),u=(e==null?void 0:e.me)!==null&&(e==null?void 0:e.me)!==void 0?(s=e==null?void 0:e.players[e.me])==null?void 0:s.color:null;!!u&&(l==null?void 0:l.color)===u&&(e==null?void 0:e.phase)==="play"&&(e==null?void 0:e.turn)===(e==null?void 0:e.me)&&(c=t,p())}});p(); diff --git a/client/index.html b/client/index.html index 3942e47..b83f4b2 100644 --- a/client/index.html +++ b/client/index.html @@ -4,8 +4,8 @@ Chess — 3miz - - + +
…