-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
40 lines (35 loc) · 976 Bytes
/
Game.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chess_Game
{
class Game
{
public ChessBoard chessBoard;
public BoardViewer viewer;
public Game()
{
chessBoard = new ChessBoard();
viewer = new BoardViewer();
while (true)
{
viewer.Show(chessBoard.Board);
makeMove(viewer.getMoveInput());
}
}
private void makeMove(Move move)
{
Piece piece = chessBoard.getSquare(move.from).Piece;
if (piece == null || !piece.validateMove(move, chessBoard))
{
Console.WriteLine("Invalid move.");
return;
}
chessBoard.getSquare(move.to).Piece = piece;
piece.Moved = true;
chessBoard.getSquare(move.from).Piece = null;
}
}
}