This commit is contained in:
Gnieark 2016-06-23 23:56:18 +02:00
parent b403c053e7
commit df7f2dc1bb

View File

@ -43,7 +43,17 @@ function hash_map($map,$me,$opponent){
return base_convert($hashMap, 3, 10); return base_convert($hashMap, 3, 10);
} }
function remenber_previous_lap_is_a_bullshit(){
global $params, $lnMySQL;
mysqli_query($lnMySQL,
"INSERT INTO battleshipLearn(map, dont_play_col)
SELECT battleship_current.map, battleship_current.play_at
FROM battleship_current
WHERE battleship_current.game_id='".mysqli_real_escape_string($lnMySQL,$params['game-id'])."'
AND battleship_current.player_index='".mysqli_real_escape_string($lnMySQL,$params['player-index'])."';"
);
}
function play($map,$colToPlay,$me,$opponent,$gameid,$player_index){ function play($map,$colToPlay,$me,$opponent,$gameid,$player_index){
global $lnMySQL; global $lnMySQL;
@ -372,6 +382,7 @@ switch($params['action']){
} }
if(count($colAvailable) == 0){ if(count($colAvailable) == 0){
//on risque de perdre au prochain tour //on risque de perdre au prochain tour
remenber_previous_lap_is_a_bullshit();
for($i=0;$i<7;$i++){ for($i=0;$i<7;$i++){
if(($params['board'][5][$i] == "+") OR ($params['board'][5][$i] == "-")){ if(($params['board'][5][$i] == "+") OR ($params['board'][5][$i] == "-")){
$colAvailable[]=$i; $colAvailable[]=$i;
@ -388,6 +399,7 @@ switch($params['action']){
die; die;
}else{ }else{
//on pourra perdre au prochain tour, tant pis //on pourra perdre au prochain tour, tant pis
remenber_previous_lap_is_a_bullshit();
shuffle($choice['colForNoLose']); shuffle($choice['colForNoLose']);
play($params['board'],$choice['colForNoLose'][0],$params['you'],$opponent,$params['game-id'],$params['player-index']); play($params['board'],$choice['colForNoLose'][0],$params['you'],$opponent,$params['game-id'],$params['player-index']);
die; die;