Example #1
0
        // private Army consolidatedArmy;

        public Army(Staff owner, Province where, string name) : base(name)
        {
            //if (!this.armies.Contains(this))
            where.AddArmy(this);

            Province = where;
            owner.addArmy(this);
            this.owner = owner;


            World.DayPassed += OnMoveArmy;
            //Province.OwnerChanged += CheckPathOnProvinceOwnerChanged;
            personal = new Dictionary <PopUnit, Corps>();
            foreach (var pop in where.GetAllPopulation()) //mirrored in Staff. mobilization
            {
                if (pop.Type.canMobilize(owner) && pop.howMuchCanMobilize(owner, null) > 0)
                {
                    //newArmy.add(item.mobilize(this));
                    this.add(Corps.mobilize(owner, pop));
                }
            }

            var unitObject = Unit.Create(this);

            unit = unitObject.GetComponent <Unit>();

            Game.provincesToRedrawArmies.Add(where);
            OnMoveArmy(this, EventArgs.Empty);
            foreach (var enemyArmy in Province.AllStandingArmies().Where(x => x.owner != owner).ToList())
            {
                if (enemyArmy.getSize() > 0)
                {
                    this.attack(enemyArmy).createMessage();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Enterprise rises salary if labor demand is bigger than labor supply (assuming enterprise is profitable). And vice versa - enterprise lowers salary if labor demand is lower than labor supply.
        ///More profitable enterprise rises salary faster.
        /// </summary>
        public void ChangeSalary()
        {
            //Should be rise salary if: small unemployment, has profit, need has other resources

            if (IsOpen && Economy.isMarket.checkIfTrue(Country))
            {
                var unemployment = Province.GetAllPopulation().Where(x => x.Type == PopType.Workers).GetAverageProcent(x => x.getUnemployment());
                var margin       = GetMargin();

                // rise salary to attract  workforce, including workforce from other factories
                if (margin.isBiggerThan(Options.minMarginToRiseSalary) &&
                    unemployment.isSmallerThan(Options.ProvinceLackWorkforce) && //demand >= supply
                    GetVacancies() > 10)   // && getInputFactor() == 1)
                {
                    // cant catch up salaries like that. Check for zero workforce?
                    float salaryRaise = 0.001f; //1%
                    if (margin.get() > 10f)     //1000%
                    {
                        salaryRaise = 0.012f;
                    }
                    else if (margin.get() > 1f) //100%
                    {
                        salaryRaise = 0.006f;
                    }
                    else if (margin.get() > 0.3f) //30%
                    {
                        salaryRaise = 0.003f;
                    }
                    else if (margin.get() > 0.1f) //10%
                    {
                        salaryRaise = 0.002f;
                    }

                    salary.add(salaryRaise);
                }

                // Reduce salary on non-profit
                if (margin.isZero() &&
                    daysUnprofitable >= Options.minDaysBeforeSalaryCut &&
                    !isJustHiredPeople() && !isSubsidized())
                {
                    salary.Subtract(0.01f, false);
                }

                // if supply > demand
                if (unemployment.isBiggerThan(Options.ProvinceExcessWorkforce))
                {
                    salary.Subtract(0.001f, false);
                }

                if (getWorkForce() == 0)// && getInputFactor() == 1)
                {
                    salary.set(Province.getLocalMinSalary());
                }
                // to help factories catch up other factories salaries
                //    salary.set(province.getLocalMinSalary());
                // freshly built factories should rise salary to concurrency with old ones
                //if (getWorkForce() < 100 && Province.getUnemployedWorkers() == 0 && this.Cash.get() > 10f)// && getInputFactor() == 1)
                //    //salary.set(province.getLocalMinSalary());
                //    salary.add(0.09f);


                // limit salary country's min wage
                var minSalary = Country.getMinSalary();
                if (salary.isSmallerThan(minSalary))
                {
                    salary.set(minSalary);
                }
            }
        }