public Deck(DeckConfig deckConfig) { Categories = new List <Unit> [(int)UnitCategory._SIZE]; foreach (string categoryKey in Enum.GetNames(typeof(UnitCategory))) { if (Regex.IsMatch(categoryKey, @"^_")) { break; } int i = (int)Enum.Parse(typeof(UnitCategory), categoryKey); if (Categories[i] == null) { Categories[i] = new List <Unit>(); } foreach (string unitId in (List <string>)deckConfig[categoryKey]) { Unit unit = ConfigReader.FindUnit(unitId); unit.CategoryId = (byte)i; unit.Id = Categories[i].Count; Categories[i].Add(unit); } } }
public Deck(DeckConfig deckConfig, Armory armory) { Categories = new List <Unit> [(int)UnitCategory._SIZE]; for (int i = 0; i < (int)UnitCategory._SIZE; i++) { Categories[i] = new List <Unit>(); } foreach (string unitId in deckConfig.UnitIds) { bool exists = armory.Units.TryGetValue(unitId, out Unit unit); if (!exists) { Logger.LogConfig(LogLevel.ERROR, $"deck refers to non-existent unit {unitId}"); } Categories[unit.CategoryId].Add(unit); } }