using System;
using System.Collections.Generic;
using UnityEngine;

public class CsvImporter : MonoBehaviour
{
	private void Start()
	{
	}

	public int GetCsvDataMs(string fileName)
	{
		if (!GameUty.FileSystem.IsExistentFile(fileName))
		{
			NDebug.Assert("表がありません。" + fileName, false);
		}
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, fileName + "\nopen failed.");
				int i = 0;
				List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
				for (i = 1; i < csvParser.max_cell_y; i++)
				{
					if (csvParser.IsCellToExistData(0, i))
					{
						string cellAsString = csvParser.GetCellAsString(0, i);
						Debug.Log("cell = " + cellAsString);
						return int.Parse(cellAsString);
					}
				}
			}
		}
		return -1;
	}

	public void GetCsvData(string fileName)
	{
		if (!GameUty.FileSystem.IsExistentFile(fileName))
		{
			NDebug.Assert("表がありません。" + fileName, false);
		}
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, fileName + "\nopen failed.");
				int i = 0;
				List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
				for (i = 1; i < csvParser.max_cell_y; i++)
				{
					if (csvParser.IsCellToExistData(0, i))
					{
						int j = 0;
						int num = 0;
						for (j = 0; j < csvParser.max_cell_x; j++)
						{
							if (csvParser.IsCellToExistData(j, i))
							{
								switch (j)
								{
								case 1:
								{
									string cellAsString = csvParser.GetCellAsString(j, i);
									if (cellAsString == null)
									{
										goto IL_1B1;
									}
									if (CsvImporter.<>f__switch$map5 == null)
									{
										CsvImporter.<>f__switch$map5 = new Dictionary<string, int>(7)
										{
											{
												"スリーセブン",
												0
											},
											{
												"BAR",
												1
											},
											{
												"ピエロ",
												2
											},
											{
												"ベル",
												3
											},
											{
												"メダル",
												4
											},
											{
												"ぶどう",
												5
											},
											{
												"チェリー",
												6
											}
										};
									}
									int num2;
									if (!CsvImporter.<>f__switch$map5.TryGetValue(cellAsString, out num2))
									{
										goto IL_1B1;
									}
									switch (num2)
									{
									case 0:
										num = 0;
										break;
									case 1:
										num = 1;
										break;
									case 2:
										num = 2;
										break;
									case 3:
										num = 3;
										break;
									case 4:
										num = 4;
										break;
									case 5:
										num = 5;
										break;
									case 6:
										num = 6;
										break;
									case 7:
										goto IL_1B1;
									default:
										goto IL_1B1;
									}
									break;
									IL_1B1:
									num = -1;
									break;
								}
								case 2:
									if (num != -1)
									{
										this.payDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
									}
									break;
								case 3:
									if (num != -1)
									{
										this.normalDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
										this.normalMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
									}
									break;
								case 4:
									if (num != -1)
									{
										this.chanceDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
										this.chanceMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
									}
									break;
								}
							}
						}
					}
				}
			}
		}
	}

	public int GetCsvDataParse(int id)
	{
		if (id == 0)
		{
			return this.normalMaxProb;
		}
		if (id != 1)
		{
			return -1;
		}
		return this.chanceMaxProb;
	}

	public int[] GetCsvDataParseList(int id)
	{
		if (id == 0)
		{
			return this.payDividend;
		}
		if (id == 1)
		{
			return this.normalDividend;
		}
		if (id != 2)
		{
			return null;
		}
		return this.chanceDividend;
	}

	public int[] normalDividend = new int[8];

	public int[] chanceDividend = new int[8];

	public int[] payDividend = new int[8];

	public int normalMaxProb;

	public int chanceMaxProb;
}
