|
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
|
|
|
{ |
|
16
|
|
|
public function testGetSkillType(): void |
|
17
|
|
|
{ |
|
18
|
|
|
$skillData = [ |
|
19
|
|
|
"id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5, |
|
20
|
|
|
"target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%", |
|
21
|
|
|
]; |
|
22
|
|
|
$skill = new SkillAttack($skillData); |
|
23
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 1); |
|
24
|
|
|
Assert::same("attack", $characterSkill->skillType); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testGetLevel(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$skillData = [ |
|
30
|
|
|
"id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5, |
|
31
|
|
|
"target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%", |
|
32
|
|
|
]; |
|
33
|
|
|
$skill = new SkillAttack($skillData); |
|
34
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 1); |
|
35
|
|
|
Assert::same(1, $characterSkill->level); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testGetDamage(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$skillData = [ |
|
41
|
|
|
"id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5, |
|
42
|
|
|
"target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%", |
|
43
|
|
|
]; |
|
44
|
|
|
$skill = new SkillAttack($skillData); |
|
45
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 1); |
|
46
|
|
|
Assert::same(120, $characterSkill->damage); |
|
47
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 5); |
|
48
|
|
|
Assert::same(128, $characterSkill->damage); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testGetHitRate(): void |
|
52
|
|
|
{ |
|
53
|
|
|
$skillData = [ |
|
54
|
|
|
"id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5, |
|
55
|
|
|
"target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => null, |
|
56
|
|
|
]; |
|
57
|
|
|
$skill = new SkillAttack($skillData); |
|
58
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 1); |
|
59
|
|
|
Assert::same(100, $characterSkill->hitRate); |
|
60
|
|
|
$skillData["hitRate"] = "80%"; |
|
61
|
|
|
$skill = new SkillAttack($skillData); |
|
62
|
|
|
$characterSkill = new CharacterAttackSkill($skill, 1); |
|
63
|
|
|
Assert::same(80, $characterSkill->hitRate); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$test = new CharacterAttackSkillTest(); |
|
68
|
|
|
$test->run(); |
|
69
|
|
|
|