Example #1
0
function update_oko_ans($glob, $name, $ans)
{
    $last_waiting_ans = find_last_waiting_ans($glob);
    if ($name == "ok") {
        $glob['list_action'][$last_waiting_ans]['waiting_answer'] = 1;
        $glob['time_c'] += 7;
        $glob['bouff_c'] -= 7;
        if ($glob['list_action'][$last_waiting_ans]['nom_action'] == 'send_fork') {
            $glob['time_c'] += 35;
            $glob['bouff_c'] -= 35;
            $arr_f = array("next" => $glob['time_c'] + 601, "done" => 0);
            array_push($glob['time_to_fork'], $arr_f);
        }
    } else {
        if ($name == "ko") {
            $glob['list_action'][$last_waiting_ans]['waiting_answer'] = 2;
            $glob['list_action'][$last_waiting_ans]['pb'] = 1;
            $glob['time_c'] += 7;
            $glob['bouff_c'] -= 7;
            if ($glob['list_action'][$last_waiting_ans]['nom_action'] == 'send_fork') {
                $glob['time_c'] += 35;
                $glob['bouff_c'] -= 35;
            }
        } else {
            aff_error_code("reponse impossible");
        }
    }
    return $glob;
}
Example #2
0
function set_last_waiting_ans($glob, $name, $ans)
{
    $last_waiting_ans = find_last_waiting_ans($glob);
    $name_action_await = name_awaiting_ans($glob);
    if ($name == "ok" || $name == "ko") {
        $glob = update_oko_ans($glob, $name, $ans);
    } else {
        if ($name_action_await == $name) {
            if ($name == "inventaire") {
                $glob['time_c'] += 1;
                $glob['bouff_c']--;
            } else {
                if ($name == "incantation") {
                    $glob['time_c'] += 300;
                    $glob['bouff_c'] -= 300;
                } else {
                    if ($name == "voir") {
                        $glob['time_c'] += +7;
                        $glob['bouff_c'] -= 7;
                    } else {
                        aff_error_code("message recu incomprhenssible: : " . $name);
                    }
                }
            }
            $glob['list_action'][$last_waiting_ans]['waiting_answer'] = 1;
        } else {
            aff_error_code("Decalage entre message serveur attente client");
        }
    }
    return $glob;
}