using System;
using System.Collections.Generic;

namespace Kasizuki
{
	public static class WorkCountReplace
	{
		public static string GetWorkCountName(int workCount)
		{
			WorkCountReplace.CreateData();
			string text = string.Empty;
			foreach (KeyValuePair<int, string> keyValuePair in WorkCountReplace.basicData)
			{
				int key = keyValuePair.Key;
				if (workCount < key)
				{
					break;
				}
				text = keyValuePair.Value;
			}
			if (string.IsNullOrEmpty(text))
			{
				NDebug.Assert("Error WorkCountReplace.GetWorkCountName(int)", false);
			}
			return text;
		}

		public static SortedDictionary<int, string> GetDic()
		{
			WorkCountReplace.CreateData();
			return WorkCountReplace.basicData;
		}

		private static void CreateData()
		{
			if (WorkCountReplace.basicData != null)
			{
				return;
			}
			WorkCountReplace.basicData = new SortedDictionary<int, string>();
			string str = "kasizuki_work_count_convert_list";
			using (AFileBase afileBase = GameUty.FileSystem.FileOpen(str + ".nei"))
			{
				using (CsvParser csvParser = new CsvParser())
				{
					bool condition = csvParser.Open(afileBase);
					NDebug.Assert(condition, str + "\nopen failed.");
					for (int i = 1; i < csvParser.max_cell_y; i++)
					{
						int num = 0;
						int cellAsInteger = csvParser.GetCellAsInteger(num++, i);
						string cellAsString = csvParser.GetCellAsString(num++, i);
						WorkCountReplace.basicData.Add(cellAsInteger, cellAsString);
					}
				}
			}
		}

		private const string csvFileName = "kasizuki_work_count_convert_list";

		private static SortedDictionary<int, string> basicData;
	}
}
