using System.Collections.Generic;
using System.Xml;
namespace TeslaConsole.BattleTech;
///
/// A BattleTech scenario (game mode). Mirrors the Red Planet
/// Scenario/DeathRaceScenario pattern: it inherits the shared
/// map/vehicle/time/weather catalogs from (minus any
/// <invalid> exclusions) and adds the BT-specific option lists
/// (experience, camo, patch, emblem, role).
///
public class BTScenario
{
private readonly string mKey;
private readonly string mName;
private readonly Dictionary mMaps = new Dictionary();
private readonly Dictionary mVehicles = new Dictionary();
private readonly Dictionary mTimesOfDay = new Dictionary();
private readonly Dictionary mWeather = new Dictionary();
private readonly Dictionary mExperiences = new Dictionary();
private readonly Dictionary mColors = new Dictionary();
private readonly Dictionary mPatches = new Dictionary();
private readonly Dictionary mBadges = new Dictionary();
private readonly Dictionary mRoles = new Dictionary();
public string Key => mKey;
public string Name => mName;
public Dictionary Maps => mMaps;
public Dictionary Vehicles => mVehicles;
public Dictionary TimesOfDay => mTimesOfDay;
public Dictionary Weather => mWeather;
public Dictionary Experiences => mExperiences;
public Dictionary Colors => mColors;
public Dictionary Patches => mPatches;
public Dictionary Badges => mBadges;
public Dictionary Roles => mRoles;
internal BTScenario(XmlNode scenarioNode)
{
mKey = scenarioNode.Name;
mName = scenarioNode.Attributes["name"].InnerText;
List> invalid = new List>();
foreach (XmlNode childNode in scenarioNode.ChildNodes)
{
switch (childNode.Name)
{
case "invalid":
invalid.Add(new KeyValuePair(childNode.Attributes["type"].InnerText, childNode.Attributes["key"].InnerText));
break;
case "experience":
BTConfig.AddKeyNameNode(childNode, mExperiences);
break;
case "color":
BTConfig.AddKeyNameNode(childNode, mColors);
break;
case "patch":
BTConfig.AddKeyNameNode(childNode, mPatches);
break;
case "badge":
BTConfig.AddKeyNameNode(childNode, mBadges);
break;
case "role":
{
BTRole role = new BTRole(childNode);
mRoles.Add(role.Key, role);
break;
}
}
}
foreach (BTMap value in BTConfig.Maps.Values)
{
if (!IsInvalid("map", value.Key, invalid))
{
mMaps.Add(value.Key, value);
}
}
foreach (BTVehicle value2 in BTConfig.Vehicles.Values)
{
if (!IsInvalid("vehicle", value2.Key, invalid))
{
mVehicles.Add(value2.Key, value2);
}
}
foreach (KeyValuePair item in BTConfig.TimesOfDay)
{
if (!IsInvalid("time", item.Key, invalid))
{
mTimesOfDay.Add(item.Key, item.Value);
}
}
foreach (BTWeather value3 in BTConfig.Weather.Values)
{
if (!IsInvalid("weather", value3.Key, invalid))
{
mWeather.Add(value3.Key, value3);
}
}
}
private static bool IsInvalid(string type, string value, List> invalid)
{
foreach (KeyValuePair item in invalid)
{
if (item.Key == type && item.Value == value)
{
return true;
}
}
return false;
}
}