diff --git a/attack.php b/attack.php
new file mode 100644
index 0000000..9ddf31c
--- /dev/null
+++ b/attack.php
@@ -0,0 +1,155 @@
+health < 0) || ($playerTwo->health < 0)) {
+ echo "end of game";
+ header('Location: ./resultat.php');
+ }
+}
+if (($_SERVER['REQUEST_METHOD'] == 'POST') && !isset($_POST['attaque']) && !isset($_POST['soin'])) {
+
+ $playerOne = new Player($_POST['player-name'], $_POST['player-attaque'], $_POST['player-mana'], $_POST['player-sante']);
+ $playerTwo = new Player($_POST['adversaire-name'], $_POST['adversaire-attaque'], $_POST['adversaire-mana'], $_POST['adversaire-sante']);
+ $_SESSION['player1'] = $playerOne;
+ $_SESSION['player2'] = $playerTwo;
+}
+// $_SESSION['fight'] = true;
+if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['attaque'])) {
+ $playerOne = $_SESSION['player1'];
+ $playerTwo = $_SESSION['player2'];
+ // while ($playerOne->getLifeStatus() && $playerTwo->getLifeStatus())
+ $playerOne->attack($playerTwo);
+ $_SESSION['player2'] = $playerTwo;
+
+ if ($playerTwo->health < 0) {
+ echo "end of game";
+ header('Location: ./resultat.php');
+ }
+ if ($playerTwo->health < 30) {
+ $iscured = $playerTwo->cure();
+ if ($iscured === false) {
+ $playerTwo->attack();
+ }
+ } else {
+ $playerTwo->attack($playerOne);
+ $_SESSION['player1'] = $playerOne;
+ if ($playerOne->health < 0) {
+ echo "end of game";
+ header('Location: ./resultat.php');
+ }
+ }
+}
+if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['soin'])) {
+ $playerOne = $_SESSION['player1'];
+ $playerTwo = $_SESSION['player2'];
+ $isCured = $playerOne->cure();
+ if ($isCured === false) {
+ return;
+ } else {
+ $playerTwo->attack($playerOne);
+ $_SESSION['player1'] = $playerOne;
+
+ if ($playerOne->health < 0) {
+ echo "end of game";
+ header('Location: ./resultat.php');
+ }
+ }
+}
+?>
+
+
+
Match
+
+
+

+
+
+
+
+ - Name : = $playerOne->name ?>
+ - Attaque : = $playerOne->power ?>
+ - Mana : = $playerOne->mana ?>
+ - Vie : = $playerOne->health ?>
+
+
+
+
+
+

+
+
+
+
+ - Name : = $playerTwo->name ?>
+ - Attaque : = $playerTwo->power ?>
+ - Mana : = $playerTwo->mana ?>
+ - Vie : = $playerTwo->health ?>
+
+
+
+
+
Combat
+
+
+
+ comment)) { ?>
+ - = $playerOne->comment ?>
+ comment)) { ?>
+ - = $playerTwo->comment ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/classes/player.class.php b/classes/player.class.php
new file mode 100644
index 0000000..ebe8f6c
--- /dev/null
+++ b/classes/player.class.php
@@ -0,0 +1,59 @@
+name = $name;
+ $this->power = $power;
+ $this->mana = $mana;
+ $this->health = $health;
+ }
+ public function attack(Player $player)
+ {
+ $damage = $this->power / 4;
+ $player->health -= $damage;
+ $this->comment = "$this->name attaque $player->name et lui inflige $damage de dégats \r \n";
+ // $damage = $player->power / 20;
+ // $this->health -= $damage;
+ // echo " \r \n $player->name réplique et inflige $damage de dégat à $this->name.";
+ }
+
+
+ public function cure()
+ {
+ if ($this->mana > 0) {
+
+ $this->health += (($this->mana / 20) + 10);
+ $this->mana /= 4;
+ $this->mana -= 1;
+ $this->comment = "$this->name s'est soigné";
+ return $this;
+ } else {
+ $this->comment = "$this->name n'a plus assez de mana pour se soigner";
+ return false;
+ }
+ }
+}
+
+
+class Fight
+{
+ public object $player1;
+ public object $player2;
+
+ public function __construct(Player $player1, Player $player2 = null)
+ {
+ $this->player1 = $player1;
+ $this->player2 = $player2;
+ }
+
+ public function stopMatch()
+ {
+ }
+}
diff --git a/index.php b/index.php
index 76440eb..447348a 100644
--- a/index.php
+++ b/index.php
@@ -1,49 +1,49 @@
+
+
Battle
-
-
+
+
-
-
-
-
-
Battle
+
+
+
+
+
Battle
@@ -76,134 +76,56 @@
-
-
Match
-
-
-

-
-
-
- - Name :
- - Attaque :
- - Mana :
-
-
-
-
-
-

-
-
-
- - Name :
- - Attaque :
- - Mana :
-
-
-
-
-
Combat
-
+
+
- let submitRestart = document.querySelector("#restart");
- let alreadyPlaySongRestart = false;
- if(submitRestart) {
- submitRestart.addEventListener("click", function (event) {
- if(alreadyPlaySongRestart)
- return true;
- event.preventDefault();
- let fatality_song = document.getElementById("fatality-song");
- fatality_song.play();
- alreadyPlaySongRestart = true;
- setTimeout(function () {
- submitRestart.click();
- }, 2000);
- })
- }
- });
-
-
-
-