public bool makeMove(string col, uint x1, uint y1, uint x2, uint y2) { Piece p = getPieceAt(x1, y1); Square s1 = getSquareAt(x1, y1); Square s2 = getSquareAt(x2, y2); // Check if squares are ok. if (s1 == null || s2 == null) { return(false); } // Check if piece is ok. if (p == null) { return(false); } if (p.getColour() != col) { return(false); } if (!p.movePossible(x2, y2, getSquareAt)) { return(false); } // Move is legal // If there is a piece at x2,y2 then remove its cover. Piece p2 = s2.getPiece(); if (p2 != null) { foreach (Tuple <uint, uint> t in p2.getPossibleMoves(getSquareAt)) { // If moving piece is white, remove black cover, and vc.v. if (col == COLOUR_WHITE) { getSquareAt(t.Item1, t.Item2).removeBlackCover(); } else { getSquareAt(t.Item1, t.Item2).removeWhiteCover(); } } } // Remove from old position s1.removePiece(); foreach (Tuple <uint, uint> t in p.getPossibleMoves(getSquareAt)) { // If moving piece is white, remove white cover, and vc.v. if (col == COLOUR_WHITE) { getSquareAt(t.Item1, t.Item2).removeWhiteCover(); } else { getSquareAt(t.Item1, t.Item2).removeBlackCover(); } } // Add to new position getSquareAt(x2, y2).setPiece(p); p.move(x2, y2); foreach (Tuple <uint, uint> t in p.getPossibleMoves(getSquareAt)) { // If moving piece is white, add white cover, and vc.v. if (col == COLOUR_WHITE) { getSquareAt(t.Item1, t.Item2).addWhiteCover(); } else { getSquareAt(t.Item1, t.Item2).addBlackCover(); } } return(true); }