This commit is contained in:
gnieark 2016-05-14 22:53:46 +02:00
parent 2db615e44e
commit 6b10980a86

View File

@ -18,7 +18,7 @@ function createElem(type,attributes){
{elem.setAttribute(i,attributes[i]);} {elem.setAttribute(i,attributes[i]);}
return elem; return elem;
} }
function connectFour(bot1,bot2,xd_check){ function connectFour(bot1,bot2,xd_check, newGame=true){
document.getElementById('fightResult').innerHTML = ''; document.getElementById('fightResult').innerHTML = '';
//create grid //create grid
@ -48,6 +48,9 @@ function connectFour(bot1,bot2,xd_check){
if( reponse['strikeX'] > -1){ if( reponse['strikeX'] > -1){
document.getElementById('td' + reponse['strikeX'] + '-' + reponse['strikeY']).innerHTML=reponse['strikeSymbol']; document.getElementById('td' + reponse['strikeX'] + '-' + reponse['strikeY']).innerHTML=reponse['strikeSymbol'];
} }
if(reponse['continue'] == 1){
connectFour(bot1,bot2,xd_check, false);
}
}else{ }else{
@ -57,5 +60,10 @@ function connectFour(bot1,bot2,xd_check){
}}; }};
xhr.open("POST", '/connectFour', true); xhr.open("POST", '/connectFour', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if(newGame){
var act=newFight;
}else{
var act=fight;
}
xhr.send('act=newFight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check); xhr.send('act=newFight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
} }