@@ -9,7 +9,6 @@ |
||
9 | 9 | namespace Chrl\AppBundle\GameAction; |
10 | 10 | |
11 | 11 | use Chrl\AppBundle\Entity\Game; |
12 | -use Chrl\AppBundle\Entity\Question; |
|
13 | 12 | |
14 | 13 | class StartAction extends BaseGameAction implements GameActionInterface |
15 | 14 | { |
@@ -15,17 +15,17 @@ |
||
15 | 15 | { |
16 | 16 | public function run($message, $user) |
17 | 17 | { |
18 | - /** @var Game $game */ |
|
18 | + /** @var Game $game */ |
|
19 | 19 | $game = $this->gameService->findGame($message); |
20 | 20 | |
21 | 21 | if ($game->status == 0) { |
22 | - $game->status = 1; |
|
23 | - $this->gameService->em->persist($game); |
|
24 | - $this->gameService->em->flush(); |
|
25 | - $this->botApi->sendMessage($message['chat']['id'], 'The game has started!'); |
|
26 | - } else { |
|
27 | - $this->botApi->sendMessage($message['chat']['id'], 'The game is already running...'); |
|
28 | - $question = $this->gameService->getRandomQuestion(); |
|
29 | - } |
|
22 | + $game->status = 1; |
|
23 | + $this->gameService->em->persist($game); |
|
24 | + $this->gameService->em->flush(); |
|
25 | + $this->botApi->sendMessage($message['chat']['id'], 'The game has started!'); |
|
26 | + } else { |
|
27 | + $this->botApi->sendMessage($message['chat']['id'], 'The game is already running...'); |
|
28 | + $question = $this->gameService->getRandomQuestion(); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | } |
@@ -36,46 +36,46 @@ |
||
36 | 36 | $this->id = $id; |
37 | 37 | } |
38 | 38 | |
39 | - /** |
|
40 | - * GUID Of the question -- unique |
|
41 | - * |
|
42 | - * @ORM\Column(type="string",length=32,unique=true) |
|
43 | - */ |
|
39 | + /** |
|
40 | + * GUID Of the question -- unique |
|
41 | + * |
|
42 | + * @ORM\Column(type="string",length=32,unique=true) |
|
43 | + */ |
|
44 | 44 | public $guid; |
45 | - /** |
|
46 | - * @ORM\Column(type="text") |
|
47 | - */ |
|
48 | - public $text; |
|
49 | - /** |
|
50 | - * @ORM\Column(type="text") |
|
51 | - */ |
|
52 | - public $a1; |
|
53 | - /** |
|
54 | - * @ORM\Column(type="text") |
|
55 | - */ |
|
56 | - public $a2; |
|
57 | - /** |
|
58 | - * @ORM\Column(type="text") |
|
59 | - */ |
|
60 | - public $a3; |
|
61 | - /** |
|
62 | - * @ORM\Column(type="text") |
|
63 | - */ |
|
64 | - public $a4; |
|
65 | - /** |
|
66 | - * @ORM\Column(type="integer") |
|
67 | - */ |
|
68 | - public $price; |
|
69 | - /** |
|
70 | - * @ORM\Column(type="integer") |
|
71 | - */ |
|
72 | - public $played; |
|
73 | - /** |
|
74 | - * @ORM\Column(type="integer") |
|
75 | - */ |
|
76 | - public $correct; |
|
77 | - /** |
|
78 | - * @ORM\Column(type="string", length=30) |
|
79 | - */ |
|
80 | - public $category; |
|
45 | + /** |
|
46 | + * @ORM\Column(type="text") |
|
47 | + */ |
|
48 | + public $text; |
|
49 | + /** |
|
50 | + * @ORM\Column(type="text") |
|
51 | + */ |
|
52 | + public $a1; |
|
53 | + /** |
|
54 | + * @ORM\Column(type="text") |
|
55 | + */ |
|
56 | + public $a2; |
|
57 | + /** |
|
58 | + * @ORM\Column(type="text") |
|
59 | + */ |
|
60 | + public $a3; |
|
61 | + /** |
|
62 | + * @ORM\Column(type="text") |
|
63 | + */ |
|
64 | + public $a4; |
|
65 | + /** |
|
66 | + * @ORM\Column(type="integer") |
|
67 | + */ |
|
68 | + public $price; |
|
69 | + /** |
|
70 | + * @ORM\Column(type="integer") |
|
71 | + */ |
|
72 | + public $played; |
|
73 | + /** |
|
74 | + * @ORM\Column(type="integer") |
|
75 | + */ |
|
76 | + public $correct; |
|
77 | + /** |
|
78 | + * @ORM\Column(type="string", length=30) |
|
79 | + */ |
|
80 | + public $category; |
|
81 | 81 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | |
9 | 9 | class QuestionAskerCommand extends EndlessCommand |
10 | 10 | { |
11 | - // This is just a normal Command::configure() method |
|
12 | - protected function configure() |
|
13 | - { |
|
14 | - $this->setName('buktopuha:questionbot') |
|
15 | - ->setDescription('Endless process that monitors time and asks questions') |
|
16 | - ->setTimeout(1); |
|
17 | - } |
|
11 | + // This is just a normal Command::configure() method |
|
12 | + protected function configure() |
|
13 | + { |
|
14 | + $this->setName('buktopuha:questionbot') |
|
15 | + ->setDescription('Endless process that monitors time and asks questions') |
|
16 | + ->setTimeout(1); |
|
17 | + } |
|
18 | 18 | |
19 | - // Execute will be called in a endless loop |
|
20 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
21 | - { |
|
19 | + // Execute will be called in a endless loop |
|
20 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
21 | + { |
|
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
@@ -84,16 +84,16 @@ |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | public function getRandomQuestion() |
87 | - { |
|
88 | - $count = $this->em->createQueryBuilder() |
|
89 | - ->select('COUNT(u)')->from('AppBundle:Question','u') |
|
90 | - ->getQuery() |
|
91 | - ->getSingleScalarResult(); |
|
92 | - |
|
93 | - return $this->em->createQuery('SELECT c FROM AppBundle:Question c ORDER BY c.id ASC') |
|
94 | - ->setFirstResult(rand(0, $count - 1)) |
|
95 | - ->setMaxResults(1) |
|
96 | - ->getSingleResult(); |
|
97 | - |
|
98 | - } |
|
87 | + { |
|
88 | + $count = $this->em->createQueryBuilder() |
|
89 | + ->select('COUNT(u)')->from('AppBundle:Question','u') |
|
90 | + ->getQuery() |
|
91 | + ->getSingleScalarResult(); |
|
92 | + |
|
93 | + return $this->em->createQuery('SELECT c FROM AppBundle:Question c ORDER BY c.id ASC') |
|
94 | + ->setFirstResult(rand(0, $count - 1)) |
|
95 | + ->setMaxResults(1) |
|
96 | + ->getSingleResult(); |
|
97 | + |
|
98 | + } |
|
99 | 99 | } |
@@ -86,7 +86,7 @@ |
||
86 | 86 | public function getRandomQuestion() |
87 | 87 | { |
88 | 88 | $count = $this->em->createQueryBuilder() |
89 | - ->select('COUNT(u)')->from('AppBundle:Question','u') |
|
89 | + ->select('COUNT(u)')->from('AppBundle:Question', 'u') |
|
90 | 90 | ->getQuery() |
91 | 91 | ->getSingleScalarResult(); |
92 | 92 |