示例#1
0
        public int MakeMove(Move m)
        {
            MovesHistory.Add(new Tuple <Move, int, Point>(m, Turn.GetPlyCounter(), Turn.GetPreviouslyMovedPiece()));
            if (m.FromPiece == Const.FLAGSHIP) //Flagship has been moved --> Update flagship position
            {
                FlagshipPosition = m.To;
            }
            else if (m.ToPiece == Const.FLAGSHIP) //Flagship has been captured --> Set flagship as out of the board
            {
                FlagshipPosition = new Point(-1, -1);
            }
            //Make move
            Board.Grid[m.To.X, m.To.Y]     = Board.Grid[m.From.X, m.From.Y];
            Board.Grid[m.From.X, m.From.Y] = 0;

            Turn.PlayerMoved(m);
            CleanLegalMoves();

            if (Terminal())
            {
                Winner     = Utils.Utils.PieceToColor(MovesHistory.Last().Item1.FromPiece) == Color.Gold ? Color.Gold : Color.Silver;
                GameStatus = Const.GAME_OVER;
            }
            return(0);
        }
示例#2
0
        public void UndoMove(Move m)
        {
            Board.Grid[m.From.X, m.From.Y] = m.FromPiece;
            Board.Grid[m.To.X, m.To.Y]     = m.ToPiece;

            Turn.PlayerUnMoved(MovesHistory.Last());

            MovesHistory.RemoveAt(MovesHistory.Count - 1);
            //Turn.SetPreviousPieceMoved(MovesHistory.Last().Item3);


            if (m.FromPiece == Const.FLAGSHIP)
            {
                FlagshipPosition = m.From;
            }
            else if (m.ToPiece == Const.FLAGSHIP)
            {
                FlagshipPosition = m.To;
            }

            CleanLegalMoves();
        }