本文整理汇总了C#中IBoard.IsInsideBoard方法的典型用法代码示例。如果您正苦于以下问题:C# IBoard.IsInsideBoard方法的具体用法?C# IBoard.IsInsideBoard怎么用?C# IBoard.IsInsideBoard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBoard
的用法示例。
在下文中一共展示了IBoard.IsInsideBoard方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRequest
/// <summary>
/// The implementation of the request handler dealing with coordinates outside of the board
/// </summary>
/// <param name="row">The passed int for row</param>
/// <param name="col">The passed int for column</param>
/// <param name="board">The current playing board</param>
public override void HandleRequest(int row, int col, IBoard board)
{
if (!board.IsInsideBoard(row, col))
{
board.ChangeBoardState(new Notification(GlobalMessages.OutOfBorders, BoardState.Pending));
}
else if (this.Successor != null)
{
this.Successor.HandleRequest(row, col, board);
}
}
示例2: HandleRequest
/// <summary>
/// A method that checks whether the command is valid and deals with it or calls its successor to handle the request
/// </summary>
/// <param name="command">String with the incoming command</param>
/// <param name="board">The current playing board</param>
public override void HandleRequest(string command, IBoard board)
{
this.IsInvalid = false;
int row = -1;
int col = -1;
string trimmedCommand = command.Trim();
string[] commandComponents = trimmedCommand.Split(GlobalConstants.CommandParametersDivider);
if (commandComponents.Length < 2 || commandComponents.Length > 2)
{
this.IsInvalid = true;
}
else
{
bool rowIsNumeric = int.TryParse(commandComponents[0], out row);
bool colIsNumeric = int.TryParse(commandComponents[1], out col);
if (!(rowIsNumeric && colIsNumeric))
{
this.IsInvalid = true;
}
}
if (this.IsInvalid)
{
board.ChangeBoardState(new Notification(GlobalMessages.InvalidCommand, BoardState.Pending));
}
else if (this.Successor != null)
{
if (board.IsInsideBoard(row, col) && board.Cells[row, col].Content.Value == 0)
{
this.Accumulate(row, col, board);
// Reset list for next play command
this.visited.Clear();
}
else
{
this.Successor.HandleRequest(row, col, board);
}
}
base.HandleRequest(row, col, board);
base.HandleRequest(row + " " + col, board);
}
示例3: Accumulate
/// <summary>
/// Accumulates the zero-content board cells
/// </summary>
/// <param name="row">Root cell row</param>
/// <param name="col">Roow cell column</param>
/// <param name="board">Board to which the cells to accumulate belong</param>
private void Accumulate(int row, int col, IBoard board)
{
for (int i = row - 1; i <= row + 1; i++)
{
for (int j = col - 1; j <= col + 1; j++)
{
var coordinate = new Coordinate(i, j);
if (this.visited.Contains(coordinate))
{
continue;
}
if (board.IsInsideBoard(i, j))
{
if (board.Cells[i, j].Content.Value == 0)
{
this.visited.Add(coordinate);
this.Successor.HandleRequest(i, j, board);
this.Accumulate(i, j, board);
}
}
}
}
}