Example #1
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.getProcent(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);
            }
        }