public void ExecuteMoves_Capture_MovesPieceAwayFromStart()
        {
            Game game = new Game();
            game.SetPieceLocation(Coord.Create(0, 0), BoardSpaceState.FriendlyPieceShort);
            game.SetPieceLocation(Coord.Create(0, 1), BoardSpaceState.OpponentPieceShort);
            game.AddActiveMove(Coord.Create(0, 0));
            game.AddActiveMove(Coord.Create(0, 2));

            GameController.ExecuteMoves(game);

            Assert.AreEqual(game.GetPieceAt(Coord.Create(0, 0)), BoardSpaceState.None);
        }
 public static void OnBoardSpaceClick(User user, Game game, Coord coordClicked)
 {
     if (GameValidator.IsValidMoveFor(user, game, coordClicked))
     {
         game.AddActiveMove(coordClicked);
     }
 }
        public void ExecuteMoves_Capture_RemovesCapturedPiece()
        {
            Game game = new Game();
            game.SetPieceLocation(Coord.Create(0, 0), BoardSpaceState.FriendlyPieceShort);
            game.SetPieceLocation(Coord.Create(0, 1), BoardSpaceState.OpponentPieceShort);
            game.AddActiveMove(Coord.Create(0, 0));
            game.AddActiveMove(Coord.Create(0, 2));

            GameController.ExecuteMoves(game);

            Assert.AreEqual(BoardSpaceState.None, game.GetPieceAt(Coord.Create(0, 1)));
            Assert.AreEqual(1, game.GetCapturedCount(BoardSpaceState.OpponentPieceShort));
        }
        public void Winner_DisablesMoving()
        {
            Game game = new Game();
            game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_1), BoardSpaceState.OpponentPieceShort);
            game.SetPieceLocation(Coord.Create(Game.BOARD_ROW_MAX, Game.ENDZONE_COL_2), BoardSpaceState.OpponentPieceTall);
            game.SetPieceLocation(Coord.Create(4, 5), BoardSpaceState.OpponentPieceTall);

            game.AddActiveMove(Coord.Create(4, 5));

            Assert.IsFalse(GameValidator.IsValidMove(game, Coord.Create(4, 6)));
        }
        public void IsCompleteCapture_True()
        {
            Game game = new Game();
            game.AddActiveMove(Coord.Create(0, 2));
            game.SetPieceLocation(Coord.Create(0, 3), BoardSpaceState.OpponentPieceShort);
            game.AddActiveMove(Coord.Create(0, 4));
            game.SetPieceLocation(Coord.Create(0, 5), BoardSpaceState.OpponentPieceShort);
            game.AddActiveMove(Coord.Create(0, 6));

            Assert.IsTrue(GameValidator.IsCompleteMove(game));
        }
        public void IsCompleteCapture_SimpleMove()
        {
            Game game = new Game();
            game.AddActiveMove(Coord.Create(0, 12));
            game.AddActiveMove(Coord.Create(0, 13));

            Assert.IsTrue(GameValidator.IsCompleteMove(game));
        }
        public void GameController_MakingMoveSwitchesWaitingOn()
        {
            var game = new Game() { WaitingOn = AbsolutePlayer.Recepient };
            game.AddActiveMove(Coord.Create(0, 0));
            game.AddActiveMove(Coord.Create(0, 1));

            GameController.ExecuteMoves(game);

            Assert.AreEqual(AbsolutePlayer.Initiator, game.WaitingOn);
        }
        public void ExecuteMoves_SetWinner_Friendly()
        {
            Game game = new Game();
            // is this the right row?
            game.SetPieceLocation(Coord.Create(0, Game.ENDZONE_COL_1), BoardSpaceState.FriendlyPieceShort);
            game.SetPieceLocation(Coord.Create(1, Game.ENDZONE_COL_2), BoardSpaceState.FriendlyPieceShort);

            game.AddActiveMove(Coord.Create(1, Game.ENDZONE_COL_2));
            game.AddActiveMove(Coord.Create(0, Game.ENDZONE_COL_2));

            GameController.ExecuteMoves(game);

            Assert.AreEqual(RelativePlayer.Friendly, game.Winner);
        }
        public void ExecuteMoves_HandleSingleMove()
        {
            Game game = new Game();
            game.SetPieceLocation(Coord.Create(0, 10), BoardSpaceState.FriendlyPieceShort);
            game.AddActiveMove(Coord.Create(0, 10));
            game.AddActiveMove(Coord.Create(0, 11));

            GameController.ExecuteMoves(game);

            Assert.AreEqual(BoardSpaceState.None, game.GetPieceAt(Coord.Create(0, 10)));
            Assert.AreEqual(BoardSpaceState.FriendlyPieceShort, game.GetPieceAt(Coord.Create(0, 11)));
        }