Beispiel #1
0
        private string BoardCharacterFromPosition(int position)
        {
            var file  = (char)('a' + position % 8);
            int rank  = position / 8 + 1;
            var piece = _game.GetPiece(new Location(file, rank));

            if (piece == null)
            {
                return("-");
            }
            return(AsciiPiece.GetCharForPiece(piece) + " ");
        }
Beispiel #2
0
 public void SetPieces(Game game)
 {
     if (game == null)
     {
         throw new ArgumentNullException("game");
     }
     for (int rank = 1; rank <= 8; rank++)
     {
         for (char file = 'a'; file <= 'h'; file++)
         {
             Piece piece = game.GetPiece(new Location(file, rank));
             _boardSpaces[file - 'a', rank - 1].Text = piece != null?AsciiPiece.GetCharForPiece(piece).ToString() : "";
         }
     }
 }
Beispiel #3
0
        private void SetPieces()
        {
            var table = FindViewById <TableLayout>(Resource.Id.tableBoard);

            for (int rank = 1; rank <= 8; rank++)
            {
                //Need to reverse the rank so that a1 is in the bottom left
                var row = (TableRow)table.GetChildAt(8 - rank);
                for (char file = 'a'; file <= 'h'; file++)
                {
                    var   cell  = (TextView)row.GetChildAt(file - 'a');
                    Piece piece = _game.GetPiece(new Location(file, rank));
                    cell.Text = piece != null?AsciiPiece.GetCharForPiece(piece).ToString() : "";
                }
            }
        }
Beispiel #4
0
 private void SetPieces()
 {
     for (int rank = 1; rank <= 8; rank++)
     {
         for (char file = 'a'; file <= 'h'; file++)
         {
             Piece piece = _game.GetPiece(new Location(file, rank));
             if (piece != null)
             {
                 _board [file - 'a', rank - 1].Text = AsciiPiece.GetCharForPiece(piece).ToString();
             }
             else
             {
                 _board [file - 'a', rank - 1].Text = "";
             }
         }
     }
 }