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.
80 lines
3.6 KiB
80 lines
3.6 KiB
|
4 years ago
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Text.RegularExpressions;
|
||
|
|
using IronXL;
|
||
|
|
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)
|
||
|
|
{
|
||
|
|
WorkBook workbook = WorkBook.Load(pFilePath);
|
||
|
|
|
||
|
|
foreach (var sheet in workbook.WorkSheets)
|
||
|
|
{
|
||
|
|
var current_row_index = STARTING_ROW_INDEX;
|
||
|
|
var current_card_name = sheet[COLUMN_NAME + current_row_index.ToString()].StringValue;
|
||
|
|
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] += sheet[COLUMN_RED + current_row_index.ToString()].IntValue;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (card.IsRed)
|
||
|
|
{
|
||
|
|
if( !CollectionCounts.ContainsKey(card.CleanNameRed) )
|
||
|
|
CollectionCounts.Add(card.CleanNameRed, 0);
|
||
|
|
|
||
|
|
CollectionCounts[card.CleanNameRed] += sheet[COLUMN_RED + current_row_index.ToString()].IntValue;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (card.IsYellow)
|
||
|
|
{
|
||
|
|
if( !CollectionCounts.ContainsKey(card.CleanNameYellow) )
|
||
|
|
CollectionCounts.Add(card.CleanNameYellow, 0);
|
||
|
|
|
||
|
|
CollectionCounts[card.CleanNameYellow] += sheet[COLUMN_YELLOW + current_row_index.ToString()].IntValue;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (card.IsBlue)
|
||
|
|
{
|
||
|
|
if( !CollectionCounts.ContainsKey(card.CleanNameBlue) )
|
||
|
|
CollectionCounts.Add(card.CleanNameBlue, 0);
|
||
|
|
|
||
|
|
CollectionCounts[card.CleanNameBlue] += sheet[COLUMN_BLUE + current_row_index.ToString()].IntValue;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
current_row_index++;
|
||
|
|
current_card_name = sheet[COLUMN_NAME + current_row_index.ToString()].StringValue;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|