public static bool Move(Board board, String Direction) { var c = ExplicitCast.castAsCorrectPiece(board.ListOfPieces.FirstOrDefault(bp => bp.Type == 1)); Position moveTo = GetPositionFromDirection(board, Direction); if (BoardController.IsExit(board, moveTo)) { board.CharacterEscaped = true; return(true); } if (BoardController.IsOccupied(board, moveTo)) { return(false); } if (!BoardController.WithinBounds(board, moveTo)) { return(false); } BoardController.MovePiece(board, c.pos, moveTo); return(true); }
public static bool Attack(Board board, String Direction) { var c = ExplicitCast.castAsCorrectPiece(board.ListOfPieces.FirstOrDefault(bp => bp.Type == 1)); Position attackTo = GetPositionFromDirection(board, Direction); if (BoardController.IsExit(board, attackTo)) { return(false); } if (!BoardController.WithinBounds(board, attackTo)) { return(false); } BoardController.Attack(board, attackTo); return(true); }