Diagnostics of irradiated gas in galaxy nuclei. I. A far-ultraviolet and X-ray dominated region code