Conditions | 3 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 9 | public function qualifyBiom(PreviousLocationMap $previousLocations): Biom |
|
25 | { |
||
26 | 9 | $previousLocationsNumber = $previousLocations->count(); |
|
27 | 9 | $newBiomProbability = $previousLocationsNumber > 0 ? 50 - $previousLocationsNumber * 10 : 100; |
|
28 | 9 | $randomPercent = mt_rand(1, 100); |
|
29 | |||
30 | 9 | if ($randomPercent <= $newBiomProbability) { |
|
31 | 4 | return $this->getRandomBiom(); |
|
32 | } else { |
||
33 | 7 | $randomLocationKey = array_rand($previousLocations->getKeys()); |
|
34 | /** @var Location $randomLocation */ |
||
35 | 7 | $randomLocation = $previousLocations->get($randomLocationKey); |
|
36 | 7 | return $randomLocation->getBiom(); |
|
37 | } |
||
38 | } |
||
39 | |||
49 |