Lines
100.00%
13 / 13
Methods
100.00%
4 / 4
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| follow | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 7 | ||
| changed | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 1 | ||
| learned | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| earned | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| 14 | final readonly class ClassTracking | |
| 15 | { | |
| 16 | public static function follow(HeroClass $class, Event $event, Identity $me): bool | |
| 17 | { | |
| 18 | return match (true) { | |
| 19 | $event instanceof ClassChangedEvent && $me->owns($event->player) => self::changed($class, $event), | |
| 20 | $event instanceof SkillsLoadedEvent => self::learned($class, $event), | |
| 21 | $event instanceof RewardedEvent && $event->classPoints->value > 0 => self::earned($class, $event), | |
| 22 | default => false, | |
| 23 | }; | |
| 24 | } | |
| 25 | ||
| 26 | private static function changed(HeroClass $class, ClassChangedEvent $event): bool | |
| 27 | { | |
| 28 | $class->change( | |
| 29 | new CharacterClass($event->className, $event->category, $event->description, [], []), | |
| 30 | $event->points, | |
| 31 | ); | |
| 32 | ||
| 33 | return true; | |
| 34 | } | |
| 35 | ||
| 36 | private static function learned(HeroClass $class, SkillsLoadedEvent $event): bool | |
| 37 | { | |
| 38 | $class->learn($event->skills, $event->passives); | |
| 39 | ||
| 40 | return true; | |
| 41 | } | |
| 42 | ||
| 43 | private static function earned(HeroClass $class, RewardedEvent $event): bool | |
| 44 | { | |
| 45 | $class->earn($event->classPoints); | |
| 46 | ||
| 47 | return true; | |
| 48 | } | |
| 49 | } |