Example #1
0
        public int timeNeededToChangeTo(Stat.Governement nextGov)
        {
            int minTurns = 1, maxTurns = 5, turns = 1;

            switch (nextGov.thisSupport)
            {
            case Stat.Governement.supportType.military:
                // many units
                float unitsPerCity = (float)totMilitaryUnits / (float)totCities;
                turns = maxTurns - (int)(Math.Pow(unitsPerCity, 2) / 3);                             // unitsPerCity = 0 -> 5, 1 -> 4, 2 -> 3, 3 -> 3, 0 -> 4, 16 -> 0
                break;

            case Stat.Governement.supportType.people:
                // small unified pop
                turns = 3;
                break;

            case Stat.Governement.supportType.religion:
                // high culture
                turns = 3;
                break;

            case Stat.Governement.supportType.wealth:
                // + slavery, wealthy/power

                int[] citiesWealth = new int[cityNumber];
                int   totWealth    = 0;
                for (int c = 1; c <= cityNumber; c++)
                {
                    if (!cityList[c].dead)
                    {
                        citiesWealth[c] = cityList[c].realTrade + cityList[c].realProduction;
                        totWealth      += cityList[c].realTrade + cityList[c].realProduction;
                    }
                    else
                    {
                        citiesWealth[c] = -1;
                    }
                }

                int[]  order          = count.descOrder(citiesWealth);
                int    totWealthiest  = 0;
                double percWealthiest = 0.25;

                for (int i = 0; i < order.Length && i < cityNumber * percWealthiest && citiesWealth[order[i]] > 0; i++)
                {
                    totWealthiest += citiesWealth[order[i]];
                }

                //	if ( totWealthiest > totWealth / 3 ) // 1th of the nation should have 1 half of the wealth

                turns = minTurns + (int)((maxTurns - minTurns) * (((double)totWealthiest / (double)totWealth) - percWealthiest * (1 - percWealthiest)));

                if (economyType == (byte)enums.economies.slaveryRacial || economyType == (byte)enums.economies.slaverySocial)
                {
                    turns /= 2;
                }

                break;
            }

            if (turns > maxTurns)
            {
                turns = maxTurns;
            }

            if (turns < minTurns)
            {
                turns = minTurns;
            }

            return(turns);
        }
Example #2
0
 public void initiateRevolution(Stat.Governement nextGov)
 {
     int turns = timeNeededToChangeTo(nextGov);
 }