<?php

namespace App\Forms;

use Nette;
use Nette\Application\UI\Form;
use Nette\Security\User;
use App;


class SubmitForm extends Nette\Object
{
    public $results = array();

    /** @var User */
    private $user;

    private $GameM;


    public function __construct(User $user, App\Model\GameManager $g)
    {
        $this->user = $user;
        $this->GameM = $g;

    }

    /**
     * @return Form
     */
    public function create()
    {
        $form = new Form;
        $form->addSubmit('send', 'Next stage')->setAttribute('id','send-input');
        $form->onSuccess[] = array($this, 'formSucceeded');
        return $form;
    }


    public function formSucceeded(Form $form, $values)
    {
        $stage = $this->GameM->GetStage($this->user->id);
        $this->GameM->MoveNextStage(1 + $stage, $this->user->id);
    }

}