/**
  * @inheritDoc
  */
 public function preSubmit(FormEvent $event)
 {
     $gameMatch = $event->getData();
     if (isset($gameMatch['computerChoice'])) {
         $gameMatch['computerChoice'] = $this->moveProvider->getRandomMove();
     }
     $event->setData($gameMatch);
 }
 /**
  * @param integer $choice
  *
  * @return string
  */
 public function getChoiceName($choice)
 {
     return $this->moveProvider->getMoveName($choice);
 }
Ejemplo n.º 3
0
 /**
  * @inheritDoc
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('playerChoice', 'choice', ['label' => false, 'required' => true, 'choices' => $this->moveProvider->getAllMoves()]);
     $builder->add('computerChoice', 'hidden', []);
     $builder->addEventSubscriber(new GameFormSubscriber($this->moveProvider));
 }