Score calculation improvements

This commit is contained in:
Miguel Nogueira 2020-02-19 00:28:35 +00:00
parent dbea63edd3
commit cfc558a3d2
2 changed files with 17 additions and 5 deletions

View File

@ -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);

View File

@ -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();
}