-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.eslintcache
1 lines (1 loc) · 19.3 KB
/
.eslintcache
1
[{"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Chessboard\\Chessboard.tsx":"1","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\BishopRules.ts":"2","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\Constants.ts":"3","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Referee\\Referee.tsx":"4","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\KingRules.ts":"5","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\KnightRules.ts":"6","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\PawnRules.ts":"7","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\QueenRules.ts":"8","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\RookRules.ts":"9","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\GeneralRules.ts":"10","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Piece.ts":"11","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\index.tsx":"12","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Tile\\Tile.tsx":"13","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\index.ts":"14","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Pawn.ts":"15","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Position.ts":"16","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Board.ts":"17","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\reportWebVitals.ts":"18","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\App.tsx":"19","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\Types.ts":"20","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\index.ts":"21"},{"size":4309,"mtime":1678824167802,"results":"22","hashOfConfig":"23"},{"size":4855,"mtime":1666374740388,"results":"24","hashOfConfig":"23"},{"size":2963,"mtime":1679759252678,"results":"25","hashOfConfig":"23"},{"size":7364,"mtime":1679759349693,"results":"26","hashOfConfig":"23"},{"size":7552,"mtime":1679758886671,"results":"27","hashOfConfig":"23"},{"size":1902,"mtime":1666374622425,"results":"28","hashOfConfig":"23"},{"size":3490,"mtime":1666982074915,"results":"29","hashOfConfig":"23"},{"size":4682,"mtime":1666374642096,"results":"30","hashOfConfig":"23"},{"size":3786,"mtime":1679756323881,"results":"31","hashOfConfig":"23"},{"size":926,"mtime":1666981842810,"results":"32","hashOfConfig":"23"},{"size":1587,"mtime":1679507982554,"results":"33","hashOfConfig":"23"},{"size":517,"mtime":1611929990096,"results":"34","hashOfConfig":"23"},{"size":558,"mtime":1664566664895,"results":"35","hashOfConfig":"23"},{"size":183,"mtime":1665763713036,"results":"36","hashOfConfig":"23"},{"size":630,"mtime":1679508452848,"results":"37","hashOfConfig":"23"},{"size":378,"mtime":1666978137553,"results":"38","hashOfConfig":"23"},{"size":8081,"mtime":1679759017537,"results":"39","hashOfConfig":"23"},{"size":440,"mtime":1611929990098,"results":"40","hashOfConfig":"23"},{"size":188,"mtime":1664562836495,"results":"41","hashOfConfig":"23"},{"size":222,"mtime":1666374507524,"results":"42","hashOfConfig":"23"},{"size":53,"mtime":1665766860907,"results":"43","hashOfConfig":"23"},{"filePath":"44","messages":"45","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"f5pbom",{"filePath":"47","messages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"49","messages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","errorCount":0,"fatalErrorCount":0,"warningCount":12,"fixableErrorCount":0,"fixableWarningCount":0,"source":"53"},{"filePath":"54","messages":"55","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"58","messages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"60","messages":"61","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"62","messages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"66","messages":"67","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"68","messages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"70","messages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"72","messages":"73","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"74","messages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"76","messages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"78","messages":"79","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"80","messages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"82","messages":"83","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"84","messages":"85","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"86","messages":"87","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Chessboard\\Chessboard.tsx",[],["88","89"],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\BishopRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\Constants.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Referee\\Referee.tsx",["90","91","92","93","94","95","96","97","98","99","100","101"],"import { useEffect, useRef, useState } from \"react\";\r\nimport { initialBoard } from \"../../Constants\";\r\nimport { Piece, Position } from \"../../models\";\r\nimport { Board } from \"../../models/Board\";\r\nimport { Pawn } from \"../../models/Pawn\";\r\nimport { bishopMove, getPossibleBishopMoves, getPossibleKingMoves, getPossibleKnightMoves, getPossiblePawnMoves, getPossibleQueenMoves, getPossibleRookMoves, kingMove, knightMove, pawnMove, queenMove, rookMove } from \"../../referee/rules\";\r\nimport { PieceType, TeamType } from \"../../Types\";\r\nimport Chessboard from \"../Chessboard/Chessboard\";\r\n\r\nexport default function Referee() {\r\n const [board, setBoard] = useState<Board>(initialBoard.clone());\r\n const [promotionPawn, setPromotionPawn] = useState<Piece>();\r\n const modalRef = useRef<HTMLDivElement>(null);\r\n const checkmateModalRef = useRef<HTMLDivElement>(null);\r\n\r\n function playMove(playedPiece: Piece, destination: Position): boolean {\r\n // If the playing piece doesn't have any moves return\r\n if (playedPiece.possibleMoves === undefined) return false;\r\n\r\n // Prevent the inactive team from playing\r\n if (playedPiece.team === TeamType.OUR\r\n && board.totalTurns % 2 !== 1) return false;\r\n if (playedPiece.team === TeamType.OPPONENT\r\n && board.totalTurns % 2 !== 0) return false;\r\n\r\n let playedMoveIsValid = false;\r\n\r\n const validMove = playedPiece.possibleMoves?.some(m => m.samePosition(destination));\r\n\r\n if (!validMove) return false;\r\n\r\n const enPassantMove = isEnPassantMove(\r\n playedPiece.position,\r\n destination,\r\n playedPiece.type,\r\n playedPiece.team\r\n );\r\n\r\n // playMove modifies the board thus we\r\n // need to call setBoard\r\n setBoard(() => {\r\n const clonedBoard = board.clone();\r\n clonedBoard.totalTurns += 1;\r\n // Playing the move\r\n playedMoveIsValid = clonedBoard.playMove(enPassantMove,\r\n validMove, playedPiece,\r\n destination);\r\n\r\n if(clonedBoard.winningTeam !== undefined) {\r\n checkmateModalRef.current?.classList.remove(\"hidden\");\r\n }\r\n\r\n return clonedBoard;\r\n })\r\n\r\n // This is for promoting a pawn\r\n let promotionRow = (playedPiece.team === TeamType.OUR) ? 7 : 0;\r\n\r\n if (destination.y === promotionRow && playedPiece.isPawn) {\r\n modalRef.current?.classList.remove(\"hidden\");\r\n setPromotionPawn((previousPromotionPawn) => {\r\n const clonedPlayedPiece = playedPiece.clone();\r\n clonedPlayedPiece.position = destination.clone();\r\n return clonedPlayedPiece;\r\n });\r\n }\r\n\r\n return playedMoveIsValid;\r\n }\r\n\r\n function isEnPassantMove(\r\n initialPosition: Position,\r\n desiredPosition: Position,\r\n type: PieceType,\r\n team: TeamType\r\n ) {\r\n const pawnDirection = team === TeamType.OUR ? 1 : -1;\r\n\r\n if (type === PieceType.PAWN) {\r\n if (\r\n (desiredPosition.x - initialPosition.x === -1 ||\r\n desiredPosition.x - initialPosition.x === 1) &&\r\n desiredPosition.y - initialPosition.y === pawnDirection\r\n ) {\r\n const piece = board.pieces.find(\r\n (p) =>\r\n p.position.x === desiredPosition.x &&\r\n p.position.y === desiredPosition.y - pawnDirection &&\r\n p.isPawn &&\r\n (p as Pawn).enPassant\r\n );\r\n if (piece) {\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n //TODO\r\n //Add stalemate!\r\n function isValidMove(initialPosition: Position, desiredPosition: Position, type: PieceType, team: TeamType) {\r\n let validMove = false;\r\n switch (type) {\r\n case PieceType.PAWN:\r\n validMove = pawnMove(initialPosition, desiredPosition, team, board.pieces);\r\n break;\r\n case PieceType.KNIGHT:\r\n validMove = knightMove(initialPosition, desiredPosition, team, board.pieces);\r\n break;\r\n case PieceType.BISHOP:\r\n validMove = bishopMove(initialPosition, desiredPosition, team, board.pieces);\r\n break;\r\n case PieceType.ROOK:\r\n validMove = rookMove(initialPosition, desiredPosition, team, board.pieces);\r\n break;\r\n case PieceType.QUEEN:\r\n validMove = queenMove(initialPosition, desiredPosition, team, board.pieces);\r\n break;\r\n case PieceType.KING:\r\n validMove = kingMove(initialPosition, desiredPosition, team, board.pieces);\r\n }\r\n\r\n return validMove;\r\n }\r\n\r\n function promotePawn(pieceType: PieceType) {\r\n if (promotionPawn === undefined) {\r\n return;\r\n }\r\n\r\n setBoard((previousBoard) => {\r\n const clonedBoard = board.clone();\r\n clonedBoard.pieces = clonedBoard.pieces.reduce((results, piece) => {\r\n if (piece.samePiecePosition(promotionPawn)) {\r\n results.push(new Piece(piece.position.clone(), pieceType,\r\n piece.team, true));\r\n } else {\r\n results.push(piece);\r\n }\r\n return results;\r\n }, [] as Piece[]);\r\n\r\n clonedBoard.calculateAllMoves();\r\n\r\n return clonedBoard;\r\n })\r\n\r\n modalRef.current?.classList.add(\"hidden\");\r\n }\r\n\r\n function promotionTeamType() {\r\n return (promotionPawn?.team === TeamType.OUR) ? \"w\" : \"b\";\r\n }\r\n \r\n function restartGame() {\r\n checkmateModalRef.current?.classList.add(\"hidden\");\r\n setBoard(initialBoard.clone());\r\n }\r\n\r\n return (\r\n <>\r\n <p style={{ color: \"white\", fontSize: \"24px\", textAlign: \"center\" }}>Total turns: {board.totalTurns}</p>\r\n <div className=\"modal hidden\" ref={modalRef}>\r\n <div className=\"modal-body\">\r\n <img onClick={() => promotePawn(PieceType.ROOK)} src={`/assets/images/rook_${promotionTeamType()}.png`} />\r\n <img onClick={() => promotePawn(PieceType.BISHOP)} src={`/assets/images/bishop_${promotionTeamType()}.png`} />\r\n <img onClick={() => promotePawn(PieceType.KNIGHT)} src={`/assets/images/knight_${promotionTeamType()}.png`} />\r\n <img onClick={() => promotePawn(PieceType.QUEEN)} src={`/assets/images/queen_${promotionTeamType()}.png`} />\r\n </div>\r\n </div>\r\n <div className=\"modal hidden\" ref={checkmateModalRef}>\r\n <div className=\"modal-body\">\r\n <div className=\"checkmate-body\">\r\n <span>The winning team is {board.winningTeam === TeamType.OUR ? \"white\" : \"black\"}!</span>\r\n <button onClick={restartGame}>Play again</button>\r\n </div>\r\n </div>\r\n </div>\r\n <Chessboard playMove={playMove}\r\n pieces={board.pieces} />\r\n </>\r\n )\r\n}","C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\KingRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\KnightRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\PawnRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\QueenRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\RookRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\GeneralRules.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Piece.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\index.tsx",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\components\\Tile\\Tile.tsx",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\referee\\rules\\index.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Pawn.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Position.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\Board.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\reportWebVitals.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\App.tsx",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\Types.ts",[],"C:\\Users\\sueno\\Documents\\Github\\coding-projects\\reactjs-projects\\chess-app\\src\\models\\index.ts",[],{"ruleId":"102","replacedBy":"103"},{"ruleId":"104","replacedBy":"105"},{"ruleId":"106","severity":1,"message":"107","line":1,"column":10,"nodeType":"108","messageId":"109","endLine":1,"endColumn":19},{"ruleId":"106","severity":1,"message":"110","line":6,"column":22,"nodeType":"108","messageId":"109","endLine":6,"endColumn":44},{"ruleId":"106","severity":1,"message":"111","line":6,"column":46,"nodeType":"108","messageId":"109","endLine":6,"endColumn":66},{"ruleId":"106","severity":1,"message":"112","line":6,"column":68,"nodeType":"108","messageId":"109","endLine":6,"endColumn":90},{"ruleId":"106","severity":1,"message":"113","line":6,"column":92,"nodeType":"108","messageId":"109","endLine":6,"endColumn":112},{"ruleId":"106","severity":1,"message":"114","line":6,"column":114,"nodeType":"108","messageId":"109","endLine":6,"endColumn":135},{"ruleId":"106","severity":1,"message":"115","line":6,"column":137,"nodeType":"108","messageId":"109","endLine":6,"endColumn":157},{"ruleId":"106","severity":1,"message":"116","line":103,"column":14,"nodeType":"108","messageId":"109","endLine":103,"endColumn":25},{"ruleId":"117","severity":1,"message":"118","line":167,"column":21,"nodeType":"119","endLine":167,"endColumn":127},{"ruleId":"117","severity":1,"message":"118","line":168,"column":21,"nodeType":"119","endLine":168,"endColumn":131},{"ruleId":"117","severity":1,"message":"118","line":169,"column":21,"nodeType":"119","endLine":169,"endColumn":131},{"ruleId":"117","severity":1,"message":"118","line":170,"column":21,"nodeType":"119","endLine":170,"endColumn":129},"no-native-reassign",["120"],"no-negated-in-lhs",["121"],"@typescript-eslint/no-unused-vars","'useEffect' is defined but never used.","Identifier","unusedVar","'getPossibleBishopMoves' is defined but never used.","'getPossibleKingMoves' is defined but never used.","'getPossibleKnightMoves' is defined but never used.","'getPossiblePawnMoves' is defined but never used.","'getPossibleQueenMoves' is defined but never used.","'getPossibleRookMoves' is defined but never used.","'isValidMove' is defined but never used.","jsx-a11y/alt-text","img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.","JSXOpeningElement","no-global-assign","no-unsafe-negation"]