-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.php
More file actions
32 lines (25 loc) Β· 890 Bytes
/
cli.php
File metadata and controls
32 lines (25 loc) Β· 890 Bytes
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
<?php
require 'src/Fighter.php';
$hercules = new Fighter('π§ Hercules', 20, 6);
$lion = new Fighter('π¦ Lion de NΓ©mΓ©e', 11, 13);
$i = 1;
while ($hercules->isAlive() && $lion->isAlive()) {
echo 'π Round #' . $i . PHP_EOL;
$hercules->fight($lion);
echo $hercules->getName() . ' π‘οΈ ' . $lion->getName();
echo ' π ' . $lion->getName() . ': ' . $lion->getLife() . PHP_EOL;
$lion->fight($hercules);
echo $lion->getName() . ' π‘οΈ ' . $hercules->getName();
echo ' π ' . $hercules->getName() . ': ' . $hercules->getLife() . PHP_EOL;
$i++;
}
if (!$hercules->isAlive()) {
$winner = $lion;
$loser = $hercules;
} else {
$winner = $hercules;
$loser = $lion;
}
echo PHP_EOL;
echo 'π ' . $loser->getName() . ' is dead' . PHP_EOL;
echo 'π ' . $winner->getName() . ' wins (π ' . $winner->getLife() . ')' . PHP_EOL;