本文整理汇总了C#中IBoard.SetPiece方法的典型用法代码示例。如果您正苦于以下问题:C# IBoard.SetPiece方法的具体用法?C# IBoard.SetPiece怎么用?C# IBoard.SetPiece使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBoard
的用法示例。
在下文中一共展示了IBoard.SetPiece方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPositions
private static void GetPositions(IBoard board, string posData)
{
var ranks = posData.Split('/');
for (var r=7;r>=0;r--)
{
var f = 0;
var cPos = 0;
while (f<8)
{
var num =0;
if (int.TryParse(ranks[r][cPos].ToString(),out num))
{
f+=num;
cPos++;
}
else
{
var currentSquare = new BareSquare(f, 7 - r);
switch (ranks[r][cPos])
{
case 'p':
board.SetPiece(currentSquare, new Pawn(Color.Black,board));
break;
case 'P':
board.SetPiece(currentSquare, new Pawn(Color.White, board));
break;
case 'q':
board.SetPiece(currentSquare, new Queen(Color.Black, board));
break;
case 'Q':
board.SetPiece(currentSquare, new Queen(Color.White, board));
break;
case 'k':
board.SetPiece(currentSquare, new King(Color.Black, board));
break;
case 'K':
board.SetPiece(currentSquare, new King(Color.White, board));
break;
case 'n':
board.SetPiece(currentSquare, new Knight(Color.Black, board));
break;
case 'N':
board.SetPiece(currentSquare, new Knight(Color.White, board));
break;
case 'r':
board.SetPiece(currentSquare, new Rook(Color.Black, board));
break;
case 'R':
board.SetPiece(currentSquare, new Rook(Color.White, board));
break;
case 'b':
board.SetPiece(currentSquare, new Bishop(Color.Black, board));
break;
case 'B':
board.SetPiece(currentSquare, new Bishop(Color.White, board));
break;
}
f++;
cPos++;
}
}
}
}