Beispiel #1
0
        /// <summary>
        /// howMuchShouldBeInSecondArmy - procent of this army. Returns second army
        /// </summary>
        public Army balance(Procent howMuchShouldBeInSecondArmy)
        {
            owner.armyCount++;
            Army secondArmy = new Army(owner, Province, owner + "'s " + owner.armyCount.ToString() + "th");

            int secondArmyExpectedSize = howMuchShouldBeInSecondArmy.getProcentOf(getSize());

            //secondArmy.clear();

            int needToFullFill = secondArmyExpectedSize;

            while (needToFullFill > 0)
            {
                var corpsToBalance = getBiggestCorpsSmallerThan(needToFullFill);
                if (corpsToBalance == null)
                {
                    break;
                }
                else
                {
                    moveCorps(corpsToBalance, secondArmy);
                }
                needToFullFill = secondArmyExpectedSize - secondArmy.getSize();
            }

            return(secondArmy);
        }
Beispiel #2
0
        internal Army balance(Procent howMuchShouldBeInSecondArmy)
        {
            //if (howMuchShouldBeInSecondArmy.get() == 1f)
            //{
            //    return this;
            //    //this.personal.Clear();
            //}
            //else
            {
                Army secondArmy = new Army(this.getOwner());

                //Army sumArmy = new Army();
                //sumArmy.add(this);
                //this.joinin(secondArmy);
                int secondArmyExpectedSize = howMuchShouldBeInSecondArmy.getProcentOf(this.getSize());

                //secondArmy.clear();

                int needToFullFill = secondArmyExpectedSize;
                while (needToFullFill > 0)
                {
                    var corpsToBalance = this.getBiggestCorpsSmallerThan(needToFullFill);
                    if (corpsToBalance == null)
                    {
                        break;
                    }
                    else
                    {
                        this.move(corpsToBalance, secondArmy);
                    }
                    needToFullFill = secondArmyExpectedSize - secondArmy.getSize();
                }
                return(secondArmy);
            }
        }