You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.6 KiB
81 lines
3.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using OfficeOpenXml;
|
|
using static System.Text.RegularExpressions.Regex;
|
|
|
|
namespace FabStarterDeckGen
|
|
{
|
|
public class FABCollectionReader
|
|
{
|
|
public static readonly string COLUMN_NUMBER = "B";
|
|
public static readonly string COLUMN_NAME = "C";
|
|
public static readonly string COLUMN_RARITY = "D";
|
|
public static readonly string COLUMN_RED = "E";
|
|
public static readonly string COLUMN_YELLOW = "F";
|
|
public static readonly string COLUMN_BLUE = "G";
|
|
|
|
public static readonly string[] COLUMNS_PITCHES = { COLUMN_RED, COLUMN_YELLOW, COLUMN_BLUE };
|
|
public static readonly string[] COLUMNS_DETAILS = { COLUMN_NUMBER, COLUMN_NAME, COLUMN_RARITY };
|
|
|
|
public readonly int STARTING_ROW_INDEX = 3;
|
|
|
|
public Dictionary<string, int> CollectionCounts = new Dictionary<string, int>();
|
|
public void LoadCollection(string pFilePath, ReferenceCardLoader pReferenceCard)
|
|
{
|
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
|
using var package = new ExcelPackage(new FileInfo(pFilePath));
|
|
foreach (var sheet in package.Workbook.Worksheets)
|
|
{
|
|
var current_row_index = STARTING_ROW_INDEX;
|
|
var current_card_name = sheet.Cells[COLUMN_NAME + current_row_index.ToString()].Text;
|
|
while (current_card_name != "")
|
|
{
|
|
Console.WriteLine(current_card_name);
|
|
var reference_cards = pReferenceCard.GetCardsWithName(current_card_name);
|
|
|
|
foreach (var card in reference_cards)
|
|
{
|
|
if (card.IsPitchless)
|
|
{
|
|
if (!CollectionCounts.ContainsKey(card.CleanName))
|
|
CollectionCounts.Add(card.CleanName, 0);
|
|
|
|
CollectionCounts[card.CleanName] += int.Parse(sheet.Cells[COLUMN_RED + current_row_index.ToString()].Text);
|
|
}
|
|
else
|
|
{
|
|
if (card.IsRed)
|
|
{
|
|
if (!CollectionCounts.ContainsKey(card.CleanNameRed))
|
|
CollectionCounts.Add(card.CleanNameRed, 0);
|
|
|
|
CollectionCounts[card.CleanNameRed] += int.Parse(sheet.Cells[COLUMN_RED + current_row_index.ToString()].Text);
|
|
}
|
|
|
|
if (card.IsYellow)
|
|
{
|
|
if (!CollectionCounts.ContainsKey(card.CleanNameYellow))
|
|
CollectionCounts.Add(card.CleanNameYellow, 0);
|
|
|
|
CollectionCounts[card.CleanNameYellow] += int.Parse(sheet.Cells[COLUMN_YELLOW + current_row_index.ToString()].Text);
|
|
}
|
|
|
|
if (card.IsBlue)
|
|
{
|
|
if (!CollectionCounts.ContainsKey(card.CleanNameBlue))
|
|
CollectionCounts.Add(card.CleanNameBlue, 0);
|
|
|
|
CollectionCounts[card.CleanNameBlue] += int.Parse(sheet.Cells[COLUMN_BLUE + current_row_index.ToString()].Text);
|
|
}
|
|
}
|
|
}
|
|
|
|
current_row_index++;
|
|
current_card_name = sheet.Cells[COLUMN_NAME + current_row_index.ToString()].Text;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|