1 | <?php |
||
13 | class Evaluator |
||
14 | { |
||
15 | use InteractsWithFiles; |
||
16 | |||
17 | /** |
||
18 | * @var Collection |
||
19 | */ |
||
20 | private $potentialLevels; |
||
21 | |||
22 | /** |
||
23 | * @var Collection |
||
24 | */ |
||
25 | private $potentialHPIVs; |
||
26 | |||
27 | /** |
||
28 | * @var Collection |
||
29 | */ |
||
30 | private $potentialIVs; |
||
31 | |||
32 | /** |
||
33 | * @var Collection |
||
34 | */ |
||
35 | protected $levelUpData; |
||
36 | |||
37 | public function __construct() |
||
45 | |||
46 | /** |
||
47 | * @param Pokemon $pokemon |
||
48 | * @param $cp |
||
49 | * @param $hp |
||
50 | * @param $dustCost |
||
51 | * @param bool $neverUpgraded |
||
52 | * |
||
53 | * @return Evaluation |
||
54 | */ |
||
55 | public function process(Pokemon $pokemon, $cp, $hp, $dustCost, $neverUpgraded = false) |
||
63 | |||
64 | /** |
||
65 | * @param $dustCost |
||
66 | * @param $neverUpgraded |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | private function findPotentialLevels($dustCost, $neverUpgraded) |
||
84 | |||
85 | /** |
||
86 | * @param Pokemon $pokemon |
||
87 | * @param $hp |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | private function findPotentialHPIVs(Pokemon $pokemon, $hp) |
||
92 | { |
||
93 | foreach ($this->potentialLevels as $data) { |
||
94 | $level = new Level($data->level, $data->dust, $data->candy, $data->cpScalar); |
||
95 | |||
96 | foreach (range(0, 15) as $staminaIV) { |
||
97 | if ($this->testHP($pokemon, $level, $hp, $staminaIV)) { |
||
98 | $hpiv = new HPIV($level, $staminaIV); |
||
99 | |||
100 | $this->potentialHPIVs->push($hpiv); |
||
101 | } |
||
102 | } |
||
103 | } |
||
104 | |||
105 | return $this; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param Pokemon $pokemon |
||
110 | * @param $cp |
||
111 | * |
||
112 | * @return $this |
||
113 | */ |
||
114 | private function findPotentialIVs(Pokemon $pokemon, $cp) |
||
115 | { |
||
116 | foreach ($this->potentialHPIVs as $hpiv) { |
||
117 | foreach (range(0, 15) as $attackIV) { |
||
118 | foreach (range(0, 15) as $defenseIV) { |
||
119 | if ($this->testCP($pokemon, $hpiv->level, $cp, $attackIV, $defenseIV, $hpiv->staminaIV)) { |
||
120 | $iv = new IV($attackIV, $defenseIV, $hpiv->staminaIV, $hpiv->level->level); |
||
121 | |||
122 | $this->potentialIVs->push($iv); |
||
123 | } |
||
124 | } |
||
125 | } |
||
126 | } |
||
127 | |||
128 | return $this; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param Pokemon $pokemon |
||
133 | * @param Level $level |
||
134 | * @param $cp |
||
135 | * @param $attackIV |
||
136 | * @param $defenseIV |
||
137 | * @param $staminaIV |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | private function testCP(Pokemon $pokemon, Level $level, $cp, $attackIV, $defenseIV, $staminaIV) |
||
150 | |||
151 | /** |
||
152 | * @param Pokemon $pokemon |
||
153 | * @param Level $level |
||
154 | * @param $hp |
||
155 | * @param $staminaIV |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | private function testHP(Pokemon $pokemon, Level $level, $hp, $staminaIV) |
||
163 | } |
||
164 |