Created
February 4, 2021 16:03
-
-
Save Yougigun/3d38abf7f1d2906ad8bfd9c65f175e25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
const ChineseChessTable = ({Size,CarPos}) => { | |
let tableTD =[] | |
let table = [] | |
let tdOfCar = [] | |
for (let y = 0;y<=Size.y;y++){ | |
tableTD.push(<td></td>) | |
} | |
for (let y = 0;y<=Size.y;y++){ | |
if (CarPos.y === y) { | |
tdOfCar.push(<td>車</td>) | |
} else { | |
tdOfCar.push(<td></td>) | |
} | |
} | |
for (let x = 0;x<=Size.x;x++){ | |
if (CarPos.x === x) { | |
table.push((<tr>{tdOfCar}</tr>)) | |
} else { | |
table.push((<tr>{tableTD}</tr>)) | |
} | |
} | |
return ( | |
<div> | |
{table} | |
</div> | |
) | |
} | |
export default ChineseChessTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment