Lines
100.00%
4 / 4
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Chances | 100.00% | 4 / 4 | 100.00% | 2 / 2 | 5 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| update | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 4 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Core\Game\Attribute\Stat\Chance; | |
| 6 | ||
| 7 | final class Chances | |
| 8 | { | |
| 9 | public function __construct( | |
| 10 | public private(set) HitChance $hit = new HitChance(0.9), | |
| 11 | public private(set) CriticalChance $critical = new CriticalChance(0.05), | |
| 12 | public private(set) Evasion $evasion = new Evasion(0.04), | |
| 13 | ) {} | |
| 14 | ||
| 15 | /** @mago-expect analysis:match-not-exhaustive */ | |
| 16 | public function update(Chance $stat): void | |
| 17 | { | |
| 18 | match (true) { | |
| 19 | $stat instanceof HitChance => $this->hit = $stat, | |
| 20 | $stat instanceof CriticalChance => $this->critical = $stat, | |
| 21 | $stat instanceof Evasion => $this->evasion = $stat, | |
| 22 | }; | |
| 23 | } | |
| 24 | } |