Example #1
0
 if ($chat_id != false) {
     $messages = $gamechat_model->get_messages($chat_id, 0);
     foreach ($messages as &$message) {
         $message['time'] = date('H:i', $message['time']);
     }
 } else {
     $provider_id = $gameprovider_model->get_privider_id_by_game_id($game_id);
     $chat_id = $gamechat_model->add_chat($game_id, $command_id, $provider_id);
 }
 // Активные юзеры
 $active_users = $command_model->get_active_users($command_id, $game_id);
 //$gameStart = date("M,d,Y,h:m:i", $gameInfo['game_sdate'] + 60*60*24*62);
 $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;
         }