Esempio n. 1
0
        /// <summary>
        /// returns how much factory hired in reality
        /// </summary>
        public int hireWorkforce(int amount, IEnumerable <PopUnit> popList)
        {
            //check on no too much workers?
            //if (amount > HowMuchWorkForceWants())
            //    amount = HowMuchWorkForceWants();
            int wasWorkforce = getWorkForce();

            if (amount > 0 && wasWorkforce == 0)
            {
                justHiredPeople = true;
            }
            else
            {
                justHiredPeople = false;
            }

            ClearWorkforce();
            if (amount > 0)
            {
                int leftToHire = amount;
                hiredLastTurn = 0;
                popList       = popList.OrderByDescending(x => x.Education.get()).ThenBy(x => x.getPopulation()).ToList();

                foreach (PopUnit pop in popList)

                //for (int i = popList.Count - 1; i >= 0; i--) //revert order
                {
                    //var pop = popList[i];
                    if (pop.getPopulation() >= leftToHire) // satisfied demand
                    {
                        hiredWorkForce.Add(pop, leftToHire);
                        //hiredLastTurn = getWorkForce() - wasWorkforce;

                        averageWorkersEducation.AddPoportionally(hiredLastTurn, leftToHire, pop.Education);
                        hiredLastTurn += leftToHire;
                        return(hiredLastTurn);
                        //break;
                    }
                    else
                    {
                        hiredWorkForce.Add(pop, pop.getPopulation()); // hire as we can
                        averageWorkersEducation.AddPoportionally(hiredLastTurn, pop.getPopulation(), pop.Education);
                        hiredLastTurn += pop.getPopulation();
                        leftToHire    -= pop.getPopulation();
                    }
                }
                //hiredLastTurn = getWorkForce() - wasWorkforce;
                return(hiredLastTurn);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 2
0
        public Procent getAverageMorale()
        {
            Procent result         = new Procent(0);
            int     calculatedSize = 0;

            foreach (var item in allArmies)
            {
                result.AddPoportionally(calculatedSize, item.getSize(), item.GetAverageCorps(x => x.getMorale()));
                calculatedSize += item.getSize();
            }
            return(result);
        }
Esempio n. 3
0
        //public bool canWinUprising()
        //{
        //    var defence = country.getDefenceForces();
        //    if (defence == null)
        //        return true;
        //    else
        //        return getMembership() > defence.getSize();
        //}


        private Procent getAverageLoyalty()
        {
            Procent result         = new Procent(0);
            int     calculatedSize = 0;

            foreach (var item in members)
            {
                result.AddPoportionally(calculatedSize, item.getPopulation(), item.loyalty);
                calculatedSize += item.getPopulation();
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// New value
        /// </summary>
        public static Procent GetAverageProcent(this IEnumerable <PopUnit> source, Func <PopUnit, Procent> selector)
        {
            Procent result = new Procent(0f);
            int     calculatedPopulation = 0;

            foreach (var item in source)
            {
                result.AddPoportionally(calculatedPopulation, item.getPopulation(), selector(item));
                calculatedPopulation += item.getPopulation();
            }
            return(result);
        }