/** * Just refctor code. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @param array $data * @param array $rows * @param array $hands */ public function exercuteGame(InputInterface $input, OutputInterface $output, $data, $rows, $hands) { $output->writeln($this->comment('Please wait...')); $this->sleep(); $table = new Table($output); $table->setHeaders(['Username', 'Hand']); $table->setRows($data); $table->render(); $judger = new Judge($hands, $rows); list($grade, $winners) = $judger->getAllMax(); $output->writeln($this->comment('The results were as follows:')); $this->sleep(); $output->writeln($this->getResult($grade, $winners)); }
public function test_can_get_winner_name_and_hand_category() { for ($i = 0; $i < 2; $i++) { $username = $this->faker->firstname; $hand = $this->generator->generateHand(); $hands[] = $hand; $rows[] = [$username, implode(' ', $hand)]; } $hands[] = ['AS', 'KS', 'QS', 'JS', 'TS']; $rows[] = ['RryLee', 'AS KS QS JS TS']; $rows[] = ['ChenXi', 'AS KS QS JS TS']; $judger = new Judge($hands, $rows); $excepted = ['Oh, gad, Straight flush', ['RryLee', 'ChenXi']]; $this->assertEquals($excepted, $judger->getAllMax()); }