Ejemplo n.º 1
0
function ft_incantation($socket, $lvl, $current, $move)
{
    ft_inventaire($socket);
    echo "lvl : " . $lvl . "\n";
    $nb_joueur = 0;
    foreach ($current as $data) {
        foreach ($data as $obj) {
            if ($obj == "joueur") {
                $nb_joueur++;
            }
        }
    }
    if ($GLOBALS['leveling'][$lvl - 1]["nb_joueur"] <= $nb_joueur) {
        ft_pose($socket, $lvl);
        socket_write($socket, "incantation\n");
        echo "incantation\n";
        $tmp = get_next_line_socket($socket, "incantation");
        if ($tmp != "ko\n") {
            get_next_line_socket($socket, "incantation");
            foreach ($GLOBALS['leveling'][$lvl - 1] as $key => $value) {
                if (isset($GLOBALS['stack'][$key])) {
                    $GLOBALS['stack'][$key] -= $value;
                }
            }
            return $lvl + 1;
        }
    }
    if ($move) {
        ft_move($socket, $current);
    }
    return $lvl;
}
Ejemplo n.º 2
0
function ft_play($socket, $map, $tbl)
{
    $pos = array("x" => 0, "y" => 0, "d" => 0);
    $lvl = 1;
    $current = 0;
    $i = 0;
    ft_inventaire($socket);
    while (42) {
        $tmp = ft_connect_nbr($socket);
        if ($tmp == 0 && $i == 0) {
            ft_fork($socket);
            $i++;
        } else {
            if ($tmp != 0 && $i < 2) {
                ft_dedouble($socket, $tbl);
                $i++;
            }
        }
        if ($current == 0) {
            $current = ft_see($socket);
        }
        ft_search($socket, $current, $lvl, "nourriture");
        ft_check_objectif($socket, $lvl, $current);
        if (ft_search_up($socket, $current, $lvl) == TRUE) {
            $lvl = ft_incantation($socket, $lvl, $current, TRUE);
        } else {
            ft_move($socket, $current);
        }
        $current = 0;
    }
}