Ejemplo n.º 1
0
        /// <summary>
        /// Формирование структуры, для формул получения урона
        /// </summary>
        /// <returns>Список классов SameType</returns>
        internal List<SameType> TheSames()
        {
            //var accuracy = 0.05;
            var same0 = new SameType(); var same1 = new SameType(); var same2 = new SameType();
            var same3 = new SameType(); var same4 = new SameType(); var same5 = new SameType();
            int infantry = ActiveInfantryCount();
            int curInfantry = 0;
            int heavyWeap = HeavyWeaponCount();
            int curHeavyWeap = 0;

            foreach (var item in Items)
            {
                if (item is EquipmentMark)
                {
                    if (((EquipmentMark)item).Armor == Caliber.smallArms)
                    {
                        if (curInfantry < infantry)
                        {
                            same0.Count += item.Count;
                            //same0.Damage += item.Count  * ((EquipmentMark)item).FireRate * accuracy;
                            same0.UnitType.Add(item);
                            curInfantry += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.largeSmallArms)
                    {
                        //if (curInfantry < infantry)
                        //{
                        //    same1.Count += item.Count;
                        //    //same1.Damage += item.Count * ((EquipmentMark)item).FireRate * accuracy;
                        //    same1.UnitType.Add(item);
                        //    curInfantry += item.Count;
                        //}
                        //TODO тяжелые пулеметы не учитываются, хотя вроде они и не сюда.
                        if ((curHeavyWeap < heavyWeap) && (((EquipmentMark)item).Crew > 1))
                        {
                            same1.Count += item.Count;
                            //same2.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same1.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.small)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same2.Count += item.Count;
                            //same2.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same2.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.medium)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same3.Count += item.Count;
                            //same3.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same3.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.large)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same4.Count += item.Count;
                            //same4.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same4.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.extraLarge)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same5.Count += item.Count;
                            //same5.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same5.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                }
            }
            var sames = new List<SameType>() { same0, same1, same2, same3, same4, same5 };
            foreach (var same in sames)
            {
                var temp = new List<double>();
                foreach (var probType in same0.UnitType)
                {
                    if (same.Count == 0) temp.Add(0);
                    else
                    {
                        temp.Add(probType.Count / same.Count);
                    }
                }
                same.Probabilities = temp;
            }

            return sames;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Формирование структуры, для формул получения урона
        /// </summary>
        /// <returns>Список классов SameType</returns>
        internal List <SameType> TheSames()
        {
            //var accuracy = 0.05;
            var same0 = new SameType(); var same1 = new SameType(); var same2 = new SameType();
            var same3 = new SameType(); var same4 = new SameType(); var same5 = new SameType();
            int infantry     = ActiveInfantryCount();
            int curInfantry  = 0;
            int heavyWeap    = HeavyWeaponCount();
            int curHeavyWeap = 0;

            foreach (var item in Items)
            {
                if (item is EquipmentMark)
                {
                    if (((EquipmentMark)item).Armor == Caliber.smallArms)
                    {
                        if (curInfantry < infantry)
                        {
                            same0.Count += item.Count;
                            //same0.Damage += item.Count  * ((EquipmentMark)item).FireRate * accuracy;
                            same0.UnitType.Add(item);
                            curInfantry += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.largeSmallArms)
                    {
                        //if (curInfantry < infantry)
                        //{
                        //    same1.Count += item.Count;
                        //    //same1.Damage += item.Count * ((EquipmentMark)item).FireRate * accuracy;
                        //    same1.UnitType.Add(item);
                        //    curInfantry += item.Count;
                        //}
                        //TODO тяжелые пулеметы не учитываются, хотя вроде они и не сюда.
                        if ((curHeavyWeap < heavyWeap) && (((EquipmentMark)item).Crew > 1))
                        {
                            same1.Count += item.Count;
                            //same2.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same1.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.small)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same2.Count += item.Count;
                            //same2.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same2.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.medium)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same3.Count += item.Count;
                            //same3.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same3.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.large)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same4.Count += item.Count;
                            //same4.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same4.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                    if (((EquipmentMark)item).Armor == Caliber.extraLarge)
                    {
                        if (curHeavyWeap < heavyWeap)
                        {
                            same5.Count += item.Count;
                            //same5.Damage += ((EquipmentMark)item).FireRate * accuracy;
                            same5.UnitType.Add(item);
                            curHeavyWeap += item.Count;
                        }
                    }
                }
            }
            var sames = new List <SameType>()
            {
                same0, same1, same2, same3, same4, same5
            };

            foreach (var same in sames)
            {
                var temp = new List <double>();
                foreach (var probType in same0.UnitType)
                {
                    if (same.Count == 0)
                    {
                        temp.Add(0);
                    }
                    else
                    {
                        temp.Add(probType.Count / same.Count);
                    }
                }
                same.Probabilities = temp;
            }


            return(sames);
        }