Skip to content

Commit

Permalink
Fixed an unintentional syntax mistake in the PHP version.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrains committed Nov 23, 2011
1 parent 2357ea6 commit 001238a
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions php/Game.php
Expand Up @@ -6,29 +6,29 @@ function echoln($string) {
class Game {
var $players;
var $places;
var $purses ;
var $purses ;
var $inPenaltyBox ;

var $popQuestions;
var $scienceQuestions;
var $sportsQuestions;
var $rockQuestions;

var $currentPlayer = 0;
var $isGettingOutOfPenaltyBox;

function __construct(){

$this->players = array();
$this->places = array(0);
$this->purses = array(0);
$this->purses = array(0);
$this->inPenaltyBox = array(0);

$this->popQuestions = array();
$this->scienceQuestions = array();
$this->sportsQuestions = array();
$this->rockQuestions = array();

for ($i = 0; $i < 50; $i++) {
array_push($this->popQuestions, "Pop Question " . $i);
array_push($this->scienceQuestions, ("Science Question " . $i));
Expand All @@ -40,7 +40,7 @@ function __construct(){
function createRockQuestion($index){
return "Rock Question " . $index;
}

function isPlayable() {
return ($this->howManyPlayers() >= 2);
}
Expand All @@ -50,50 +50,50 @@ function add($playerName) {
$this->places[$this->howManyPlayers()] = 0;
$this->purses[$this->howManyPlayers()] = 0;
$this->inPenaltyBox[$this->howManyPlayers()] = false;

echoln($playerName . " was added");
echoln("They are player number " . count($this->players));
return true;
}

function howManyPlayers() {
return count($this->players);
}

function roll($roll) {
echoln($this->players[$this->currentPlayer] . " is the current player");
echoln("They have rolled a " . $roll);

if ($this->inPenaltyBox[$this->currentPlayer]) {
if ($roll % 2 != 0) {
$this->isGettingOutOfPenaltyBox = true;

echoln($this->players[$this->currentPlayer] . " is getting out of the penalty box");
$this->places[$this->currentPlayer] = $this->places[$this->currentPlayer] . $roll;
$this->places[$this->currentPlayer] = $this->places[$this->currentPlayer] + $roll;
if ($this->places[$this->currentPlayer] > 11) $this->places[$this->currentPlayer] = $this->places[$this->currentPlayer] - 12;
echoln($this->players[$this->currentPlayer]
. "'s new location is "

echoln($this->players[$this->currentPlayer]
. "'s new location is "
.$this->places[$this->currentPlayer]);
echoln("The category is " . $this->currentCategory());
$this->askQuestion();
} else {
echoln($this->players[$this->currentPlayer] . " is not getting out of the penalty box");
$this->isGettingOutOfPenaltyBox = false;
}

} else {

$this->places[$this->currentPlayer] = $this->places[$this->currentPlayer] + $roll;
if ($this->places[$this->currentPlayer] > 11) $this->places[$this->currentPlayer] = $this->places[$this->currentPlayer] - 12;
echoln($this->players[$this->currentPlayer]
. "'s new location is "

echoln($this->players[$this->currentPlayer]
. "'s new location is "
.$this->places[$this->currentPlayer]);
echoln("The category is " . $this->currentCategory());
$this->askQuestion();
}

}

function askQuestion() {
Expand All @@ -104,10 +104,10 @@ function askQuestion() {
if ($this->currentCategory() == "Sports")
echoln(array_shift($this->sportsQuestions));
if ($this->currentCategory() == "Rock")
echoln(array_shift($this->rockQuestions));
echoln(array_shift($this->rockQuestions));
}


function currentCategory() {
if ($this->places[$this->currentPlayer] == 0) return "Pop";
if ($this->places[$this->currentPlayer] == 4) return "Pop";
Expand All @@ -126,46 +126,46 @@ function wasCorrectlyAnswered() {
if ($this->isGettingOutOfPenaltyBox) {
echoln("Answer was correct!!!!");
$this->purses[$this->currentPlayer]++;
echoln($this->players[$this->currentPlayer]
echoln($this->players[$this->currentPlayer]
. " now has "
.$this->purses[$this->currentPlayer]
. " Gold Coins.");

$winner = $this->didPlayerWin();
$this->currentPlayer++;
if ($this->currentPlayer == count($this->players)) $this->currentPlayer = 0;

return $winner;
} else {
$this->currentPlayer++;
if ($this->currentPlayer == count($this->players)) $this->currentPlayer = 0;
return true;
}



} else {

echoln("Answer was corrent!!!!");
$this->purses[$this->currentPlayer]++;
echoln($this->players[$this->currentPlayer]
echoln($this->players[$this->currentPlayer]
. " now has "
.$this->purses[$this->currentPlayer]
. " Gold Coins.");

$winner = $this->didPlayerWin();
$this->currentPlayer++;
if ($this->currentPlayer == count($this->players)) $this->currentPlayer = 0;

return $winner;
}
}

function wrongAnswer(){
echoln("Question was incorrectly answered");
echoln($this->players[$this->currentPlayer] . " was sent to the penalty box");
$this->inPenaltyBox[$this->currentPlayer] = true;

$this->currentPlayer++;
if ($this->currentPlayer == count($this->players)) $this->currentPlayer = 0;
return true;
Expand Down

0 comments on commit 001238a

Please sign in to comment.