Passed
Push — master ( bc69e6...465240 )
by Jakub
12:35
created

CharacterAttackSkillTest::testGetHitRate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 12
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace HeroesofAbenez\Combat;
5
6
require __DIR__ . "/../../bootstrap.php";
7
8
use Tester\Assert;
9
10
/**
11
 * @author Jakub Konečný
12
 * @testCase
13
 */
14
final class CharacterAttackSkillTest extends \Tester\TestCase {
15
  public function testGetSkillType(): void {
16
    $skillData = [
17
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
18
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
19
    ];
20
    $skill = new SkillAttack($skillData);
21
    $characterSkill = new CharacterAttackSkill($skill, 1);
22
    Assert::same("attack", $characterSkill->skillType);
23
  }
24
  
25
  public function testGetLevel(): void {
26
    $skillData = [
27
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
28
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
29
    ];
30
    $skill = new SkillAttack($skillData);
31
    $characterSkill = new CharacterAttackSkill($skill, 1);
32
    Assert::same(1, $characterSkill->level);
33
  }
34
  
35
  public function testGetDamage(): void {
36
    $skillData = [
37
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
38
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
39
    ];
40
    $skill = new SkillAttack($skillData);
41
    $characterSkill = new CharacterAttackSkill($skill, 1);
42
    Assert::same(120, $characterSkill->damage);
43
    $characterSkill = new CharacterAttackSkill($skill, 5);
44
    Assert::same(128, $characterSkill->damage);
45
  }
46
  
47
  public function testGetHitRate(): void {
48
    $skillData = [
49
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
50
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => null,
51
    ];
52
    $skill = new SkillAttack($skillData);
53
    $characterSkill = new CharacterAttackSkill($skill, 1);
54
    Assert::same(100, $characterSkill->hitRate);
55
    $skillData["hitRate"] = "80%";
56
    $skill = new SkillAttack($skillData);
57
    $characterSkill = new CharacterAttackSkill($skill, 1);
58
    Assert::same(80, $characterSkill->hitRate);
59
  }
60
}
61
62
$test = new CharacterAttackSkillTest();
63
$test->run();
64
?>