示例#1
0
 $question_model->can_complete_game($game_id, $command_id);
 // Порции с вопросами
 $current_portions = $question_model->get_current_portions($game_id, $command_id);
 $next_portion = $question_model->get_next_portion($game_id, $command_id);
 // Если порций больше нет, то завершаем игру
 if (count($current_portions) == 0 && count($next_portion) == 0) {
     $game_model->complete_game($game_id, $command_id);
 }
 foreach ($current_portions as &$portion) {
     $portion['usedhelps'] = $question_model->get_used_helps($portion['question_id'], $command_id);
     $help = $question_model->try_get_next_help($portion['question_id'], $command_id, $portion['portion_sdate'], $portion['usedhelps'][count($portion['usedhelps']) - 1]['help_date']);
     // Обработка ПОСТов посказок
     if ($_POST['use_help'] && $help['result'] == "button") {
         $help_id = $_POST['help_id'] ? $_POST['help_id'] : 0;
         if ($help['help']['help_id'] == $help_id) {
             $question_model->use_help($help_id, $command_id);
             header("Location: game.php?game_id=" . $game_id);
             exit;
         }
         // 1. Получить из ПОСТа id подсказки
         // 2. Проверить я вляется ли она нужной подсказкой
         // 3. Если является то использовать.
     }
     $portion['status'] = "";
     if ($help == false) {
         $portion['status_help'] = "no";
     } else {
         if ($help['result'] == "success") {
             $question_model->use_help($help['help']['help_id'], $command_id);
             if ($portion['question_id'] == $help['help']['question_id']) {
                 $portion['usedhelps'][] = $help['help'];