<?php

namespace App\Presenters;

use Nette;
use App\Model;
use App\Forms;


class FirstPresenter extends SecureBasePresenter
{

	/**
	 * @inject
	 * @var \App\Forms\FirstFormFactory
	 */
	public $factory;
	
	/**
	 * @inject
	 * @var \App\Model\GameManager
	 */
	public $GameM;

	/**
	 * Faze form factory.
	 * @return Nette\Application\UI\Form
	 */
	public function createComponentFirstForm()
	{
		$form = $this->factory->create();
        $form->onSuccess[] = function ($form) {
            $form->getPresenter()->redirect('Second:Default');
        };
		return $form;
	}

	public function renderDefault()
	{
        $guilty = $this->GameM->GetGuilty($this->user->id);
	    $this->template->judging = $guilty;

	}
	
	public function actionDefault()
    {
        $stage = $this->GameM->GetStage($this->user->id);

        if ($stage != 1) {
            $this->flashMessage("The case is closed. You have been redirected to summary.");
            $this->redirect('Second:Default');
        }
    }


}
