var Board = require('./board');

var GamePrototype = {
  isOver: function() {
    return this._consectutivePasses >= 2;
  },

  /*
   * At any point in the game, a player can pass and let his opponent play
   */
  pass: function() {
    this._consectutivePasses++;
    this._switchPlayer();
  },

  play: function(i, j) {
    try {
      this._inAtari = this._board.play(this._currentColor, i, j);
      this._lastMovePassed = false;
      this._switchPlayer();
    } catch (e) {

    }
  },

  /*
   * Switches the current player
   */
  switchPlayer: function() {
    this._currentColor =
      this._currentColor == Board.BLACK ? Board.WHITE : Board.BLACK;
  }

};

function createGame(boardSize) {
  var game = Object.create(GamePrototype);
  game._board = Board.createBoard(boardSize);
  game._currentColor = Board.BLACK;
  game._consectutivePasses = 0;
  game._inAtari = false;
  return game;
}


module.exports = {
  createGame: createGame
};

@@ -125,112 +125,288 @@
 %0A%0A  
-/*%0A   * At any point in the game, a player can pass and let his opponent play%0A   */%0A  pass: function() %7B
+getCurrentPlayer: function() %7B%0A    return this._currentColor;%0A  %7D,%0A%0A  play: function(player, i, j) %7B%0A    if (player != this._currentColor)%0A      throw %22Not player's turn%22;%0A%0A    if (this.isOver())%0A      throw %22Game is already over%22;%0A%0A    this._board.play(this._currentColor, i, j);
 %0A   
@@ -434,10 +434,12 @@
 sses
-++
+ = 0
 ;%0A  
@@ -474,195 +474,308 @@
 %0A%0A  
-play: function(i, j) %7B%0A    try %7B%0A      this._inAtari = this._board.play(this._currentColor, i, j);%0A      this._lastMovePassed = false;%0A      this._switchPlayer();%0A    %7D catch (e) %7B%0A%0A    %7D
+/*%0A   * At any point in the game, a player can pass and let his opponent play%0A   */%0A  pass: function(player) %7B%0A    if (player != this._currentColor)%0A      throw %22Not player's turn%22;%0A%0A    if (this.isOver())%0A      throw %22Game is already over%22;%0A%0A    this._consectutivePasses++;%0A    this._switchPlayer();
 %0A  %7D
@@ -823,16 +823,17 @@
    */%0A  
+_
 switchPl
@@ -1148,33 +1148,8 @@
  0;%0A
-  game._inAtari = false;%0A
   re

Clean up game