static void Main(string[] args) { GameplayDisplay b = new GameplayDisplay(); Gameboard a = new Gameboard(); b.Change(); a.InitializeGameboard(b, a); while (true) { b.AskSelectPiece(); a.JudgeSide(b); b.AskMovePiece(); a.NoPlaceToGo(b); a.CalculateValidMoves(b); a.MovePiece(b.posx, b.posy, b.posx2, b.posy2, b); Console.Clear(); Console.SetCursorPosition(0, 0); b.DisplayBoard(a); if (a.GameFinished(b)) { Console.WriteLine("Game over"); break; } } }
public void NoPlaceToGo(GameplayDisplay b) { while (b.posx == b.posx2 && b.posy == b.posy2) { k--; Console.WriteLine("Select again!"); b.AskSelectPiece(); JudgeSide(b); b.AskMovePiece(); } }
public void JudgeSide(GameplayDisplay b) { if (k % 2 == 0) { while ((chess[(b.posy) / 2, (b.posx) / 2].side) == 1 || (chess[(b.posy) / 2, (b.posx) / 2].side) == 3) { Console.WriteLine("You select the wrong piece!"); Console.WriteLine("Please enter again!"); Console.Write("\n"); b.AskSelectPiece(); } } if (k % 2 == 1) { while ((chess[(b.posy) / 2, (b.posx) / 2].side) == 0 || (chess[(b.posy) / 2, (b.posx) / 2].side) == 3) { Console.WriteLine("You select the wrong piece!"); Console.WriteLine("Please enter again!"); Console.Write("\n"); b.AskSelectPiece(); } } k++; }