Example #1
0
    public float determineCanProduce(MyEnum.Goods good, Nation player)
    {
        Dictionary <string, float> costs = ProductionCosts.GetCosts(good);
        float bottleNeck    = 1000f;
        float nextComponent = 0.0f;
        float ratio;
        float materialMod = DetermineMaterialMod(player);

        foreach (string item in costs.Keys)
        {
            if (Enum.IsDefined(typeof(MyEnum.Goods), item))
            {
                MyEnum.Goods itemType = (MyEnum.Goods)System.
                                        Enum.Parse(typeof(MyEnum.Goods), item);
                nextComponent = player.getNumberGood(itemType) * materialMod;
                ratio         = nextComponent / costs[item];
            }
            else
            {
                MyEnum.Resources itemType = (MyEnum.Resources)System.
                                            Enum.Parse(typeof(MyEnum.Resources), item);
                nextComponent = player.getNumberResource(itemType) * materialMod;
                ratio         = nextComponent / costs[item];
            }
            if (ratio < bottleNeck)
            {
                bottleNeck = ratio;
            }
        }
        int value        = 0;
        int factoryLevel = getFactoryLevel(good);

        if (factoryLevel == 0)
        {
            value = 0;
        }
        if (factoryLevel == 1)
        {
            value = (int)Math.Min(4, bottleNeck);
        }
        if (factoryLevel == 2)
        {
            value = (int)Math.Min(8, bottleNeck);
        }
        float corruptionFactor    = PlayerCalculator.getCorruptionFactor(player);
        float industrialExpFactor = PlayerCalculator.getIndustrialExperienceFactor(player);

        /*Later additional modifiers will affect this including:
         * Corruptuon, happiness, management level, and perhaps some
         * technologies */
        value = (int)(value * corruptionFactor * industrialExpFactor);
        return(value);
    }