@@ 22-52 (lines=31) @@ | ||
19 | * @param float $trainer the level of the the trainer |
|
20 | * @return int dusts to max the pokemon |
|
21 | */ |
|
22 | public static function dustsToMax(float $pokemon, float $trainer) |
|
23 | { |
|
24 | $trainer += 1.5; |
|
25 | $loop = $pokemon; |
|
26 | $dusts = 0; |
|
27 | ||
28 | if ($pokemon >= $trainer) { |
|
29 | return 0; |
|
30 | } |
|
31 | ||
32 | if ($trainer > 40) { |
|
33 | $trainer = 40; |
|
34 | } |
|
35 | ||
36 | $levels = (new LevelExtractor()) |
|
37 | ->getIntervalLevelFiltered($pokemon, $trainer); |
|
38 | ||
39 | $levels |
|
40 | ->each(function ($level) use (&$dusts, &$loop, $trainer) { |
|
41 | $loop += 0.5; |
|
42 | $dusts += $level->dust * 2; |
|
43 | }); |
|
44 | ||
45 | if ($pokemon*2 % 2 === 1) { |
|
46 | $dusts -= $levels->first()->dust; |
|
47 | } |
|
48 | ||
49 | $dusts -= $levels->last()->dust; |
|
50 | ||
51 | return $dusts; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Method to calculate how many candies are necessary to max a pokemon |
|
@@ 60-90 (lines=31) @@ | ||
57 | * @param float $trainer the level of the the trainer |
|
58 | * @return int dusts to max the pokemon |
|
59 | */ |
|
60 | public static function candiesToMax(float $pokemon, float $trainer) |
|
61 | { |
|
62 | $trainer += 1.5; |
|
63 | $loop = $pokemon; |
|
64 | $candies = 0; |
|
65 | ||
66 | if ($pokemon >= $trainer) { |
|
67 | return 0; |
|
68 | } |
|
69 | ||
70 | if ($trainer > 40) { |
|
71 | $trainer = 40; |
|
72 | } |
|
73 | ||
74 | $levels = (new LevelExtractor()) |
|
75 | ->getIntervalLevelFiltered($pokemon, $trainer); |
|
76 | ||
77 | $levels |
|
78 | ->each(function ($level) use (&$candies, &$loop, $trainer) { |
|
79 | $loop += 0.5; |
|
80 | $candies += $level->candy * 2; |
|
81 | }); |
|
82 | ||
83 | if ($pokemon*2 % 2 === 1) { |
|
84 | $candies -= $levels->first()->candy; |
|
85 | } |
|
86 | ||
87 | $candies -= $levels->last()->candy; |
|
88 | ||
89 | return $candies; |
|
90 | } |
|
91 | ||
92 | /** |
|
93 | * Method to calculate the CP with stats |