-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeast.php
More file actions
77 lines (68 loc) · 1.67 KB
/
Copy pathBeast.php
File metadata and controls
77 lines (68 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
class Beast implements Battlers
{
private $health;
private $strength;
private $defence;
private $speed;
private $luck;
public function __construct()
{
$this->health = rand(60,90);
$this->strength = rand(60,90);
$this->defence = rand(40,60);
$this->speed = rand(40,60);
$this->luck = rand(25,40);
}
/**
* @return int
*/
public function getHealth(): int
{
return $this->health;
}
/**
* @return int
*/
public function getStrength(): int
{
return $this->strength;
}
/**
* @return int
*/
public function getSpeed(): int
{
return $this->speed;
}
/**
* @return int
*/
public function getLuck(): int
{
return $this->luck;
}
public function takeDamage(int $attack){
if($attack > $this->defence){
$this->health = $this->health - ($attack - $this->defence);
echo("Beast takes ".($attack - $this->defence)." damage\n");
echo("Beast now has ".$this->health." hp\n");
}
else{
echo("Beast takes no damage.");
}
}
public function dealDamage(Battlers $enemy){
$enemy->takeDamage($this->getStrength());
}
public function writeStats(){
echo("-----------------------------\n");
echo("Beast stats:\n");
echo("Health: ".$this->health."\n");
echo("Strength: ".$this->strength."\n");
echo("Defense: ".$this->defence."\n");
echo("Speed: ".$this->speed."\n");
echo("Luck: ".$this->luck."%\n");
echo("-----------------------------\n");
}
}