Esempio n. 1
0
    internal static Factory getMostPracticlyProfitable(Province province)
    {
        List <FactoryType> possiblefactories = province.WhatFactoriesCouldBeBuild();
        float profit         = 0;
        float maxProfitFound = 0;

        foreach (Factory ft in province.allFactories)
        {
            if (province.CanUpgradeFactory(ft.type))
            {
                profit = ft.getProfit();
                if (profit > maxProfitFound)
                {
                    maxProfitFound = profit;
                }
            }
        }
        if (maxProfitFound > 0f)
        {
            foreach (Factory factory in province.allFactories)
            {
                if (factory.getProfit() == maxProfitFound && province.CanUpgradeFactory(factory.type))
                {
                    return(factory);
                }
            }
        }
        return(null);
    }
Esempio n. 2
0
    internal static FactoryType getMostTeoreticalProfitable(Province province)
    {
        List <FactoryType> possiblefactories = province.WhatFactoriesCouldBeBuild();
        float possibleProfit = 0;
        float maxProfitFound = 0;

        foreach (FactoryType ft in possiblefactories)
        {
            // if (province.CanBuildNewFactory(ft) || province.CanUpgradeFactory(ft))
            {
                possibleProfit = ft.getPossibleProfit(province);
                if (possibleProfit > maxProfitFound)
                {
                    maxProfitFound = possibleProfit;
                }
            }
        }
        if (maxProfitFound > 0f)
        {
            foreach (FactoryType ft in possiblefactories)
            {
                if (ft.getPossibleProfit(province) == maxProfitFound && (province.CanBuildNewFactory(ft) || province.CanUpgradeFactory(ft)))
                {
                    return(ft);
                }
            }
        }
        return(null);
    }