From 2346bfa24288565f5fd4d7c7ca96e297d56c6b45 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 18 Dec 2015 21:45:00 +0100 Subject: [PATCH] loop --- src/arenas/Battleship/act.php | 8 +++++++- src/arenas/Battleship/js.js | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/act.php b/src/arenas/Battleship/act.php index 29c26cd..c106b98 100644 --- a/src/arenas/Battleship/act.php +++ b/src/arenas/Battleship/act.php @@ -268,10 +268,16 @@ switch ($_POST['act']){ 'target' => $x.",".$y, 'result' => $result ); + if(count( $_SESSION['strikes'][$currentPlayer]) < 10){ + $continue=1; + }else{ + $continue=0; + } echo json_encode(array( 'opponent'=> $opponent, 'target' => $x.",".$y, - 'log' => $currentBot['name']."tire en ".$x.",".$y." ".$result + 'log' => $currentBot['name']."tire en ".$x.",".$y." ".$result, + 'continue' => $continue )); die; diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 7f0f8ff..679ff4d 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -36,7 +36,10 @@ function fight(xd_check){ var p=createElem("p"); p.innerHTML=strike['log']; document.getElementById('logs').appendChild(p); - //fight(xd_check); + + if( strike['continue'] == 1){ + fight(xd_check); + } }