import React, { useState, useCallback, useEffect } from “react”;
import “./index.css”
export default () => {
const [begin, setBegin] = useState(false)
const [figure, setFigure] = useState(true)
const [ids, setId] = useState<Array>([])
const [time, setTime] = useState(30)
let data = new Array(16).fill(16).map((v, i) => {
return new Array(16).fill(16).map((o, k) => {
return (i*16 + k) + 1
})
})
const handlClick = (e:any) => {
if(!begin) return
if(e.target.innerText == ‘’) {
let successOrFailure:boolean
if(figure){
e.target.innerText = “o”
e.target.style.color = “red”
setId([…ids, e.target.id])
setFigure(false)
successOrFailure = onVictory(e.target.id, e.target.innerText)
}else{
e.target.innerText = “x”
setId([…ids, e.target.id])
setFigure(true)
successOrFailure = onVictory(e.target.id, e.target.innerText)
}
if(successOrFailure) alert(figure?‘红方胜利’:‘蓝方胜利’)
setTime(30)
}else{
return
}
}
const onRevocation = () => {
if(ids.length < 1) return
const tr = document.getElementById(ids[ids.length-1])
if(tr) {
tr.innerText = ''
tr.style.color = ''
ids.pop()
setFigure(