Пример #1
0
 private string _UpdateBuffer()
 {
     char[] buffer = new char[71];
     buffer[0] = 'U';
     buffer[1] = 'P';
     buffer[2] = 'D';
     buffer[3] = 'T';
     PieceState[,] pieceStates = new PieceState[8, 8];
     _Reversi.CopyState(pieceStates);
     for (var i = 0; i < 8; i++)
     {
         for (var j = 0; j < 8; j++)
         {
             if (pieceStates[i, j] == PieceState.PieceAvailable)
             {
                 if (_Reversi.GetCurrentPlayer() == _Player)
                 {
                     buffer[4 + i * 8 + j] = (char)((int)pieceStates[i, j]);
                 }
                 else
                 {
                     buffer[4 + i * 8 + j] = (char)0;
                 }
             }
             else
             {
                 buffer[4 + i * 8 + j] = (char)((int)pieceStates[i, j]);
             }
         }
     }
     if (_Reversi.GetCurrentPlayer() == _Player)
     {
         if (_Reversi.GetState() == ReversiState.NoAvailableSpaces)
         {
             buffer[4 + 64] = (char)10;
         }
         else if (((byte)_Reversi.GetState() & (byte)ReversiState.InProgress) != 0)
         {
             buffer[4 + 64] = (char)_Reversi.GetCurrentPlayer();
         }
         else
         {
             buffer[4 + 64] = (char)((int)_Reversi.GetState() + 1);
         }
     }
     else
     {
         if (((byte)_Reversi.GetState() & (byte)ReversiState.InProgress) != 0)
         {
             buffer[4 + 64] = (char)_Reversi.GetCurrentPlayer();
         }
         else
         {
             buffer[4 + 64] = (char)((int)_Reversi.GetState() + 1);
         }
     }
     buffer[4 + 65] = (char)_Reversi.GetDarkCount();
     buffer[4 + 66] = (char)_Reversi.GetLightCount();
     return(new string(buffer));
 }