JavaScript连接四个游戏,需要帮助在某人获胜后停止游戏

JavaScript连接四个游戏,需要帮助在某人获胜后停止游戏,javascript,Javascript,这是一个连接四,我正在工作的游戏。问题是,如果你在某人获胜后点击棋盘,那么该人的得分(获胜次数)会不断上升,并播放“胜利之声”。我如何编辑我的代码,以便在某人获胜后单击棋盘时不会发生任何事情?这是学校里的一个项目,如果有人能帮助我,我会非常感激 //常数///////////////////////////////////// 常量winningConditions=[ //水平的 [35, 36, 37, 38], [36, 37, 38, 39], [37, 38, 39, 40], [3

这是一个连接四,我正在工作的游戏。问题是,如果你在某人获胜后点击棋盘,那么该人的得分(获胜次数)会不断上升,并播放“胜利之声”。我如何编辑我的代码,以便在某人获胜后单击棋盘时不会发生任何事情?这是学校里的一个项目,如果有人能帮助我,我会非常感激

//常数/////////////////////////////////////
常量winningConditions=[
//水平的
[35, 36, 37, 38],
[36, 37, 38, 39],
[37, 38, 39, 40],
[38, 39, 40, 41],
[28, 29, 30, 31],
[29, 30, 31, 32],
[30, 31, 32, 33],
[31, 32, 33, 34],
[21, 22, 23, 24],
[22, 23, 24, 25],
[23, 24, 25, 26],
[24, 25, 26, 27],
[14, 15, 16 ,17],
[15, 16, 17, 18],
[16, 17, 18, 19],
[17, 18, 19, 20],
[7, 8, 9 ,10],
[8, 9, 10, 11],
[9, 10, 11, 12],
[10, 11, 12, 13],
[0, 1, 2, 3],
[1, 2, 3, 4],
[2, 3, 4, 5],
[3, 4, 5, 6],
//垂直的
[35, 28, 21, 14],
[28, 21, 14, 7],
[21, 14, 7, 0],
[36, 29, 22, 15],
[29, 22, 15, 8],
[22, 15, 8, 1],
[37, 30, 23, 16],
[30, 23, 16, 9],
[23, 16, 9, 2],
[38, 31, 24, 17],
[31, 24, 17, 10],
[24, 17, 10, 3],
[39, 32, 25, 18],
[32, 25, 18, 11],
[25, 18, 11, 4],
[40, 33, 26, 19],
[33, 26, 19, 12],
[26, 19, 12, 5],
[41, 34, 27, 20],
[34, 27, 20, 13],
[27, 20, 13, 6],
//对角线(右)
[38, 32, 26, 20],
[37, 31, 25, 19],
[36, 30, 24, 18],
[35, 29, 23, 17],
[31, 25, 19, 13],
[30, 24, 18, 12],
[29, 23, 17, 11],
[28, 22, 16, 15],
[24, 18, 12, 6],
[23, 17, 11, 5],
[22, 16, 10, 4],
[21, 15, 9, 2],
//对角线(左)
[41, 33, 25, 17],
[40, 32, 24, 16],
[39, 31, 23, 15],
[38, 30, 22, 14],
[34, 26, 18, 10],
[33, 25, 27, 9],
[32, 24, 26, 8],
[31, 23, 25, 7],
[27, 19, 11, 3],
[26, 18, 10, 2],
[25, 17, 9, 1],
[24, 16, 8, 0]
];
/////////////////////应用程序状态(变量)/////////////////////////
让董事会;
让我们转身;
让我们赢;
设redWins=0;
让yellowWins=0;
设ties=0;
让我们先来;
让胜利者;
/////////////////////缓存的元素引用/////////////////////
const dots=Array.from(document.queryselectoral(#board div));
const message=document.querySelector(“h2”);
/////////////////////事件侦听器///////////////////////////////
window.onload=init;
document.getElementById(“board”).onclick=takeTurn;
document.getElementById(“重置按钮”).onclick=playreach;
document.getElementById(“redFirst”).onclick=redFirst;
document.getElementById(“yellowFirst”).onclick=yellowFirst;
document.getElementById(“重置记分板”).onclick=resetScoreboard;
/////////////////////功能/////////////////////////////////////
函数init(){
董事会=[
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
];
转向=“红色”
win=null
render();
}
函数render(){
board.forEach(功能(标记、索引){
点[索引]。文本内容=标记;
});
message.textContent=
赢===“T”?“这是平局!”:赢?${win}赢!`:`Turn:${Turn}`;
}
职能转变(e){
如果(e.target.id==“板”){
返回false;
}
如果(!赢){
让索引=点。findIndex(函数(点){
返回点===e.目标;
});
让行1=索引%7;
如果(板[索引]=“”){
而(单板[索引+7]=“”){
设i=指数+7;
document.getElementById(“点”+i+).classList.add(回合);
板[i]=转弯;
document.getElementById(“点”+索引+”).classList.remove(回合);
板[索引]=“”;
指数=i;
}
如果(板[索引]=“”){
document.getElementById(“点”+索引+”).classList.add(回合);
板[指数]=圈数;
}
}
else if(板[索引]!=“”){
如果(线路板[第1行]=“”){
同时(线路板[row1+7]=“”){
设i=row1+7;
document.getElementById(“点”+i+).classList.add(回合);
板[i]=转弯;
document.getElementById(“点”+行1+).classList.remove(回合);
董事会[第1行]=“”;
row1=i;
}
如果(线路板[第1行]=“”){
document.getElementById(“点”+行1+).classList.add(回合);
板[row1]=转弯;
}
}
else if(板[row1]!=“”){
返回false;
}
}
}
转弯=转弯==“红色”?“黄色”:“红色”;
win=getWinner();
如果(赢=“T”){
ties++;
document.getElementById(“tScore”).innerHTML=ties;
}
render();
}
函数getWinner(){
设winner=null;
winningConditions.forEach(函数(条件、索引){
如果(
电路板[条件[0]]&&
线路板[条件[0]]==线路板[条件[1]]&&
线路板[条件[1]]==线路板[条件[2]]&&
线路板[条件[2]]==线路板[条件[3]]
) {
获胜者=董事会[条件[0]];
如果(获胜者=“红色”){
redWins++;
document.getElementById(“redScore”).innerHTML=redWins;
playOKOK();
}
否则如果(获胜者==“黄色”){
yellowWins++;
document.getElementById(“yellowScore”).innerHTML=yellowWins;
playOKOK();
}
}
});
返回赢家?赢家:板。包括(“”)空:“T”;
}
函数playreach(){
board.forEach(功能(标记、索引){
if(点[index].classList.contains(“红色”)){
点[index].classList.remove(“红色”)
}
if(点[index].classList.contains(“黄色”)){
点[index].classList.remove(“黄色”)
}
});
init()
}
函数重置记分板(){
redWins=0;
yellowWins=0;
领带=0;
document.getElementById(“redScore”).innerHTML=redWins;
document.getElementById(“tScore”).innerHTML=ties;
document.getElementById(“yellowScore”).innerHTML=yellowWins;
}
函数redFirst(){
init();
再次播放();
document.getElementById(“turn”).innerHTML=“turn:Red”;
变为“红色”;
first=“Red”
}