function first_work($glob) { aff_client("first work OK"); $glob['list_action'] = add_action_place($glob['list_action'], name_to_arr("b_bouff_20")); $glob['list_action'] = add_action_place($glob['list_action'], name_to_arr("b_hello")); $glob['list_action'] = add_action_place($glob['list_action'], name_to_arr("b_fork")); return $glob; }
function dekrypte($glob, $message) { $info = explode($glob['del'], $message); $glob = update_info_friendz($glob, $info); if ($info[6] == 'hello :-)') { aff_client("Salut mec, soit le bienvenue !"); } return $glob; }
function send_msg_to_serv($glob, $msg) { aff_client($msg, $glob); $res = fputs($glob['fd'], $msg . "\n"); if ($res != FALSE) { return $msg; } else { aff_error_connect("MSG :" . $msg . " Not Send !"); return -1; } }
function init_message($glob) { $line = xfgets($glob); if ($line == "BIENVENUE") { aff_client("Nous sommes connecte"); } send_msg_to_serv($glob, $glob['equipe']); $glob['num_client'] = xfgets($glob); $arr_map = explode(' ', xfgets($glob)); $glob['map_x'] = $arr_map[0]; $glob['map_y'] = $arr_map[1]; return $glob; }
function error_to_go($glob, $obj) { aff_client("Pas de " . $obj . " devant moi, je pars en chercher"); if ($obj == 'b_bouff_20') { $rempl = 'b_go_bouf'; } else { if (strstr($obj, '_sg_') == TRUE) { $rempl = 'b_go_' . substr($obj, 5); } else { $rempl = $obj; } } $place_to_add = find_action_where_add($glob, $rempl); $arr = array(name_to_arr(rand_way()), name_to_arr($obj)); $glob['list_action'] = add_action_place($glob['list_action'], $arr, $place_to_add); return $glob; }
function call_my_egg($glob, $i) { aff_client("Fork resussit !"); $glob['time_to_fork'][$i]['done'] = 1; $to_send = "./client.php -n " . $glob['equipe'] . " -p " . $glob['port'] . " -h " . $glob['host']; exec($to_send . " > /dev/null &"); echo yellow(' :::::::::: :::::::: ::::::::: ::: ::: :::::::::: ::::::::: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ :#::+::# +#+ +:+ +#++:++#: +#++:++ +#++:++# +#+ +:+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# ### ######## ### ### ### ### ########## ######### '); return $glob; }
function b_go_bouf($glob) { /* 1 cherche le plus cours chemi 2 Build path vers bouf */ $case_to_go = find_shorter_way($glob['vision'], "nourriture", $glob['lvl']); if ($case_to_go > 0) { // on vas chercher le chemin pour aller manger $glob = build_way_to_go($glob, $case_to_go, "b_go_bouf"); return $glob; } else { if ($case_to_go == 0) { //On est sur la bonne case aff_client("Il y a de la nourriture sur ma case !"); return $glob; } else { $glob = error_to_go($glob, 'b_bouff_20'); // il n y a pas de bouf sur la case return $glob; } } aff_error_code("Out of go bouf"); }
function mort($glob) { aff_client("Haaggrrrr Je suis mort"); aff_client("closage du socket : ok"); exit; }