using System.Xml;

namespace TeslaConsole.BattleTech;

/// <summary>
/// A BattleTech weather option. Unlike Red Planet (where weather is a plain
/// key/name pair), a BT weather entry also carries the ambient temperature that
/// becomes the egg's <c>[mission] temperature=</c> field.
/// </summary>
public class BTWeather
{
	private readonly string mKey;

	private readonly string mName;

	private readonly int mTemperature;

	public string Key => mKey;

	public string Name => mName;

	public int Temperature => mTemperature;

	internal BTWeather(XmlNode weatherNode)
	{
		mKey = weatherNode.Attributes["key"].InnerText;
		mName = weatherNode.Attributes["name"].InnerText;
		XmlAttribute xmlAttribute = weatherNode.Attributes["temperature"];
		mTemperature = ((xmlAttribute != null) ? int.Parse(xmlAttribute.InnerText) : 0);
	}

	public override string ToString()
	{
		return mName;
	}
}
