|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace IVCalculator\Console\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use IVCalculator\IVCalculator; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Helper\Table; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
11
|
|
|
|
|
12
|
|
|
class AnalyzeCommand extends Command |
|
13
|
|
|
{ |
|
14
|
|
|
protected function configure() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->setName('analyze') |
|
17
|
|
|
->setDescription('Analyzes a pokemon.'); |
|
18
|
|
|
|
|
19
|
|
|
$this->addArgument('nameOrId', InputArgument::REQUIRED, 'The Pokemon\'s name or ID') |
|
20
|
|
|
->addArgument('CP', InputArgument::REQUIRED) |
|
21
|
|
|
->addArgument('HP', InputArgument::REQUIRED) |
|
22
|
|
|
->addArgument('dustCost', InputArgument::REQUIRED, 'Stardust needed for power up') |
|
23
|
|
|
->addArgument('neverUpgraded', InputArgument::OPTIONAL, ' Was powered up before?'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
27
|
|
|
{ |
|
28
|
|
|
$results = (new IVCalculator())->evaluate( |
|
29
|
|
|
$input->getArgument('nameOrId'), |
|
30
|
|
|
(int) $input->getArgument('CP'), |
|
31
|
|
|
(int) $input->getArgument('HP'), |
|
32
|
|
|
(int) $input->getArgument('dustCost'), |
|
33
|
|
|
$input->getArgument('neverUpgraded') == 'true' ? true : false |
|
34
|
|
|
); |
|
35
|
|
|
|
|
36
|
|
|
// Title |
|
37
|
|
|
$output->writeln('========================='); |
|
38
|
|
|
$output->writeln( |
|
39
|
|
|
sprintf( |
|
40
|
|
|
"%s (%.0f%%)", |
|
41
|
|
|
$results->get('name'), |
|
42
|
|
|
$results->get('perfection')->get('average') * 100 |
|
43
|
|
|
) |
|
44
|
|
|
); |
|
45
|
|
|
$output->writeln("=========================\n"); |
|
46
|
|
|
|
|
47
|
|
|
// IVs |
|
48
|
|
|
(new Table($output)) |
|
49
|
|
|
->setHeaders(array('Perfection', 'Attack IV', 'Defense IV', 'Stamina IV', 'Level')) |
|
50
|
|
|
->setRows($results->get('ivs')->map(function($iv) { |
|
51
|
|
|
return [ |
|
52
|
|
|
sprintf('%.0f%%', $iv->perfection * 100), |
|
53
|
|
|
$iv->attackIV, |
|
54
|
|
|
$iv->defenseIV, |
|
55
|
|
|
$iv->staminaIV, |
|
56
|
|
|
$iv->level |
|
57
|
|
|
]; |
|
58
|
|
|
})->toArray())->render(); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|