Changed game timers and score calculation
This commit is contained in:
parent
a5e0bf5a41
commit
dbea63edd3
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "83e517bf36ce6cd988a8b08e1ff8f7f2",
|
||||||
|
"packages": [],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": {
|
||||||
|
"ext-readline": "*"
|
||||||
|
},
|
||||||
|
"platform-dev": []
|
||||||
|
}
|
|
@ -35,7 +35,7 @@ while ($gameRuntime)
|
||||||
echo 'Got it ' . $playerName . '! Let\'s start, shall we? ' . PHP_EOL;
|
echo 'Got it ' . $playerName . '! Let\'s start, shall we? ' . PHP_EOL;
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
echo 'Each player starts with 20 points and 4 lives;' . PHP_EOL;
|
echo 'Each player starts with 20 points and 4 lives;' . PHP_EOL;
|
||||||
echo 'Each time you win, your score is multiplied by 3;' . PHP_EOL;
|
echo 'Each time you win, your score is multiplied by 2;' . PHP_EOL;
|
||||||
echo 'Each time you lose, your score is subtracted from the result of the score multiplier (which is 3) times 2.' . PHP_EOL;
|
echo 'Each time you lose, your score is subtracted from the result of the score multiplier (which is 3) times 2.' . PHP_EOL;
|
||||||
echo 'This also applies for the bot. Good luck! Starting in 15 seconds.' . PHP_EOL;
|
echo 'This also applies for the bot. Good luck! Starting in 15 seconds.' . PHP_EOL;
|
||||||
sleep(15);
|
sleep(15);
|
||||||
|
@ -123,14 +123,14 @@ while ($gameRuntime)
|
||||||
echo 'Computer\'s lives: ' . $robot->getLives() . PHP_EOL;
|
echo 'Computer\'s lives: ' . $robot->getLives() . PHP_EOL;
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
echo 'Continuing in 10 seconds...';
|
echo 'Continuing in 5 seconds...';
|
||||||
|
|
||||||
if ($human->getLives() == 0 || $robot->getLives() == 0)
|
if ($human->getLives() == 0 || $robot->getLives() == 0)
|
||||||
{
|
{
|
||||||
$gameOver = true;
|
$gameOver = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(10);
|
sleep(5);
|
||||||
Menu::clearScreen();
|
Menu::clearScreen();
|
||||||
|
|
||||||
} while (!$gameOver);
|
} while (!$gameOver);
|
|
@ -12,7 +12,7 @@ class Player
|
||||||
|
|
||||||
private $initialScore = 20;
|
private $initialScore = 20;
|
||||||
|
|
||||||
private $multiplier = 3;
|
private $multiplier = 2;
|
||||||
|
|
||||||
private $lives = 4;
|
private $lives = 4;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class Player
|
||||||
|
|
||||||
public function registerWin()
|
public function registerWin()
|
||||||
{
|
{
|
||||||
if ($this->initialScore > 500)
|
if ($this->initialScore >= 1000)
|
||||||
{
|
{
|
||||||
$this->increaseLives();
|
$this->increaseLives();
|
||||||
}
|
}
|
||||||
|
@ -83,16 +83,16 @@ class Player
|
||||||
|
|
||||||
public function registerLoss()
|
public function registerLoss()
|
||||||
{
|
{
|
||||||
if ($this->initialScore <= 0)
|
$score = $this->initialScore;
|
||||||
|
|
||||||
|
if ($score <= 1)
|
||||||
{
|
{
|
||||||
$this->decreaseLives();
|
$this->decreaseLives();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->initialScore = $this->initialScore - ($this->multiplier * 2);
|
$this->initialScore = $score - ($this->multiplier * 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue