From cfc558a3d2e8e80a6a3ed71f1dc54ab9aa9f4907 Mon Sep 17 00:00:00 2001 From: Miguel N Date: Wed, 19 Feb 2020 00:28:35 +0000 Subject: [PATCH] Score calculation improvements --- main.php | 4 ++-- src/Base/Player.php | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/main.php b/main.php index c4eb769..72adb84 100644 --- a/main.php +++ b/main.php @@ -148,9 +148,9 @@ while ($gameRuntime) echo 'You lost this match of Rock Paper Scissors! Thank you for playing!' . PHP_EOL; } echo PHP_EOL; - echo 'The main menu will appear in five seconds...'; + echo 'The main menu will appear in fifteen seconds...'; - sleep(5); + sleep(15); Menu::clearScreen(); unset($robot, $human, $computerChoiceItem, $humanChoiceItem); diff --git a/src/Base/Player.php b/src/Base/Player.php index f2ad3c9..60c599c 100644 --- a/src/Base/Player.php +++ b/src/Base/Player.php @@ -73,19 +73,31 @@ class Player public function registerWin() { - if ($this->initialScore >= 1000) + + $score = $this->initialScore; + + if ($score <= 0) { + // If your score is below zero, it slowly increases by the multiplier value instead of being multiplied again + $this->initialScore = $score + $this->multiplier; + } + elseif($score >= 1000) + { + $this->increaseLives(); } + else + { + $this->initialScore = $score * $this->multiplier; + } - $this->initialScore = $this->initialScore * $this->multiplier; } public function registerLoss() { $score = $this->initialScore; - if ($score <= 1) + if ($score <= 0) { $this->decreaseLives(); }