private EnumValue[] GetEnumValues(Type enumType)
 {
     return(enumType != null?Enum.GetValues(enumType)
            .Cast <object>()
            .Select(v => EnumValue.Create(enumType, v))
            .ToArray() : null);
 }
 protected void BuyStock(FloatRangePerPowerLevel perPowerLevelItemBudgetRange)
 {
     for (int i = 0; i < powerLevelEnum.Length; i++)
     {
         EnumValue powerLevel = EnumValue.Create(powerLevelEnum, i);
         BuyStockAtPowerLevel(powerLevel, stockAvailability[powerLevel], perPowerLevelItemBudgetRange[powerLevel]);
     }
 }
    public void AddRandom(string powerLevel, FloatRangePerPowerLevel perPowerLevelItemBudgetRange)
    {
        TSpecificItem[] newSpecificItems = new TSpecificItem[specificItems.Length + 1];
        for (int i = 0; i < specificItems.Length; i++)
        {
            newSpecificItems[i] = specificItems[i];
        }
        EnumValue itemPowerLevel = EnumValue.Create(powerLevelEnum, powerLevelEnum[powerLevel]);

        newSpecificItems[specificItems.Length] = CreateRandomSpecificItem(itemPowerLevel, perPowerLevelItemBudgetRange[powerLevel]);
        specificItems = newSpecificItems;
    }
    protected void BuyStockAtPowerLevel(EnumValue powerLevel, IntRange stockRange, FloatRange itemBudgetRange)
    {
        int   desiredCount  = stockRange.Random();
        int   currentCount  = GetTotalCount(powerLevel);
        float currentBudget = GetTotalCost(powerLevel);

        int   requiredStockCount = desiredCount - currentCount;
        float desiredTotalBudget = itemBudgetRange.Mean * requiredStockCount;

        if (requiredStockCount > 0)
        {
            float requiredStockBudget = desiredTotalBudget - currentBudget;

            if (requiredStockBudget > 0)
            {
                for (int i = 0; i < requiredStockCount; i++)
                {
                    EnumValue     itemPowerLevel     = EnumValue.Create(powerLevelEnum, powerLevelEnum[powerLevel]);
                    TSpecificItem randomSpecificItem = CreateRandomSpecificItem(itemPowerLevel, itemBudgetRange);
                    Add(randomSpecificItem);
                }
            }
        }
    }
    public void ReplaceWithRandom(int index, string powerLevel, FloatRangePerPowerLevel perPowerLevelItemBudgetRange)
    {
        EnumValue itemPowerLevel = EnumValue.Create(powerLevelEnum, powerLevelEnum[powerLevel]);

        specificItems[index] = CreateRandomSpecificItem(itemPowerLevel, perPowerLevelItemBudgetRange[itemPowerLevel]);
    }