Skip to content

Instantly share code, notes, and snippets.

@Yougigun
Created February 4, 2021 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yougigun/3d38abf7f1d2906ad8bfd9c65f175e25 to your computer and use it in GitHub Desktop.
Save Yougigun/3d38abf7f1d2906ad8bfd9c65f175e25 to your computer and use it in GitHub Desktop.
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