FSHF
✅ How to make this loop
switch (chessPiece)
{
case "Knight":
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber -1))
theGrid[currentCell.RowNumber + 2, currentCell.ColumnNumber + 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 2, currentCell.ColumnNumber - 1))
theGrid[currentCell.RowNumber + 2, currentCell.ColumnNumber - 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber +1))
theGrid[currentCell.RowNumber - 2, currentCell.ColumnNumber + 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber -1))
theGrid[currentCell.RowNumber - 2, currentCell.ColumnNumber - 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 1, currentCell.ColumnNumber + 2))
theGrid[currentCell.RowNumber + 1, currentCell.ColumnNumber + 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 1, currentCell.ColumnNumber - 2))
theGrid[currentCell.RowNumber + 1, currentCell.ColumnNumber - 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber - 1, currentCell.ColumnNumber + 2))
theGrid[currentCell.RowNumber - 1, currentCell.ColumnNumber + 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -1, currentCell.ColumnNumber -2))
theGrid[currentCell.RowNumber - 1, currentCell.ColumnNumber - 2].LegalNextMove = true;
break;
switch (chessPiece)
{
case "Knight":
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber -1))
theGrid[currentCell.RowNumber + 2, currentCell.ColumnNumber + 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 2, currentCell.ColumnNumber - 1))
theGrid[currentCell.RowNumber + 2, currentCell.ColumnNumber - 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber +1))
theGrid[currentCell.RowNumber - 2, currentCell.ColumnNumber + 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -2, currentCell.ColumnNumber -1))
theGrid[currentCell.RowNumber - 2, currentCell.ColumnNumber - 1].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 1, currentCell.ColumnNumber + 2))
theGrid[currentCell.RowNumber + 1, currentCell.ColumnNumber + 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber + 1, currentCell.ColumnNumber - 2))
theGrid[currentCell.RowNumber + 1, currentCell.ColumnNumber - 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber - 1, currentCell.ColumnNumber + 2))
theGrid[currentCell.RowNumber - 1, currentCell.ColumnNumber + 2].LegalNextMove = true;
if(isSafe(currentCell.RowNumber -1, currentCell.ColumnNumber -2))
theGrid[currentCell.RowNumber - 1, currentCell.ColumnNumber - 2].LegalNextMove = true;
break;
12 replies
clone
Instead of removing last number i would like to clone, how?
private void btnpocl(object sender, EventArgs e)
{
if (ccal.Length > 0)
{
ccal = ccal.Remove(ccal.Length - 1, 1);
}
txtbout.Text = ccal;
}
private void btnpocl(object sender, EventArgs e)
{
if (ccal.Length > 0)
{
ccal = ccal.Remove(ccal.Length - 1, 1);
}
txtbout.Text = ccal;
}
57 replies