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 InitializeGameboard(GameplayDisplay b, Gameboard a) { b.Change(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 9; j++) { chess[i, j] = new GameboardPiece.blank(3); } } chess[0, 0] = new GameboardPiece.Rook(0); chess[0, 1] = new GameboardPiece.Horse(0); chess[0, 2] = new GameboardPiece.Elephant(0); chess[0, 3] = new GameboardPiece.Advisor(0); chess[0, 4] = new GameboardPiece.General(0); chess[0, 5] = new GameboardPiece.Advisor(0); chess[0, 6] = new GameboardPiece.Elephant(0); chess[0, 7] = new GameboardPiece.Horse(0); chess[0, 8] = new GameboardPiece.Rook(0); chess[2, 1] = new GameboardPiece.Cannon(0); chess[2, 7] = new GameboardPiece.Cannon(0); chess[3, 0] = new GameboardPiece.Soldier(0); chess[3, 2] = new GameboardPiece.Soldier(0); chess[3, 4] = new GameboardPiece.Soldier(0); chess[3, 6] = new GameboardPiece.Soldier(0); chess[3, 8] = new GameboardPiece.Soldier(0); chess[9, 0] = new GameboardPiece.Rook(1); chess[9, 1] = new GameboardPiece.Horse(1); chess[9, 2] = new GameboardPiece.Elephant(1); chess[9, 3] = new GameboardPiece.Advisor(1); chess[9, 4] = new GameboardPiece.General(1); chess[9, 5] = new GameboardPiece.Advisor(1); chess[9, 6] = new GameboardPiece.Elephant(1); chess[9, 7] = new GameboardPiece.Horse(1); chess[9, 8] = new GameboardPiece.Rook(1); chess[7, 1] = new GameboardPiece.Cannon(1); chess[7, 7] = new GameboardPiece.Cannon(1); chess[6, 0] = new GameboardPiece.Soldier(1); chess[6, 2] = new GameboardPiece.Soldier(1); chess[6, 4] = new GameboardPiece.Soldier(1); chess[6, 6] = new GameboardPiece.Soldier(1); chess[6, 8] = new GameboardPiece.Soldier(1); b.a[0, 0] = chess[0, 0].ToChar(); b.a[0, 2] = chess[0, 1].ToChar(); b.a[0, 4] = chess[0, 2].ToChar(); b.a[0, 6] = chess[0, 3].ToChar(); b.a[0, 8] = chess[0, 4].ToChar(); b.a[0, 10] = chess[0, 5].ToChar(); b.a[0, 12] = chess[0, 6].ToChar(); b.a[0, 14] = chess[0, 7].ToChar(); b.a[0, 16] = chess[0, 8].ToChar(); b.a[4, 2] = chess[2, 1].ToChar(); b.a[4, 14] = chess[2, 7].ToChar(); b.a[6, 0] = chess[3, 0].ToChar(); b.a[6, 4] = chess[3, 2].ToChar(); b.a[6, 8] = chess[3, 4].ToChar(); b.a[6, 12] = chess[3, 6].ToChar(); b.a[6, 16] = chess[3, 8].ToChar(); b.a[18, 0] = chess[9, 0].ToChar(); b.a[18, 2] = chess[9, 1].ToChar(); b.a[18, 4] = chess[9, 2].ToChar(); b.a[18, 6] = chess[9, 3].ToChar(); b.a[18, 8] = chess[9, 4].ToChar(); b.a[18, 10] = chess[9, 5].ToChar(); b.a[18, 12] = chess[9, 6].ToChar(); b.a[18, 14] = chess[9, 7].ToChar(); b.a[18, 16] = chess[9, 8].ToChar(); b.a[14, 2] = chess[7, 1].ToChar(); b.a[14, 14] = chess[7, 7].ToChar(); b.a[12, 0] = chess[6, 0].ToChar(); b.a[12, 4] = chess[6, 2].ToChar(); b.a[12, 8] = chess[6, 4].ToChar(); b.a[12, 12] = chess[6, 6].ToChar(); b.a[12, 16] = chess[6, 8].ToChar(); b.DisplayBoard(a); }