Chess.Domain.GameManager.IsDraw C# (CSharp) Method

IsDraw() public method

public IsDraw ( ) : bool
return bool
        public bool IsDraw()
        {
            if (Game.Moves.Count() < 6) return false;

            if (Game.MoveCountSinceProgress > 49) return true;

            if (NeitherTeamCanCheckmate()) return true;

            if (LastSixMovesAreRepeats())
                return true;

            return false;
        }

Usage Example

        public ActionResult MakeMove(long id, Move move)
        {
            var game = GetChessGame(id);
            var gameManager = new GameManager(game);

            if (!IsPlayersMove(game, CurrentUser))
                throw new Exception("It is not your turn!");

            try
            {
                var movingTeam = gameManager.TeamToMove();

                gameManager.MovePiece(move);

                if (gameManager.IsDraw())
                    gameManager.MarkGameAsDraw();
                else if (gameManager.IsCheckmate())
                    gameManager.MarkWinningTeam(movingTeam);

                UnitOfWork.Commit();

                var model = GetGameModel(game);

                return Json(model, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                throw NewMoveFailureException(move, ex);
            }
        }