diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a09c56d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.idea
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index ea1c4e6..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-checkers
\ No newline at end of file
diff --git a/.idea/checkers.iml b/.idea/checkers.iml
deleted file mode 100644
index 6b8184f..0000000
--- a/.idea/checkers.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index e206d70..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 1162f43..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 9b92b39..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 2e0588c..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 063e7ec..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,496 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
- 1370283613901
- 1370283613901
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.index.php.swp b/.index.php.swp
deleted file mode 100644
index acb5ba0..0000000
Binary files a/.index.php.swp and /dev/null differ
diff --git a/Board.php b/Board.php
new file mode 100644
index 0000000..7566a1b
--- /dev/null
+++ b/Board.php
@@ -0,0 +1,187 @@
+squares[] = new Square($i, $j, false);
+ }else{
+ $this->squares[] = new Square($i, $j, true);
+ }
+ }
+ }
+
+ $this->playerOne = new Player('White',-1);
+ $this->playerTwo = new Player('Red',1);
+
+ $this->turn = 'White';
+ $this->inactivePlayer = 'Red';
+
+ $p1 = $this->playerOne->getPieces();
+ $p2 = $this->playerTwo->getPieces();
+
+ foreach($this->squares as $square) {
+
+ $x = $square->getPosX();
+ $y = $square->getPosY();
+
+ $square->setOccupied(false);
+
+ $this->instancePiece($p1, $x, $y, $square, 'White');
+ $this->instancePiece($p2, $x, $y, $square, 'Red');
+ }
+ }
+
+ public function instancePiece($piece, $x, $y, $square, $color)
+ {
+ foreach($piece as $p) {
+ if($p != null)
+ {
+ $pX = $p->getPosX();
+ $pY = $p->getPosY();
+ if($pX==$x && $pY==$y){
+ $square->setOccupied($color, $p->getId());
+ break;
+ }
+ }
+ }
+ }
+
+ public function setBoard() {
+
+ reset($this->squares);
+ for ($i=0; $i<8; $i++) {
+ for ($j=0; $j<8; $j++) {
+ if ( ($i%2==0 && $j%2==0) || ($i%2==1 && $j%2==1) ) {
+ $this->squares[] = new Square($i, $j, false);
+ }else {
+ $this->squares[] = new Square($i, $j, true);
+ }
+ }
+ }
+
+ if ($this->getTurn()=='White') {
+ $this->playerOne->move($this->piece,$this->x,$this->y);
+ $pieces = $this->playerOne->getPieces();
+ $otherPieces = $this->playerTwo->getPieces();
+ $this->inactivePlayer = 'Red';
+ }elseif ($this->getTurn()=='Red') {
+ $this->playerTwo->move($this->piece,$this->x,$this->y);
+ $pieces = $this->playerTwo->getPieces();
+ $otherPieces = $this->playerOne->getPieces();
+ $this->inactivePlayer = 'White';
+ }
+
+ foreach ($this->squares as $square) {
+
+ $x = $square->getPosX();
+ $y = $square->getPosY();
+
+ $square->setOccupied(false);
+
+ $this->instancePiece($pieces, $x, $y, $square, $this->getTurn());
+ $this->instancePiece($otherPieces, $x, $y, $square, $this->inactivePlayer);
+ }
+ }
+
+ public function moveIsValid() {
+
+ if ($this->getTurn()=='White') {
+ $thisPiece = $this->playerOne->getPiece($this->piece);
+ $this->inactivePlayer='Red';
+ }elseif ($this->getTurn()=='Red') {
+ $thisPiece = $this->playerTwo->getPiece($this->piece);
+ $this->inactivePlayer='White';
+ }else{
+ exit('Error occurred!');
+ }
+
+ if(is_object($thisPiece)){
+ $moveFromX = $thisPiece->getPosX();
+ $moveFromY = $thisPiece->getPosY();
+ $direction = $thisPiece->getDirection();
+ }else{
+ exit('thisPiece is not an object!');
+ }
+
+ foreach($direction as $d) {
+ if(($moveFromX + $d == $this->x && $moveFromY + 1 == $this->y) || ($moveFromX + $d == $this->x && $moveFromY - 1 == $this->y)) {
+ $this->validMove=true;
+ return 'move';
+ }
+ }
+
+ return $this->checkNearbySquares($moveFromX, $moveFromY);
+ }
+
+ public function checkNearbySquares($moveFromX, $moveFromY)
+ {
+ if($moveFromX+2==$this->x || $moveFromX-2==$this->x)
+ {
+ if($moveFromY+2==$this->y || $moveFromY-2==$this->y)
+ {
+ foreach($this->squares as $thisSquare) {
+ if(($thisSquare->getPosX()==$moveFromX+1 && $thisSquare->getPosY()==$moveFromY+1 && $thisSquare->getOccupied()==$this->inactivePlayer) || ($thisSquare->getPosX()==$moveFromX+1 && $thisSquare->getPosY()==$moveFromY-1 && $thisSquare->getOccupied()==$this->inactivePlayer) || ($thisSquare->getPosX()==$moveFromX-1 && $thisSquare->getPosY()==$moveFromY+1 && $thisSquare->getOccupied()==$this->inactivePlayer) || ($thisSquare->getPosX()==$moveFromX-1 && $thisSquare->getPosY()==$moveFromY-1 && $thisSquare->getOccupied()==$this->inactivePlayer)) {
+ return $this->capturePiece($thisSquare);
+ }
+ }
+ return false;
+ }
+ } else {
+ $this->validMove=false;
+ return false;
+ }
+ }
+
+ public function capturePiece($square)
+ {
+ if($this->getTurn()=='White') {
+ $this->playerTwo->deletePiece($square->getPieceId());
+ }elseif($this->getTurn()=='Red') {
+ $this->playerOne->deletePiece($square->getPieceId());
+ }
+ $this->validMove=true;
+
+ return 'jump';
+ }
+
+ public function getPlayerOne() {
+ return $this->playerOne;
+ }
+ public function getPlayerTwo() {
+ return $this->playerTwo;
+ }
+
+ public function setTurn($color) {
+ $this->turn = $color;
+ }
+
+ public function getTurn() {
+ return $this->turn;
+ }
+
+ public function setX($num) {
+ $this->x = $num;
+ }
+
+ public function setY($num) {
+ $this->y = $num;
+ }
+
+ public function setPiece($id) {
+ $this->piece = $id;
+ }
+}
\ No newline at end of file
diff --git a/BoardPrintDecorator.php b/BoardPrintDecorator.php
new file mode 100644
index 0000000..72dc8bc
--- /dev/null
+++ b/BoardPrintDecorator.php
@@ -0,0 +1,62 @@
+board = $board;
+ }
+
+ public function printBoard() {
+ echo "
";
+ }
+}
\ No newline at end of file
diff --git a/Game.php b/Game.php
new file mode 100644
index 0000000..708aed3
--- /dev/null
+++ b/Game.php
@@ -0,0 +1,104 @@
+startSession();
+
+ $this->message = "Welcome! White's turn!";
+ $this->color = 'Red';
+ $this->activeColor = 'White';
+
+ if(array_key_exists('submit',$_GET)) {
+ $this->checkMove();
+ }
+ }
+
+ private function startSession()
+ {
+ session_start();
+
+ if (!isset($_SESSION['b']) || array_key_exists('reset',$_GET)) {
+ $this->message = "Start New Game...White's Move";
+ $this->board = new Board();
+ $_SESSION['b'] = $this->board;
+ }else {
+ $this->board = $_SESSION['b'];
+ }
+ }
+
+ public function checkMove()
+ {
+ if(array_key_exists('piece',$_GET) && array_key_exists('n',$_GET)) {
+ $id = $_GET['piece'];
+ $moveTo = explode('-',$_GET['n']);
+ $x = $moveTo[0];
+ $y = $moveTo[1];
+ $this->board->setX($x);
+ $this->board->setY($y);
+ $this->board->setPiece($id);
+
+ $this->changeTurn();
+ }else {
+ $this->message = "Invalid Move. Try Again.";
+ }
+ }
+
+ public function changeTurn()
+ {
+ if($this->board->moveIsValid()=='move') {
+ $this->board->setBoard();
+ if($this->board->getTurn()=='White') {
+ $this->board->setTurn('Red');
+ }elseif($this->board->getTurn()=='Red') {
+ $this->board->setTurn('White');
+ }
+ $this->message = $this->board->getTurn() . "'s turn...";
+ }elseif($this->board->moveIsValid()=='jump') {
+ $this->board->setBoard();
+ if($this->board->getTurn()=='White') {
+ $this->board->setTurn('Red');
+ }elseif($this->board->getTurn()=='Red') {
+ $this->board->setTurn('White');
+ }
+ $this->message = 'Jump! Still ' .$this->board->getTurn() . "'s turn...";
+ }else{
+ $this->message = 'Invalid Move. Still ' . $this->board->getTurn() . "'s turn...";
+ }
+ }
+
+ public function displayMessage()
+ {
+ echo $this->message;
+ }
+
+ public function printBoard()
+ {
+ $boardPrintDecorator = new BoardPrintDecorator($this->board);
+ $boardPrintDecorator->printBoard();
+ }
+
+ public static function getInstance()
+ {
+ static $instance = null;
+ if (null === $instance) {
+ $instance = new static();
+ }
+
+ return $instance;
+ }
+
+ private function __clone() {}
+}
\ No newline at end of file
diff --git a/Piece.php b/Piece.php
new file mode 100644
index 0000000..83a1c7b
--- /dev/null
+++ b/Piece.php
@@ -0,0 +1,43 @@
+moveY = array(-1,1);
+ $this->moveX = array($direction);
+ $this->posX = $x;
+ $this->posY = $y;
+ $this->pId = $id;
+ }
+
+ public function getPosX() {
+ return $this->posX;
+ }
+
+ public function getPosY() {
+ return $this->posY;
+ }
+
+ public function getId() {
+ return $this->pId;
+ }
+
+ public function getDirection() {
+ return $this->moveX;
+ }
+
+ public function setPos($x,$y) {
+ $this->posX = $x;
+ $this->posY = $y;
+ }
+
+ public function king() {
+ $this->moveX = array(-1,1);
+ }
+}
\ No newline at end of file
diff --git a/player.php b/Player.php
similarity index 87%
rename from player.php
rename to Player.php
index 44406a2..03174cb 100644
--- a/player.php
+++ b/Player.php
@@ -1,17 +1,14 @@
color = $color; // White OR Red
- $this->direction = $direction; // 1 or -1
+ $this->color = $color;
+ $this->direction = $direction;
$this->pieces = array();
@@ -28,8 +25,7 @@ public function __construct($color, $direction) {
$x = $yCoord[$i];
$this->pieces[] = new Piece($x,$y,$direction,$i);
}
-
- } // End constructor
+ }
public function &getPieces() {
return $this->pieces;
@@ -62,8 +58,5 @@ public function move($piece,$x,$y) {
}elseif($this->color=='Red' && $x==7) {
$pieceObj->king();
}
- //$this->pieces[$piece] = $pieceObj;
}
-
-
-} // End class definition
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index bd14556..a25e4b0 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,7 @@
-checkers
+Checkers
========
-
-Checkers Game
-
-partially functional checkers game.
+Partially functional checkers game
Notes:
--Kinged pieces look the same as regular pieces.
--Double jumps aren't possible.
--
--
+- Kinged pieces look the same as regular pieces.
+- Double jumps aren't possible.
diff --git a/Square.php b/Square.php
new file mode 100644
index 0000000..5233b3b
--- /dev/null
+++ b/Square.php
@@ -0,0 +1,43 @@
+posX = $x;
+ $this->posY = $y;
+ $this->occupied = false;
+ $this->pieceId = null;
+ $this->valid = $isValid;
+ }
+
+ public function getPosX() {
+ return $this->posX;
+ }
+
+ public function getPosY() {
+ return $this->posY;
+ }
+
+ public function setOccupied($color=false, $id=null) {
+ $this->occupied = $color;
+ $this->pieceId = $id;
+ }
+
+ public function getOccupied() {
+ return $this->occupied;
+ }
+
+ public function getPieceId() {
+ return $this->pieceId;
+ }
+
+ public function getValid() {
+ return $this->valid;
+ }
+}
\ No newline at end of file
diff --git a/board.php b/board.php
deleted file mode 100644
index 0ae76aa..0000000
--- a/board.php
+++ /dev/null
@@ -1,371 +0,0 @@
-squares[] = new Square($i, $j, false);
- }else{
- $this->squares[] = new Square($i, $j, true);
- }
-
- }
- }
-
-
- $this->playerOne = new Player('White',-1);
- $this->playerTwo = new Player('Red',1);
-
- $this->turn = 'White';
- $this->inactivePlayer = 'Red';
-
- $p1 = $this->playerOne->getPieces();
- $p2 = $this->playerTwo->getPieces();
-
- foreach($this->squares as $square) {
-
- $x = $square->getPosX();
- $y = $square->getPosY();
-
- $square->setOccupied(false);
-
- foreach($p1 as $p) {
- $pX = $p->getPosX();
- $pY = $p->getPosY();
- if($pX==$x && $pY==$y){
- $square->setOccupied('White',$p->getId());
- break;
- }
- }
-
-
- foreach($p2 as $p) {
- $pX = $p->getPosX();
- $pY = $p->getPosY();
- if($pX==$x && $pY==$y){
- $square->setOccupied('Red',$p->getId());
- break;
- }
- }
-
- }
-
- }
-
- // Class Methods
- public function setBoard() {
-
- reset($this->squares);
- for ($i=0; $i<8; $i++) {
- for ($j=0; $j<8; $j++) {
- if ( ($i%2==0 && $j%2==0) || ($i%2==1 && $j%2==1) ) {
- $this->squares[] = new Square($i, $j, false);
- }else {
- $this->squares[] = new Square($i, $j, true);
- }
-
- }
- }
-
-
- if ($this->getTurn()=='White') {
- $this->playerOne->move($this->piece,$this->x,$this->y);
- $pieces = $this->playerOne->getPieces();
- $otherPieces = $this->playerTwo->getPieces();
- $this->inactivePlayer = 'Red';
- }elseif ($this->getTurn()=='Red') {
- $this->playerTwo->move($this->piece,$this->x,$this->y);
- $pieces = $this->playerTwo->getPieces();
- $otherPieces = $this->playerOne->getPieces();
- $this->inactivePlayer = 'White';
- }
-
- foreach ($this->squares as $square) {
-
-
- $x = $square->getPosX();
- $y = $square->getPosY();
-
- $square->setOccupied(false);
-
- foreach ($pieces as $p) {
- if ($p != null) {
- $pX = $p->getPosX();
- $pY = $p->getPosY();
- if ($pX==$x && $pY==$y){
- $square->setOccupied($this->getTurn(),$p->getId());
- break;
- }
- }
- }
-
- foreach ($otherPieces as $p) {
- if ($p != null) {
- $pX = $p->getPosX();
- $pY = $p->getPosY();
- if ($pX==$x && $pY==$y){
- $square->setOccupied($this->inactivePlayer,$p->getId());
- break;
- }
- }
- }
-
- }
-
- } // End method setBoard
-
-
- public function moveIsValid() {
-
- if ($this->getTurn()=='White') {
- $thisPiece = $this->playerOne->getPiece($this->piece);
- //!
- $this->inactivePlayer='Red';
- }elseif ($this->getTurn()=='Red') {
- $thisPiece = $this->playerTwo->getPiece($this->piece);
- //!
- $this->inactivePlayer='White';
- }else{
- exit('Exception occurred!');
- }
-
- if(is_object($thisPiece)){
- $moveFromX = $thisPiece->getPosX();
- $moveFromY = $thisPiece->getPosY();
- $direction = $thisPiece->getDirection();
- }else{
- exit('thisPiece is not an object!');
- }
-
-
- /*
- if($moveFromX+1==$x && $moveFromY+1==$y) {
- return 'move';
- }elseif($moveFromX-1==$x && $moveFromY-1==$y) {
- return 'move';
- }elseif($moveFromX-1==$x && $moveFromY+1==$y) {
- return 'move';
- }elseif($moveFromX+1==$x && $moveFromY-1==$y) {
- return 'move';
- }*/
- //Check if move is valid. Returns true or false
- foreach($direction as $d) {
- if($moveFromX + $d == $this->x && $moveFromY + 1 == $this->y) {
- $this->validMove=true;
- return 'move';
- }elseif($moveFromX + $d == $this->x && $moveFromY - 1 == $this->y) {
- $this->validMove=true;
- return 'move';
- }
- }
- if($moveFromX+2==$this->x && $moveFromY+2==$this->y) {
- foreach($this->squares as $thisSquare) {
- //echo $this->turn.'-'. $this->inactivePlayer.'-' . $thisSquare->getOccupied() . '
';
- if($thisSquare->getPosX()==$moveFromX+1 && $thisSquare->getPosY()==$moveFromY+1 && $thisSquare->getOccupied()==$this->inactivePlayer) {
- if($this->getTurn()=='White') {
- $this->playerTwo->deletePiece($thisSquare->getPieceId());
- }elseif($this->getTurn()=='Red') {
- $this->playerOne->deletePiece($thisSquare->getPieceId());
- }
- $this->validMove=true;
- return 'jump';
- }
- }
- return false;
- }elseif($moveFromX+2==$this->x && $moveFromY-2==$this->y) {
- foreach($this->squares as $thisSquare) {
- //echo $this->turn.'-'. $this->inactivePlayer.'-' . $thisSquare->getOccupied() . '
';
- if($thisSquare->getPosX()==$moveFromX+1 && $thisSquare->getPosY()==$moveFromY-1 && $thisSquare->getOccupied()==$this->inactivePlayer) {
- if($this->getTurn()=='White') {
- $this->playerTwo->deletePiece($thisSquare->getPieceId());
- }elseif($this->getTurn()=='Red') {
- $this->playerOne->deletePiece($thisSquare->getPieceId());
- }
- $this->validMove=true;
- return 'jump';
- }
- }
- return false;
- }elseif($moveFromX-2==$this->x && $moveFromY+2==$this->y) {
- foreach($this->squares as $thisSquare) {
- //echo $this->turn.'-'. $this->inactivePlayer.'-' . $thisSquare->getOccupied() . '
';
- if($thisSquare->getPosX()==$moveFromX-1 && $thisSquare->getPosY()==$moveFromY+1 && $thisSquare->getOccupied()==$this->inactivePlayer) {
- if($this->getTurn()=='White') {
- $this->playerTwo->deletePiece($thisSquare->getPieceId());
- }elseif($this->getTurn()=='Red') {
- $this->playerOne->deletePiece($thisSquare->getPieceId());
- }
- $this->validMove=true;
- return 'jump';
- }
- }
- return false;
- }elseif($moveFromX-2==$this->x && $moveFromY-2==$this->y) {
-
- foreach($this->squares as $thisSquare) {
- //echo 'Inactive Player: '.$this->inactivePlayer . 'getOccupied'.$thisSquare->getOccupied() . '
';
- if($thisSquare->getPosX()==$moveFromX-1 && $thisSquare->getPosY()==$moveFromY-1 && $thisSquare->getOccupied()==$this->inactivePlayer) {
- if($this->getTurn()=='White') {
- $this->playerTwo->deletePiece($thisSquare->getPieceId());
- }elseif($this->getTurn()=='Red') {
- $this->playerOne->deletePiece($thisSquare->getPieceId());
- }
- $this->validMove=true;
- return 'jump';
- }
- }
- $this->validMove=false;
- return false;
- }else {
- $this->validMove=false;
- return false;
- }
- }
-
-
- public function printBoard() {
- echo "";
- } // End method printBoard()
-
- /*
- * GETTERS & SETTERS
- */
- public function getPlayerOne() {
- return $this->playerOne;
- }
- public function getPlayerTwo() {
- return $this->playerTwo;
- }
-
- public function setTurn($color) {
- $this->turn = $color;
- }
-
- public function getTurn() {
- return $this->turn;
- }
-
- public function setX($num) {
- $this->x = $num;
- }
-
- public function setY($num) {
- $this->y = $num;
- }
-
- public function setPiece($id) {
- $this->piece = $id;
- }
-
-
-} // End class definition
-
-
-class Square {
-
- private $posX;
- private $posY;
- private $occupied;
- private $pieceId;
- private $valid;
-
- public function __construct($x,$y,$isValid) {
- $this->posX = $x;
- $this->posY = $y;
- $this->occupied = false;
- $this->pieceId = null;
- $this->valid = $isValid;
- }
-
-
- public function getPosX() {
- return $this->posX;
- }
-
- public function getPosY() {
- return $this->posY;
- }
-
- public function setOccupied($color=false, $id=null) {
- $this->occupied = $color; // White, Red, or false
- $this->pieceId = $id;
- }
-
- public function getOccupied() {
- return $this->occupied;
- }
-
- public function getPieceId() {
- return $this->pieceId;
- }
-
- public function getValid() {
- return $this->valid;
- }
-
-
-} // End class definition
\ No newline at end of file
diff --git a/css/style.css b/css/style.css
new file mode 100644
index 0000000..6fe7ac7
--- /dev/null
+++ b/css/style.css
@@ -0,0 +1,102 @@
+h2,
+p {
+ font-family: Helvetica, sans-serif;
+}
+
+h2 {
+ margin-top: 10px;
+}
+
+body {
+ background: #e5b585;
+}
+
+table {
+ width: 500px;
+ height: 500px;
+ margin: 0 auto;
+}
+
+td {
+ background-color: #883000;
+}
+
+.red {
+ background-color: #883000;
+}
+
+.white {
+ background-color: #883000;
+}
+
+.black {
+ background-color: #000000;
+}
+
+#left {
+ display: inline-block;
+ float: left;
+ width: 400px;
+}
+
+#game {
+ text-align: center;
+}
+
+#controls {
+ margin: 10px;
+ font-size: 15px;
+}
+
+input[type=submit] {
+ padding: 12px;
+ margin: 0 10px;
+ width: 200px;
+ color: wheat;
+ background: #883000;
+ border: none;
+ border-radius: 30px;
+ font-weight: bold;
+ cursor: pointer;
+}
+
+input[type=submit]:hover {
+ color: #883000;
+ background: white;
+ -webkit-transition: ease .3s;
+ -moz-transition: ease .3s;
+ -ms-transition: ease .3s;
+ -o-transition: ease .3s;
+ transition: ease .3s;
+}
+
+input[type=submit]:focus {
+ outline: none;
+ background: #501c00;
+ color: white;
+ -webkit-transition: ease .3s;
+ -moz-transition: ease .3s;
+ -ms-transition: ease .3s;
+ -o-transition: ease .3s;
+ transition: ease .3s;
+}
+
+input[type=checkbox] {
+ height: 35px;
+}
+
+.red-piece {
+ height: 40px;
+ width: 40px;
+ background: red;
+ border-radius: 50%;
+ display: inline-block;
+}
+
+.white-piece {
+ height: 40px;
+ width: 40px;
+ background: white;
+ border-radius: 50%;
+ display: inline-block;
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index dc7443e..05362bb 100644
--- a/index.php
+++ b/index.php
@@ -1,127 +1,32 @@
setX($x);
- $b->setY($y);
- $b->setPiece($id);
- if($b->moveIsValid()=='move') {
- $b->setBoard();
- if($b->getTurn()=='White') {
- $b->setTurn('Red');
- }elseif($b->getTurn()=='Red') {
- $b->setTurn('White');
- }
- $message = $b->getTurn() . "'s turn...";
- }elseif($b->moveIsValid()=='jump') {
- $b->setBoard();
- if($b->getTurn()=='White') {
- $b->setTurn('Red');
- }elseif($b->getTurn()=='Red') {
- $b->setTurn('White');
- }
- $message = 'Jump! Still ' .$b->getTurn() . "'s turn...";
- }else{
- $message = 'Invalid Move. Still ' . $b->getTurn() . "'s turn...";
- }
-
-
- }else {
- $message = "Invalid Move. Try Again.";
- }
-}
+$game = Game::getInstance();
?>
-
-
-
+
-
Checkers
-
-
-
+
-
-
- ';
- var_dump($b);
- echo '';
- ?>
-
-
-
Checkers
-
+
= $game->displayMessage() ?>
-
-
-
+
-
\ No newline at end of file
diff --git a/piece.php b/piece.php
deleted file mode 100644
index 0ea6d23..0000000
--- a/piece.php
+++ /dev/null
@@ -1,64 +0,0 @@
-moveY = array(-1,1); // move options on x-axis
- $this->moveX = array($direction); // move options on y-axis
- $this->posX = $x;
- $this->posY = $y;
- $this->pId = $id;
- //$this->isKing = false;
- }
-
- public function getPosX() {
- return $this->posX;
- }
-
- public function getPosY() {
- return $this->posY;
- }
-
- public function getId() {
- return $this->pId;
- }
-
- public function getDirection() {
- return $this->moveX;
- }
-
- public function setPos($x,$y) {
- $this->posX = $x;
- $this->posY = $y;
- }
-
- public function king() {
- $this->moveX = array(-1,1); // piece is able to move positive & negative on y-axis
- }
-
-/*
- public function possibleMoves() {
- foreach ($this->moveY as $dirY) {
- foreach ($this->moveX as $dirX) {
- //$this->moveX;
- }
- }
-
- if ($this->posX > 8 || $this->posX < 1 || $this->posY > 8 || $this->posY < 1) {
- // Invalid Move!
- }
- //elseif(This Square Is Occupied)
- }
-
- public function makeKing() {
- $this->moveY = array(-1,1);
- }
-*/
-} // End class definition
\ No newline at end of file
diff --git a/square.php b/square.php
deleted file mode 100644
index a4abe2d..0000000
--- a/square.php
+++ /dev/null
@@ -1,2 +0,0 @@
-