-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintcache
1 lines (1 loc) · 27.6 KB
/
.eslintcache
1
[{"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\index.js":"1","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\App.js":"2","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\reportWebVitals.js":"3","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\index.js":"4","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\Tetris.js":"5","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Header\\Header.js":"6","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\borderFactory.js":"7","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\cellRender.js":"8","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\validateLine.js":"9","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\clearLines.js":"10","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\index.js":"11","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\useTetris.js":"12","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\boardReducer.js":"13","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\emptyBoard.js":"14","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\buildPc.js":"15","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\usePcs.js":"16","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\canHasMovement.js":"17","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\transformPc.js":"18","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\canHasRotation.js":"19","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\useBoard.js":"20","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\Dummy.js":"21","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\lineBoard.js":"22"},{"size":517,"mtime":1624215584260,"results":"23","hashOfConfig":"24"},{"size":546,"mtime":1626000952425,"results":"25","hashOfConfig":"24"},{"size":375,"mtime":1624215584263,"results":"26","hashOfConfig":"24"},{"size":124,"mtime":1624215584256,"results":"27","hashOfConfig":"24"},{"size":5662,"mtime":1625965530324,"results":"28","hashOfConfig":"24"},{"size":480,"mtime":1624216424687,"results":"29","hashOfConfig":"24"},{"size":426,"mtime":1624215584228,"results":"30","hashOfConfig":"24"},{"size":868,"mtime":1624215584234,"results":"31","hashOfConfig":"24"},{"size":811,"mtime":1624215584242,"results":"32","hashOfConfig":"24"},{"size":609,"mtime":1624215584236,"results":"33","hashOfConfig":"24"},{"size":323,"mtime":1625435637487,"results":"34","hashOfConfig":"24"},{"size":208,"mtime":1624291737492,"results":"35","hashOfConfig":"24"},{"size":4404,"mtime":1625882011735,"results":"36","hashOfConfig":"24"},{"size":921,"mtime":1625791322247,"results":"37","hashOfConfig":"24"},{"size":2251,"mtime":1625647513137,"results":"38","hashOfConfig":"24"},{"size":590,"mtime":1625881340676,"results":"39","hashOfConfig":"24"},{"size":3306,"mtime":1624215584231,"results":"40","hashOfConfig":"24"},{"size":522,"mtime":1625880627968,"results":"41","hashOfConfig":"24"},{"size":1261,"mtime":1625788716608,"results":"42","hashOfConfig":"24"},{"size":200,"mtime":1624291765819,"results":"43","hashOfConfig":"24"},{"size":175,"mtime":1624919406101,"results":"44","hashOfConfig":"45"},{"size":934,"mtime":1625791953277,"results":"46","hashOfConfig":"24"},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},"c5xh1h",{"filePath":"50","messages":"51","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"52"},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"57","messages":"58","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"59"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"70","messages":"71","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"74","messages":"75","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"76"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"81","messages":"82","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"83"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"86","usedDeprecatedRules":"49"},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"89","messages":"90","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"91","usedDeprecatedRules":"49"},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"96"},"1rtkkq9",{"filePath":"97","messages":"98","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\index.js",[],["99","100"],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\App.js",["101","102"],"\r\nimport React, { useEffect } from 'react';\r\nimport './App.css';\r\n\r\nimport {\r\n Header,\r\n Tetris\r\n} from './components';\r\n\r\nimport {\r\n initBoard, gamePcs, dummyPcs\r\n} from './components/Tetris/useTetrisHooks';\r\n\r\nimport { lineBoard } from './components/Tetris/assets/lineBoard';\r\n\r\nfunction App() {\r\nreturn (\r\n<div className=\"centering_wrapper\" data-testid=\"app_cont\">\r\n<div className='centered_cont'>\r\n\r\n <Header />\r\n <Tetris initBoard={{...initBoard(dummyPcs), board: lineBoard}} />\r\n\r\n</div>\r\n</div>\r\n);\r\n}\r\n\r\nexport default App;","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\reportWebVitals.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\index.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\Tetris.js",["103","104"],"\r\nimport './styles/_helpers.css';\r\nimport './styles/_tetrisBoard.css';\r\nimport React, { useEffect, useRef, useState } from 'react';\r\n\r\n// outside components\r\nimport KeyboardEventHandler from 'react-keyboard-event-handler';\r\n\r\n// cell style factories\r\n// (stateAssets): renderUI\r\nimport { determineBorder } from './assets/borderFactory.js';\r\nimport { isAPc } from './assets/cellRender.js';\r\n\r\n// line handling\r\nimport { validateLine } from './assets/validateLine.js';\r\nimport { clearLines } from './assets/clearLines.js';\r\n\r\n// tetris state assets\r\nimport {\r\n useTetris,\r\n // initBoard,\r\n BOARD_ACTIONS,\r\n boardReducer,\r\n} from './useTetrisHooks';\r\n\r\nconst { KILL_ACTIVE } = BOARD_ACTIONS;\r\n\r\nconst controls = {\r\n 'f': BOARD_ACTIONS.RIGHT,\r\n 'd': BOARD_ACTIONS.DOWN,\r\n 's': BOARD_ACTIONS.LEFT,\r\n\r\n 'r': BOARD_ACTIONS.CW,\r\n 'w': BOARD_ACTIONS.CCW,\r\n};\r\n\r\nconst lineActions = {\r\n // 'highlight': BOARD_ACTIONS.HIGHLIGHT, \r\n 'update': BOARD_ACTIONS.UPDATE,\r\n};\r\n\r\nfunction Tetris({ initBoard }) {\r\n\r\n const startGameButtonBlurRef = useRef();\r\n const killActiveButtonBlurRef = useRef();\r\n const endGameButtonBlurRef = useRef();\r\n const resetGameButtonBlurRef = useRef();\r\n\r\n const [boardState, dispatchBoard] = useTetris(boardReducer, initBoard);\r\n const [dropInt, setDropInt] = useState(null);\r\n\r\n // dropInterval\r\n useEffect(() => {\r\n\r\n if (boardState.gameActive) {\r\n\r\n setDropInt( setInterval(() => {\r\n\r\n dispatchBoard({ type: BOARD_ACTIONS.DOWN });\r\n }, 500) );\r\n\r\n } else {\r\n if (dropInt) {\r\n setDropInt(null);\r\n clearInterval(dropInt);\r\n }\r\n }\r\n\r\n return () => clearInterval(dropInt);\r\n \r\n }, [boardState.gameActive]);\r\n\r\n useEffect(() => {\r\n // why is game not ending? \r\n if (boardState.board[0].find((block) => block > 0)) {\r\n dispatchBoard({ type: BOARD_ACTIONS.END });\r\n }\r\n\r\n const lineObj = validateLine(boardState.board);\r\n // lineObj: { lines: [...Rows], points }\r\n \r\n if (lineObj.lines.length) {\r\n dispatchBoard({ \r\n type: lineActions['update'], \r\n payload: clearLines(boardState.board, lineObj.lines)\r\n });\r\n // clearLines: updatedBoard: [...[...], etc]\r\n }\r\n\r\n }, [boardState.board]);\r\n\r\n const receiveKeyPress = (key) => {\r\n // listen for key actions\r\n if (boardState.gameActive) {\r\n dispatchBoard({ type: controls[key] });\r\n }\r\n\r\n }\r\n\r\nreturn (\r\n<>\r\n <div className='tetris_cont' data-testid='tetris_cont'>\r\n\r\n {\r\n boardState.board.map((row, r_idx) => (\r\n <div className='board_row' key={r_idx}>\r\n {\r\n row.map((staticCell, c_idx) => (\r\n\r\n <div className='board_cell' key={c_idx}\r\n style={{ \r\n ...determineBorder(r_idx, c_idx),\r\n ...isAPc(staticCell, boardState.activePc, [r_idx, c_idx])\r\n }}\r\n >\r\n\r\n </div>\r\n\r\n ))\r\n }\r\n </div>\r\n ))\r\n }\r\n </div>\r\n <div className='controllers_cont'>\r\n {/* rotations */}\r\n <div className='helpers_cont'>\r\n\r\n <button data-testid='control_ccw'\r\n onClick={() => receiveKeyPress('w')}\r\n >ccw</button>\r\n <button data-testid='control_cw'\r\n onClick={() => receiveKeyPress('r')}\r\n >cw</button>\r\n\r\n </div>\r\n\r\n {/* directions */}\r\n <div className='helpers_cont'>\r\n\r\n <button data-testid='control_left'\r\n onClick={() => receiveKeyPress('s')}\r\n >left</button>\r\n <button data-testid='control_down'\r\n onClick={() => receiveKeyPress('d')}\r\n >down</button>\r\n <button data-testid='control_right'\r\n onClick={() => receiveKeyPress('f')}\r\n >right</button>\r\n\r\n </div>\r\n\r\n {/* game */}\r\n <div className='helpers_cont'>\r\n <button className='helpers_btn' ref={startGameButtonBlurRef} data-testid='startGame'\r\n onClick={() => {\r\n dispatchBoard({type: BOARD_ACTIONS.START});\r\n startGameButtonBlurRef.current.blur();\r\n }}\r\n >Start Game</button>\r\n\r\n <button className='helpers_btn' ref={endGameButtonBlurRef} data-testid='endGame'\r\n onClick={() => {\r\n dispatchBoard({type: BOARD_ACTIONS.END});\r\n endGameButtonBlurRef.current.blur();\r\n }}\r\n >End Game</button>\r\n\r\n <button className='helpers_btn' ref={resetGameButtonBlurRef} data-testid='resetGame'\r\n onClick={() => {\r\n dispatchBoard({type: BOARD_ACTIONS.RESET});\r\n resetGameButtonBlurRef.current.blur();\r\n }}\r\n >Reset Game</button>\r\n\r\n </div>\r\n\r\n {/* mod */}\r\n <div className='helpers_cont'>\r\n <button className='helpers_btn' ref={killActiveButtonBlurRef} data-testid='killActive'\r\n onClick={() => {\r\n dispatchBoard({type: KILL_ACTIVE});\r\n killActiveButtonBlurRef.current.blur();\r\n }}\r\n >kill active pc</button>\r\n </div>\r\n\r\n {/* \r\n key handling \r\n KeyboardEventHandler - might not be super accessible as is seen from tests\r\n */}\r\n\r\n <KeyboardEventHandler\r\n handleKeys={['f', 'd', 's', 'r', 'w']}\r\n handleEventType='keydown'\r\n onKeyEvent={(key, e) => receiveKeyPress(key)}\r\n />\r\n </div>\r\n</>\r\n)\r\n}\r\n\r\nexport default Tetris;","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Header\\Header.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\borderFactory.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\cellRender.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\validateLine.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\clearLines.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\index.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\useTetris.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\boardReducer.js",["105"],"\r\nimport produce from 'immer';\r\nimport { emptyBoard } from '../assets/emptyBoard.js';\r\nimport { buildPcFactory, gamePcs } from '../assets/buildPc.js';\r\nimport { canHasMovement } from '../assets/canHasMovement';\r\nimport { transformPc } from '../assets/transformPc';\r\nimport { canHasRotation } from '../assets/canHasRotation';\r\n\r\nconst initBoard = (gamePcs) => { \r\n return {\r\n board: emptyBoard,\r\n // pieces\r\n activePc: {},\r\n /*\r\n {pivot[y, x], form, forms[...[]], color}\r\n */\r\n\r\n inWaitingPc: {},\r\n\r\n combo: 0,\r\n points: 0,\r\n\r\n gameActive: false,\r\n buildPc: buildPcFactory(gamePcs)\r\n };\r\n}\r\n\r\n// constructing while pointing at normal gamePcs\r\n// const buildPc = buildPcFactory(gamePcs);\r\n\r\nconst BOARD_ACTIONS = {\r\n START: 'start_game',\r\n END: 'end_game',\r\n RESET: 'reset_game',\r\n\r\n PULL_ACTIVE: 'pull_active',\r\n KILL_ACTIVE: 'kill_active',\r\n\r\n // keyPress handling\r\n RIGHT: 'keyPress_right',\r\n DOWN: 'keyPress_down',\r\n LEFT: 'keyPress_left',\r\n\r\n CW: 'rotate_cw', // expect shift form index to right\r\n CCW: 'rotate_ccw', // expect shift form index to left\r\n\r\n // updating board\r\n HIGHLIGHT: 'highlight_rows', \r\n};\r\n\r\nconst {\r\n START, END, RESET, \r\n // pc handling\r\n PULL_ACTIVE, KILL_ACTIVE, \r\n // keyPress handling\r\n RIGHT, DOWN, LEFT, \r\n CW, CCW, \r\n // updating board\r\n UPDATE,\r\n} = BOARD_ACTIONS;\r\n\r\nconst boardReducer = (state, { type, payload }) => {\r\n\r\n switch(type) {\r\n case START: \r\n if (state.gameActive === true) return state;\r\n\r\n if (state.board !== emptyBoard) return state;\r\n\r\n if (Object.keys(state.activePc).length > 0) return state;\r\n\r\n return produce(state, draft => {\r\n // draft.activePc = {};\r\n draft.gameActive = true;\r\n });\r\n\r\n case END: \r\n return produce(state, draft => {\r\n draft.gameActive = false;\r\n });\r\n\r\n case RESET:\r\n if (state.gameActive === true) return state;\r\n\r\n return produce(state, draft => {\r\n draft.activePc = {};\r\n draft.board = emptyBoard;\r\n });\r\n\r\n case PULL_ACTIVE: \r\n return produce(state, draft => {\r\n const builtPc = {...draft.buildPc(), form: 0 };\r\n draft.activePc = builtPc;\r\n });\r\n\r\n case KILL_ACTIVE: \r\n return produce(state, draft => {\r\n draft.activePc = {}\r\n });\r\n\r\n case RIGHT: \r\n const moveRightObj = canHasMovement(state.board, state.activePc, type);\r\n return produce(state, draft => {\r\n if (moveRightObj.canHas) {\r\n draft.activePc.pivot = moveRightObj.pos;\r\n }\r\n });\r\n\r\n case DOWN: \r\n if (!Object.keys(state.activePc).length) { return state }\r\n\r\n const moveDownObj = canHasMovement(state.board, state.activePc, type);\r\n if (moveDownObj.canHas) {\r\n return produce(state, draft => {\r\n draft.activePc.pivot = moveDownObj.pos;\r\n });\r\n\r\n } else {\r\n return produce(state, draft => {\r\n draft.board = transformPc(state.activePc, state.board);\r\n draft.activePc = {};\r\n });\r\n }\r\n\r\n case LEFT: \r\n const moveLeftObj = canHasMovement(state.board, state.activePc, type);\r\n return produce(state, draft => {\r\n if (moveLeftObj.canHas) {\r\n draft.activePc.pivot = moveLeftObj.pos;\r\n }\r\n })\r\n \r\n case CW: \r\n return produce(state, draft => {\r\n draft.activePc.form = canHasRotation(state.board, state.activePc, CW).form;\r\n });\r\n \r\n\r\n case CCW: \r\n return produce(state, draft => {\r\n draft.activePc.form = canHasRotation(state.board, state.activePc, CCW).form;\r\n });\r\n \r\n case UPDATE: \r\n return produce(state, draft => {\r\n draft.board = payload;\r\n });\r\n\r\n default: \r\n return state;\r\n }\r\n}\r\n\r\nexport {\r\n initBoard,\r\n BOARD_ACTIONS,\r\n boardReducer,\r\n};","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\emptyBoard.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\buildPc.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\usePcs.js",["106"],"\r\nimport { useEffect } from 'react';\r\n// parent hook\r\nimport { useBoard } from './useBoard';\r\n\r\nimport { BOARD_ACTIONS } from './boardReducer.js';\r\n\r\nconst { PULL_ACTIVE } = BOARD_ACTIONS;\r\n\r\n\r\nexport const usePcs = (reducer, init) => {\r\n\r\n const [boardState, dispatchBoard] = useBoard(reducer, init);\r\n\r\n useEffect(() => {\r\n\r\n if (!Object.keys(boardState.activePc).length && boardState.gameActive) { dispatchBoard({ type: PULL_ACTIVE }) }\r\n \r\n }, [boardState.activePc, boardState.gameActive]);\r\n\r\n return [\r\n boardState, \r\n dispatchBoard, \r\n\r\n ];\r\n};","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\canHasMovement.js",["107"],"\r\nimport produce from 'immer'\r\nconst BOARD_ACTIONS = {\r\n UP: 'keyPress_up',\r\n RIGHT: 'keyPress_right',\r\n DOWN: 'keyPress_down',\r\n LEFT: 'keyPress_left',\r\n}\r\n\r\nconst {\r\n UP,\r\n RIGHT,\r\n DOWN,\r\n LEFT,\r\n} = BOARD_ACTIONS\r\n\r\nexport const canHasMovement = (board, activePc, dir) => {\r\n // receive (board, activePc)\r\n // if !activePc.lenght return false\r\n if (!Object.keys(activePc).length) { \r\n console.log('keyPress: RIGHT. no pc present, preventing movement') \r\n return { canHas: false, pos: [] } \r\n }\r\n\r\n // dir: [UP, RIGHT, DOWN, LEFT] - helper validates against ACTIONS\r\n\r\n const pivot = activePc.pivot\r\n const curForm = activePc.forms[activePc.form]\r\n\r\n const formsPositioned = [pivot, ...curForm.map((point, idx) => {\r\n return [point[0] + pivot[0], point[1] + pivot[1]]\r\n })]\r\n\r\n\r\n if (dir === LEFT) {\r\n\r\n return formsPositioned.reduce( (prev, block, idx) => {\r\n if (!prev.canHas) { return prev }\r\n\r\n const blockY = block[0]\r\n const blockX = block[1]\r\n\r\n // wall collision check\r\n if (blockX - 1 < 0) {\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n draft.pos = []\r\n })\r\n }\r\n // pc collision check\r\n else if (board[blockY][blockX-1] === 1) {\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n draft.pos = []\r\n })\r\n } else { return prev }\r\n \r\n }, { canHas: true, pos: [pivot[0], pivot[1]-1] })\r\n\r\n } \r\n\r\n if (dir === RIGHT) {\r\n\r\n return formsPositioned.reduce( (prev, block, idx) => {\r\n if (!prev.canHas) { return prev }\r\n\r\n const blockY = block[0]\r\n const blockX = block[1]\r\n // wall collision check\r\n if (blockX + 1 >= board[0].length) {\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n draft.pos = []\r\n })\r\n }\r\n // pc collision check\r\n else if (board[blockY][blockX+1] === 1) {\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n draft.pos = []\r\n })\r\n } else { return prev }\r\n\r\n \r\n }, { canHas: true, pos: [pivot[0], pivot[1]+1] })\r\n\r\n } \r\n\r\n if (dir === DOWN) {\r\n\r\n return formsPositioned.reduce( (prev, block, idx) => {\r\n if (!prev.canHas) { return prev }\r\n\r\n const blockY = block[0]\r\n const blockX = block[1]\r\n\r\n // floor collision check\r\n if (blockY + 1 >= board.length) {\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n })\r\n\r\n // staticPc collision check\r\n } else if (board[blockY+1][blockX] === 1) {\r\n\r\n return produce(prev, draft => {\r\n draft.canHas = false\r\n })\r\n\r\n } else { return prev }\r\n\r\n }, { canHas: true, pos: [pivot[0]+1, pivot[1]] })\r\n\r\n }\r\n\r\n}","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\transformPc.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\canHasRotation.js",["108"],"\r\nimport produce from 'immer';\r\n\r\nconst ROTATE = {\r\n CW: 'rotate_cw', // expect shift form index to right\r\n CCW: 'rotate_ccw', // expect shift form index to left\r\n};\r\n\r\nconst { CW, CCW } = ROTATE;\r\n\r\nconst canHasRotation = (board, activePc, dir) => {\r\n\r\nconst prevForm = activePc.form;\r\nlet nextForm;\r\n\r\nif (CW === dir) {\r\n nextForm = activePc.form === activePc.forms.length-1 ? 0 : activePc.form+1;\r\n \r\n}\r\n\r\nif (CCW === dir) {\r\n nextForm = activePc.form === 0 ? activePc.forms.length-1 : activePc.form-1;\r\n}\r\n let pivot = activePc.pivot;\r\n\r\n const builtForm = [activePc.pivot, ...activePc.forms[nextForm].map((block, idx) => {\r\n return [block[0] + pivot[0], block[1] + pivot[1]];\r\n })];\r\n\r\n const canHasRotate = builtForm.reduce((prev, block) => {\r\n if (!prev) { return prev }\r\n // check wall\r\n if (block[0] < 0 || block[0] >= board.length) { \r\n return false }\r\n if (block[1] < 0 || block[1] >= board[0].length) { \r\n return false }\r\n\r\n // check static\r\n if (board[block[0]][block[1]]) { \r\n return false }\r\n\r\n return prev\r\n }, true)\r\n\r\n return { form: canHasRotate ? nextForm : prevForm }\r\n} // canHasRotation\r\n\r\nexport { canHasRotation };","C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\useTetrisHooks\\useBoard.js",[],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\Dummy.js",[],["109","110"],"C:\\Users\\Hui\\desktop\\prog\\myProjs\\tetris\\src\\components\\Tetris\\assets\\lineBoard.js",[],{"ruleId":"111","replacedBy":"112"},{"ruleId":"113","replacedBy":"114"},{"ruleId":"115","severity":1,"message":"116","line":2,"column":17,"nodeType":"117","messageId":"118","endLine":2,"endColumn":26},{"ruleId":"115","severity":1,"message":"119","line":11,"column":16,"nodeType":"117","messageId":"118","endLine":11,"endColumn":23},{"ruleId":"120","severity":1,"message":"121","line":71,"column":8,"nodeType":"122","endLine":71,"endColumn":31,"suggestions":"123"},{"ruleId":"120","severity":1,"message":"124","line":90,"column":8,"nodeType":"122","endLine":90,"endColumn":26,"suggestions":"125"},{"ruleId":"115","severity":1,"message":"119","line":4,"column":26,"nodeType":"117","messageId":"118","endLine":4,"endColumn":33},{"ruleId":"120","severity":1,"message":"124","line":19,"column":8,"nodeType":"122","endLine":19,"endColumn":52,"suggestions":"126"},{"ruleId":"115","severity":1,"message":"127","line":11,"column":5,"nodeType":"117","messageId":"118","endLine":11,"endColumn":7},{"ruleId":"115","severity":1,"message":"128","line":2,"column":8,"nodeType":"117","messageId":"118","endLine":2,"endColumn":15},{"ruleId":"111","replacedBy":"129"},{"ruleId":"113","replacedBy":"130"},"no-native-reassign",["131"],"no-negated-in-lhs",["132"],"no-unused-vars","'useEffect' is defined but never used.","Identifier","unusedVar","'gamePcs' is defined but never used.","react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'dispatchBoard' and 'dropInt'. Either include them or remove the dependency array.","ArrayExpression",["133"],"React Hook useEffect has a missing dependency: 'dispatchBoard'. Either include it or remove the dependency array.",["134"],["135"],"'UP' is assigned a value but never used.","'produce' is defined but never used.",["131"],["132"],"no-global-assign","no-unsafe-negation",{"desc":"136","fix":"137"},{"desc":"138","fix":"139"},{"desc":"140","fix":"141"},"Update the dependencies array to be: [boardState.gameActive, dispatchBoard, dropInt]",{"range":"142","text":"143"},"Update the dependencies array to be: [boardState.board, dispatchBoard]",{"range":"144","text":"145"},"Update the dependencies array to be: [boardState.activePc, boardState.gameActive, dispatchBoard]",{"range":"146","text":"147"},[1734,1757],"[boardState.gameActive, dispatchBoard, dropInt]",[2352,2370],"[boardState.board, dispatchBoard]",[467,511],"[boardState.activePc, boardState.gameActive, dispatchBoard]"]