Slash   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 12
c 2
b 0
f 0
dl 0
loc 41
ccs 9
cts 15
cp 0.6
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredWeaponMastery() 0 3 1
A getDescription() 0 3 1
A getRequiredTalentPoints() 0 3 1
A getName() 0 3 1
A getDamage() 0 5 1
A __toString() 0 3 1
A getEffects() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Build\Talent\WeaponMastery\ShortSword\Novice;
6
7
use AardsGerds\Game\Build\Attribute\Damage;
8
use AardsGerds\Game\Build\Talent\Effect\EffectCollection;
9
use AardsGerds\Game\Build\Talent\TalentPoints;
10
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMastery;
11
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMasteryLevel;
12
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMasteryTalent;
13
use AardsGerds\Game\Fight\MeleeAttack;
14
use AardsGerds\Game\Inventory\Weapon\Weapon;
15
use JetBrains\PhpStorm\Immutable;
16
17
#[Immutable]
18
final class Slash implements MeleeAttack, WeaponMasteryTalent
19
{
20
    private const MIN_DAMAGE_MULTIPLIER = 80;
21
    private const MAX_DAMAGE_MULTIPLIER = 110;
22
23 3
    public function getDamage(Weapon $weapon): Damage
24
    {
25 3
        $damageMultiplier = rand(self::MIN_DAMAGE_MULTIPLIER, self::MAX_DAMAGE_MULTIPLIER) / 100;
26
27 3
        return new Damage((int) round($weapon->getDamage()->get() * $damageMultiplier));
28
    }
29
30 3
    public function getEffects(): EffectCollection
31
    {
32 3
        return new EffectCollection([]);
33
    }
34
35 3
    public static function getName(): string
36
    {
37 3
        return 'Slash';
38
    }
39
40
    public static function getDescription(): string
41
    {
42
        return 'Standard slash with sword. Everyone can do it.';
43
    }
44
45
    public static function getRequiredTalentPoints(): TalentPoints
46
    {
47
        return new TalentPoints(1);
48
    }
49
50
    public static function getRequiredWeaponMastery(): WeaponMastery
51
    {
52
        return WeaponMastery::shortSword(WeaponMasteryLevel::novice());
53
    }
54
55 3
    public function __toString(): string
56
    {
57 3
        return self::getName();
58
    }
59
}
60