@vue-skuilder/courseware 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chess-BVYo88i5.cjs +1 -0
- package/dist/{chess-BsgVZARV.cjs → chess-BWes0jGA.cjs} +2 -2
- package/dist/{chess-BsgVZARV.cjs.map → chess-BWes0jGA.cjs.map} +1 -1
- package/dist/{chess-BbHATAzk.js → chess-E2uOAyQS.js} +10 -8
- package/dist/{chess-BbHATAzk.js.map → chess-E2uOAyQS.js.map} +1 -1
- package/dist/{chess-X1bmWmh3.js → chess-Lfm7Fsvs.js} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +5 -5
- package/dist/chess-C_2RQEuq.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./CourseWare-DSeyTAtH.cjs`);const e=require(`./chess-BWes0jGA.cjs`);exports.default=e.t;
|
|
@@ -3,5 +3,5 @@ require('./assets/chess.css');const e=require(`./shapes-C_-mvrCc.cjs`),t=require
|
|
|
3
3
|
`}={}){function mask(e){return e.replace(/\\/g,`\\`)}function parsePgnHeader(e){let t={},r=e.split(new RegExp(mask(n))),i=``,a=``;for(let e=0;e<r.length;e++){let n=/^\s*\[\s*([A-Za-z]+)\s*"(.*)"\s*\]\s*$/;i=r[e].replace(n,`$1`),a=r[e].replace(n,`$2`),i.trim().length>0&&(t[i]=a)}return t}e=e.trim();let r=RegExp(`^(\\[((?:`+mask(n)+`)|.)*\\])((?:\\s*`+mask(n)+`){2}|(?:\\s*`+mask(n)+`)*$)`).exec(e),i=r&&r.length>=2?r[1]:``;this.reset();let a=parsePgnHeader(i),o=``;for(let e in a)e.toLowerCase()===`fen`&&(o=a[e]),this.header(e,a[e]);if(!t)o&&this.load(o,{preserveHeaders:!0});else if(a.SetUp===`1`){if(!(`FEN`in a))throw Error(`Invalid PGN: FEN tag must be supplied with SetUp tag`);this.load(a.FEN,{preserveHeaders:!0})}function toHex(e){return Array.from(e).map(function(e){return e.charCodeAt(0)<128?e.charCodeAt(0).toString(16):encodeURIComponent(e).replace(/%/g,``).toLowerCase()}).join(``)}function fromHex(e){return e.length==0?``:decodeURIComponent(`%`+(e.match(/.{1,2}/g)||[]).join(`%`))}let encodeComment=function(e){return e=e.replace(new RegExp(mask(n),`g`),` `),`{${toHex(e.slice(1,e.length-1))}}`},decodeComment=function(e){if(e.startsWith(`{`)&&e.endsWith(`}`))return fromHex(e.slice(1,e.length-1))},s=e.replace(i,``).replace(RegExp(`({[^}]*})+?|;([^${mask(n)}]*)`,`g`),function(e,t,n){return t===void 0?` `+encodeComment(`{${n.slice(1)}}`):encodeComment(t)}).replace(new RegExp(mask(n),`g`),` `),c=/(\([^()]+\))+?/g;for(;c.test(s);)s=s.replace(c,``);s=s.replace(/\d+\.(\.\.)?/g,``),s=s.replace(/\.\.\./g,``),s=s.replace(/\$\d+/g,``);let l=s.trim().split(new RegExp(/\s+/));l=l.filter(e=>e!==``);let u=``;for(let e=0;e<l.length;e++){let n=decodeComment(l[e]);if(n!==void 0){this._comments[this.fen()]=n;continue}let r=this._moveFromSan(l[e],t);if(r==null)if(I.indexOf(l[e])>-1)u=l[e];else throw Error(`Invalid move in PGN: ${l[e]}`);else u=``,this._makeMove(r),this._incPositionCount(this.fen())}u&&Object.keys(this._header).length&&!this._header.Result&&this.header(`Result`,u)}_moveToSan(e,t){let n=``;if(e.flags&b.KSIDE_CASTLE)n=`O-O`;else if(e.flags&b.QSIDE_CASTLE)n=`O-O-O`;else{if(e.piece!==`p`){let r=getDisambiguator(e,t);n+=e.piece.toUpperCase()+r}e.flags&(b.CAPTURE|b.EP_CAPTURE)&&(e.piece===`p`&&(n+=algebraic(e.from)[0]),n+=`x`),n+=algebraic(e.to),e.promotion&&(n+=`=`+e.promotion.toUpperCase())}return this._makeMove(e),this.isCheck()&&(this.isCheckmate()?n+=`#`:n+=`+`),this._undoMove(),n}_moveFromSan(e,t=!1){let n=strippedSan(e),r=inferPieceType(n),i=this._moves({legal:!0,piece:r});for(let e=0,t=i.length;e<t;e++)if(n===strippedSan(this._moveToSan(i[e],i)))return i[e];if(t)return null;let a,o,s,c,l,u=!1;if(o=n.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/),o?(a=o[1],s=o[2],c=o[3],l=o[4],s.length==1&&(u=!0)):(o=n.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/),o&&(a=o[1],s=o[2],c=o[3],l=o[4],s.length==1&&(u=!0))),r=inferPieceType(n),i=this._moves({legal:!0,piece:a||r}),!c)return null;for(let e=0,t=i.length;e<t;e++)if(!s){if(n===strippedSan(this._moveToSan(i[e],i)).replace(`x`,``))return i[e]}else if((!a||a.toLowerCase()==i[e].piece)&&x[s]==i[e].from&&x[c]==i[e].to&&(!l||l.toLowerCase()==i[e].promotion))return i[e];else if(u){let t=algebraic(i[e].from);if((!a||a.toLowerCase()==i[e].piece)&&x[c]==i[e].to&&(s==t[0]||s==t[1])&&(!l||l.toLowerCase()==i[e].promotion))return i[e]}return null}ascii(){let e=` +------------------------+
|
|
4
4
|
`;for(let t=x.a8;t<=x.h1;t++){if(file(t)===0&&(e+=` `+`87654321`[rank(t)]+` |`),this._board[t]){let n=this._board[t].type,r=this._board[t].color===`w`?n.toUpperCase():n.toLowerCase();e+=` `+r+` `}else e+=` . `;t+1&136&&(e+=`|
|
|
5
5
|
`,t+=8)}return e+=` +------------------------+
|
|
6
|
-
`,e+=` a b c d e f g h`,e}perft(e){let t=this._moves({legal:!1}),n=0,r=this._turn;for(let i=0,a=t.length;i<a;i++)this._makeMove(t[i]),this._isKingAttacked(r)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}turn(){return this._turn}board(){let e=[],t=[];for(let n=x.a8;n<=x.h1;n++)this._board[n]==null?t.push(null):t.push({square:algebraic(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in x){let t=x[e];return(rank(t)+file(t))%2==0?`light`:`dark`}return null}history({verbose:e=!1}={}){let t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){let r=t.pop();if(!r)break;e?n.push(new Move(this,r)):n.push(this._moveToSan(r,this._moves())),this._makeMove(r)}return n}_getPositionCount(e){let t=trimFen(e);return this._positionCount[t]||0}_incPositionCount(e){let t=trimFen(e);this._positionCount[t]===void 0&&(this._positionCount[t]=0),this._positionCount[t]+=1}_decPositionCount(e){let t=trimFen(e);this._positionCount[t]===1?delete this._positionCount[t]:--this._positionCount[t]}_pruneComments(){let e=[],t={},copyComment=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(copyComment(this.fen());;){let t=e.pop();if(!t)break;this._makeMove(t),copyComment(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace(`{`,`[`).replace(`}`,`]`)}deleteComment(){return this.removeComment()}removeComment(){let e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{let t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(let n of[`k`,`q`])t[n]!==void 0&&(t[n]?this._castling[e]|=N[n]:this._castling[e]&=~N[n]);this._updateCastlingRights();let n=this.getCastlingRights(e);return(t.k===void 0||t.k===n.k)&&(t.q===void 0||t.q===n.q)}getCastlingRights(e){return{k:(this._castling[e]&N.k)!==0,q:(this._castling[e]&N.q)!==0}}moveNumber(){return this._moveNumber}};function useChessgroundBounds(e,t){let r=null,i=(0,n.watch)(()=>t.value,t=>{!t||!e.value||(requestAnimationFrame(()=>t.redrawAll()),r=new ResizeObserver(()=>t.redrawAll()),r.observe(e.value),i())},{immediate:!0});(0,n.onUnmounted)(()=>{r?.disconnect(),r=null})}var parseUciMove=e=>{if(e.length<4||e.length>5)throw Error(`Invalid UCI move format: ${e}`);return{from:e.substring(0,2),to:e.substring(2,4),promotion:e.length===5?e[4]:void 0}},toDests=e=>{let t=new Map;return y.forEach(n=>{let r=e.moves({square:n,verbose:!0});r.length&&t.set(n,r.map(e=>e.to))}),t},swapColor=e=>e===`cg-white`?`cg-black`:`cg-white`,toColor=e=>e.turn()===`w`?`cg-white`:`cg-black`,L=(0,n.defineComponent)({name:`PuzzleView`,props:{data:{type:Array,required:!0},modifyDifficulty:{type:Number,required:!1,default:0}},setup(e,{emit:t}){let i=(0,r.useViewable)(e,t,`PuzzleView`),a=(0,r.useQuestionView)(i),o=(0,n.ref)(null),s=(0,n.ref)(),c=(0,n.ref)(),l=(0,n.ref)(`cg-white`),u=(0,n.ref)(!1),d=(0,n.ref)(null);useChessgroundBounds(o,c);let f=[{value:`q`,name:`Queen`,whiteSymbol:`♕`,blackSymbol:`♛`},{value:`r`,name:`Rook`,whiteSymbol:`♖`,blackSymbol:`♜`},{value:`b`,name:`Bishop`,whiteSymbol:`♗`,blackSymbol:`♝`},{value:`n`,name:`Knight`,whiteSymbol:`♘`,blackSymbol:`♞`}],p=(0,n.computed)(()=>{let e=[`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`];return l.value===`cg-white`?e:e.reverse()}),isPromotionPiece=e=>e?[`q`,`r`,`b`,`n`].includes(e):!1,isUnfinishedPromotion=(e,t,n)=>isPromotionPiece(n)?!1:s.value?.get(e)?.type===`p`&&(t[1]===`8`||t[1]===`1`),updateChessground=()=>{!s.value||!c.value||c.value.set({fen:s.value.fen(),turnColor:toColor(s.value),movable:{color:toColor(s.value),dests:toDests(s.value)}})},handlePromotion=e=>{if(e!==`q`&&e!==`r`&&e!==`b`&&e!==`n`){i.logger.error(`Invalid promotion piece: ${e}`);return}d.value&&(i.logger.log(`promoting to ${e}`),u.value=!1,checkMove(d.value.from,d.value.to,e))},checkMove=(e,t,n)=>{if(!a.question.value?.moves.length)throw Error(`No moves`);if(isUnfinishedPromotion(e,t,n)){d.value={from:e,to:t},u.value=!0;return}a.question.value.moves[0]===(isPromotionPiece(n)?`${e}${t}${n}`:`${e}${t}`)?(s.value?.move({from:e,to:t,promotion:isPromotionPiece(n)?n:void 0}),updateChessground(),a.question.value.moves.shift(),a.question.value.moves.length===0?a.submitAnswer(``):window.setTimeout(()=>{if(!a.question.value)return;let e=parseUciMove(a.question.value.moves.shift());s.value?.move(e),updateChessground()},300)):(s.value?.move({from:e,to:t,promotion:n}),s.value?.isCheckmate()?a.submitAnswer(J.CHECKMATE):s.value?.undo(),a.submitAnswer(e+t+n),updateChessground())};return(0,n.onMounted)(()=>{if(!o.value)return;a.question.value=new J(e.data),s.value=new Chess(a.question.value.fen),l.value=swapColor(toColor(s.value)),c.value=Chessground(o.value,{movable:{free:!1,showDests:!0,dests:toDests(s.value),events:{after:checkMove}},draggable:{showGhost:!0},fen:s.value.fen(),orientation:l.value,coordinates:!1,animation:{duration:300,enabled:!0}});let t=a.question.value.moves.shift();c.value.move(t.substring(0,2),t.substring(2)),s.value.move({from:t.substring(0,2),to:t.substring(2)}),updateChessground()}),(0,n.onUnmounted)(()=>{c.value?.destroy(),s.value=void 0}),{boardElement:o,playerColor:l,files:p,showPromotionDialog:u,promotionPieces:f,handlePromotion,...i,...a}}}),R={"data-viewable":`PuzzleView`},z={class:`text-h5`},B={class:`puzzle-board-wrapper`},V={class:`puzzle-ranks-labels`},H={class:`puzzle-board-and-files`},U={id:`cg`,ref:`boardElement`},W={class:`puzzle-files-labels`},G={key:0,class:`puzzle-promotion-dialog`},K=[`onClick`];function _sfc_render(e,t,r,i,a,o){return(0,n.openBlock)(),(0,n.createElementBlock)(`div`,R,[(0,n.createElementVNode)(`p`,z,` Make the best move for `+(0,n.toDisplayString)(e.playerColor===`cg-white`?`White ♖♘♗♕♔♗♘♖`:`Black ♜♞♝♚♛♝♞♜`)+`: `,1),(0,n.createElementVNode)(`div`,B,[(0,n.createElementVNode)(`div`,V,[((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(8,t=>(0,n.createElementVNode)(`div`,{key:t},(0,n.toDisplayString)(e.playerColor===`cg-white`?9-t:t),1)),64))]),(0,n.createElementVNode)(`div`,H,[(0,n.createElementVNode)(`div`,U,null,512),(0,n.createElementVNode)(`div`,W,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.files,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:e},(0,n.toDisplayString)(e),1))),128))])])]),e.showPromotionDialog?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,G,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.promotionPieces,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:t.value,onClick:n=>e.handlePromotion(t.value)},(0,n.toDisplayString)(e.playerColor===`cg-white`?t.whiteSymbol:t.blackSymbol)+` `+(0,n.toDisplayString)(t.name),9,K))),128))])):(0,n.createCommentVNode)(``,!0)])}var q=t.r(L,[[`render`,_sfc_render]]),J=class ChessPuzzle extends r.Question{static dataShapes=[{name:i.DataShapeName.CHESS_puzzle,fields:[{name:`puzzleData`,type:i.FieldType.CHESS_PUZZLE,validator:{instructions:`insert a valid fen string`,test:function(e){
|
|
7
|
-
//# sourceMappingURL=chess-
|
|
6
|
+
`,e+=` a b c d e f g h`,e}perft(e){let t=this._moves({legal:!1}),n=0,r=this._turn;for(let i=0,a=t.length;i<a;i++)this._makeMove(t[i]),this._isKingAttacked(r)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}turn(){return this._turn}board(){let e=[],t=[];for(let n=x.a8;n<=x.h1;n++)this._board[n]==null?t.push(null):t.push({square:algebraic(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in x){let t=x[e];return(rank(t)+file(t))%2==0?`light`:`dark`}return null}history({verbose:e=!1}={}){let t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){let r=t.pop();if(!r)break;e?n.push(new Move(this,r)):n.push(this._moveToSan(r,this._moves())),this._makeMove(r)}return n}_getPositionCount(e){let t=trimFen(e);return this._positionCount[t]||0}_incPositionCount(e){let t=trimFen(e);this._positionCount[t]===void 0&&(this._positionCount[t]=0),this._positionCount[t]+=1}_decPositionCount(e){let t=trimFen(e);this._positionCount[t]===1?delete this._positionCount[t]:--this._positionCount[t]}_pruneComments(){let e=[],t={},copyComment=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(copyComment(this.fen());;){let t=e.pop();if(!t)break;this._makeMove(t),copyComment(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace(`{`,`[`).replace(`}`,`]`)}deleteComment(){return this.removeComment()}removeComment(){let e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{let t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(let n of[`k`,`q`])t[n]!==void 0&&(t[n]?this._castling[e]|=N[n]:this._castling[e]&=~N[n]);this._updateCastlingRights();let n=this.getCastlingRights(e);return(t.k===void 0||t.k===n.k)&&(t.q===void 0||t.q===n.q)}getCastlingRights(e){return{k:(this._castling[e]&N.k)!==0,q:(this._castling[e]&N.q)!==0}}moveNumber(){return this._moveNumber}};function useChessgroundBounds(e,t){let r=null,i=(0,n.watch)(()=>t.value,t=>{!t||!e.value||(requestAnimationFrame(()=>t.redrawAll()),r=new ResizeObserver(()=>t.redrawAll()),r.observe(e.value),i())},{immediate:!0});(0,n.onUnmounted)(()=>{r?.disconnect(),r=null})}var parseUciMove=e=>{if(e.length<4||e.length>5)throw Error(`Invalid UCI move format: ${e}`);return{from:e.substring(0,2),to:e.substring(2,4),promotion:e.length===5?e[4]:void 0}},toDests=e=>{let t=new Map;return y.forEach(n=>{let r=e.moves({square:n,verbose:!0});r.length&&t.set(n,r.map(e=>e.to))}),t},swapColor=e=>e===`cg-white`?`cg-black`:`cg-white`,toColor=e=>e.turn()===`w`?`cg-white`:`cg-black`,L=(0,n.defineComponent)({name:`PuzzleView`,props:{data:{type:Array,required:!0},modifyDifficulty:{type:Number,required:!1,default:0}},setup(e,{emit:t}){let i=(0,r.useViewable)(e,t,`PuzzleView`),a=(0,r.useQuestionView)(i),o=(0,n.ref)(null),s=(0,n.ref)(),c=(0,n.ref)(),l=(0,n.ref)(`cg-white`),u=(0,n.ref)(!1),d=(0,n.ref)(null);useChessgroundBounds(o,c);let f=[{value:`q`,name:`Queen`,whiteSymbol:`♕`,blackSymbol:`♛`},{value:`r`,name:`Rook`,whiteSymbol:`♖`,blackSymbol:`♜`},{value:`b`,name:`Bishop`,whiteSymbol:`♗`,blackSymbol:`♝`},{value:`n`,name:`Knight`,whiteSymbol:`♘`,blackSymbol:`♞`}],p=(0,n.computed)(()=>{let e=[`a`,`b`,`c`,`d`,`e`,`f`,`g`,`h`];return l.value===`cg-white`?e:e.reverse()}),isPromotionPiece=e=>e?[`q`,`r`,`b`,`n`].includes(e):!1,isUnfinishedPromotion=(e,t,n)=>isPromotionPiece(n)?!1:s.value?.get(e)?.type===`p`&&(t[1]===`8`||t[1]===`1`),updateChessground=()=>{!s.value||!c.value||c.value.set({fen:s.value.fen(),turnColor:toColor(s.value),movable:{color:toColor(s.value),dests:toDests(s.value)}})},handlePromotion=e=>{if(e!==`q`&&e!==`r`&&e!==`b`&&e!==`n`){i.logger.error(`Invalid promotion piece: ${e}`);return}d.value&&(i.logger.log(`promoting to ${e}`),u.value=!1,checkMove(d.value.from,d.value.to,e))},checkMove=(e,t,n)=>{if(!a.question.value?.moves.length)throw Error(`No moves`);if(isUnfinishedPromotion(e,t,n)){d.value={from:e,to:t},u.value=!0;return}a.question.value.moves[0]===(isPromotionPiece(n)?`${e}${t}${n}`:`${e}${t}`)?(s.value?.move({from:e,to:t,promotion:isPromotionPiece(n)?n:void 0}),updateChessground(),a.question.value.moves.shift(),a.question.value.moves.length===0?a.submitAnswer(``):window.setTimeout(()=>{if(!a.question.value)return;let e=parseUciMove(a.question.value.moves.shift());s.value?.move(e),updateChessground()},300)):(s.value?.move({from:e,to:t,promotion:n}),s.value?.isCheckmate()?a.submitAnswer(J.CHECKMATE):s.value?.undo(),a.submitAnswer(e+t+n),updateChessground())};return(0,n.onMounted)(()=>{if(!o.value)return;a.question.value=new J(e.data),s.value=new Chess(a.question.value.fen),l.value=swapColor(toColor(s.value)),c.value=Chessground(o.value,{movable:{free:!1,showDests:!0,dests:toDests(s.value),events:{after:checkMove}},draggable:{showGhost:!0},fen:s.value.fen(),orientation:l.value,coordinates:!1,animation:{duration:300,enabled:!0}});let t=a.question.value.moves.shift();c.value.move(t.substring(0,2),t.substring(2)),s.value.move({from:t.substring(0,2),to:t.substring(2)}),updateChessground()}),(0,n.onUnmounted)(()=>{c.value?.destroy(),s.value=void 0}),{boardElement:o,playerColor:l,files:p,showPromotionDialog:u,promotionPieces:f,handlePromotion,...i,...a}}}),R={"data-viewable":`PuzzleView`},z={class:`text-h5`},B={class:`puzzle-board-wrapper`},V={class:`puzzle-ranks-labels`},H={class:`puzzle-board-and-files`},U={id:`cg`,ref:`boardElement`},W={class:`puzzle-files-labels`},G={key:0,class:`puzzle-promotion-dialog`},K=[`onClick`];function _sfc_render(e,t,r,i,a,o){return(0,n.openBlock)(),(0,n.createElementBlock)(`div`,R,[(0,n.createElementVNode)(`p`,z,` Make the best move for `+(0,n.toDisplayString)(e.playerColor===`cg-white`?`White ♖♘♗♕♔♗♘♖`:`Black ♜♞♝♚♛♝♞♜`)+`: `,1),(0,n.createElementVNode)(`div`,B,[(0,n.createElementVNode)(`div`,V,[((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(8,t=>(0,n.createElementVNode)(`div`,{key:t},(0,n.toDisplayString)(e.playerColor===`cg-white`?9-t:t),1)),64))]),(0,n.createElementVNode)(`div`,H,[(0,n.createElementVNode)(`div`,U,null,512),(0,n.createElementVNode)(`div`,W,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.files,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:e},(0,n.toDisplayString)(e),1))),128))])])]),e.showPromotionDialog?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,G,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.promotionPieces,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:t.value,onClick:n=>e.handlePromotion(t.value)},(0,n.toDisplayString)(e.playerColor===`cg-white`?t.whiteSymbol:t.blackSymbol)+` `+(0,n.toDisplayString)(t.name),9,K))),128))])):(0,n.createCommentVNode)(``,!0)])}var q=t.r(L,[[`render`,_sfc_render]]),J=class ChessPuzzle extends r.Question{static dataShapes=[{name:i.DataShapeName.CHESS_puzzle,fields:[{name:`puzzleData`,type:i.FieldType.CHESS_PUZZLE,validator:{instructions:`insert a valid fen string`,test:function(e){if(console.log(`running puzzle validator on ${e}`),!e)return{status:i.Status.error,msg:`no defined input`};let t=e.split(`,`);return t.length<10||t.length>11?{status:i.Status.error,msg:`puzzleData must have 10 or 11 comma-separated fields (got ${t.length})`}:{status:i.Status.ok,msg:``}}},tagger:()=>[`test`]}]}];static views=[q];static acceptsUserData=!0;static CHECKMATE=`CHECKMATE`;fen;id;moves;rating;themes;constructor(e){super(e);let[t,n,r,i,,,,a]=e[0].puzzleData.split(`,`);this.id=t,this.fen=n,this.moves=r.split(` `),this.rating=parseInt(i,10),this.themes=a.split(` `)}checkMove=(e,t)=>(alert(`checkMove`),console.log(`checkMove`,e,t),console.log(`this.moves[0]`,this.moves[0]),this.moves[0]===t);evaluate(e,t){return{isCorrect:this.isCorrect(e),performance:this.displayedSkill(e,t)}}displayedSkill(e,t){return this.isCorrect(e)?t<5e3?1:1-Math.min(1,(t-5e3)/1e4):0}dataShapes(){return ChessPuzzle.dataShapes}views(){return ChessPuzzle.views}isCorrect(e){let t=this.moves.length===0;return e===ChessPuzzle.CHECKMATE||t}},Y=new t.t(`chess`,[J]);Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Y}});
|
|
7
|
+
//# sourceMappingURL=chess-BWes0jGA.cjs.map
|