Example #1
0
    public static int calculDegat(Personnage victime, TypeSort type, int pddPresume)
    {
        Debug.Log(victime);
        Debug.Log(victime.caracteristiqueFeu);
        float degat = pddPresume;

        switch (type)
        {
        case TypeSort.feu:
            degat -= (degat / 100) * (victime.caracteristiqueFeu / 5);
            break;

        case TypeSort.eau:
            degat -= (degat / 100) * (victime.caracteristiqueEau / 5);
            break;

        case TypeSort.vent:
            degat -= (degat / 100) * (victime.caracteristiqueVent / 5);
            break;

        case TypeSort.terre:
            degat -= (degat / 100) * (victime.caracteristiqueTerre / 5);
            break;
        }
        degat -= (degat / 100) * victime.resistance;
        return(Mathf.RoundToInt(degat));
    }
Example #2
0
		public static void QuickSort(int[][] array, int start, int end, TypeSort type = TypeSort.Max, DirectionSort direction = DirectionSort.Inc) {
			int mid = GetValueFromArr(array[(start + end) / 2], type), i = start, j = end;
			int[] temp;

			while (i <= j)
			{
				if (direction == DirectionSort.Inc) {
					while (GetValueFromArr (array [i], type) < mid)
						i++;
					while (GetValueFromArr (array [j], type) > mid)
						j--;
				} else {
					while (GetValueFromArr (array [i], type) > mid)
						i++;
					while (GetValueFromArr (array [j], type) < mid)
						j--;
				}

				if (i <= j)
				{
					temp = array[i];
					array[i] = array[j];
					array[j] = temp;
					i++;
					j--;
				}
			
				if (i < end)
					QuickSort (array, i, end, type, direction);
				if (j > start)
					QuickSort (array, start, j, type, direction);
			}
		}
Example #3
0
        public IEnumerable<ReportRecord> SortCalls(Report report, TypeSort sortType)
        {
            var rep = report.GetRecords();
            switch (sortType)
            {
                case TypeSort.SortByCallType:
                    return rep = rep.
                        OrderBy(x => x.CallType).
                        ToList();

                case TypeSort.SortByDate:
                    return rep = rep.
                        OrderBy(x => x.Date).
                        ToList();

                case TypeSort.SortByCost:
                    return rep = rep
                        .OrderBy(x => x.Cost)
                        .ToList();

                case TypeSort.SortByNumber:
                    return rep = rep.
                        OrderBy(x => x.Number).
                        ToList();

                default:
                    return rep;
            }
        }
Example #4
0
 static void Regularize(dynamic array, TypeSort typeSort)
 {
     if (typeSort == null)
     {
         throw new Exception("Нет ссылки на метод!");
     }
     else
     {
         try
         {
             for (int i = 0; i < array.Length; i++)
             {
                 for (int j = i + 1; j < array.Length; j++)
                 {
                     if (typeSort(array[i], array[j]))
                     {
                         Swap(array, i, j);
                     }
                 }
             }
         }
         catch (Exception e)
         {
             Console.WriteLine("Нужно перегрузить операции > и < для типа {0}", array.GetType());
         }
     }
 }
Example #5
0
        private void addDataSort()
        {
            TypeSort SortTheoTenSanPham = new TypeSort()
            {
                MaSort = "SapXepTheoTen", TenSort = "Sort theo tên"
            };
            TypeSort SortTheoMaSanPham = new TypeSort()
            {
                MaSort = "SapXepTheoMa", TenSort = "Sort theo mã"
            };
            TypeSort SortTheoNgay = new TypeSort()
            {
                MaSort = "SapXepTheoTenMatHang", TenSort = "Sort theo ngày"
            };
            TypeSort SortTheoMatHang = new TypeSort()
            {
                MaSort = "SapXepTheoThoiGian", TenSort = "Sort theo mặt hàng"
            };
            List <TypeSort> lists = new List <TypeSort>();

            lists.Add(SortTheoTenSanPham);
            lists.Add(SortTheoMaSanPham);
            lists.Add(SortTheoNgay);
            lists.Add(SortTheoMatHang);
            cbSort.DataSource    = lists;
            cbSort.DisplayMember = "TenSort";
            cbSort.ValueMember   = "MaSort";
        }
        public IEnumerable <ReportRecord> SortCalls(Report report, TypeSort sortType)
        {
            var rep = report.GetRecords();

            switch (sortType)
            {
            case TypeSort.SortByCallType:
                return(rep = rep.
                             OrderBy(x => x.CallType).
                             ToList());

            case TypeSort.SortByDate:
                return(rep = rep.
                             OrderBy(x => x.Date).
                             ToList());

            case TypeSort.SortByCost:
                return(rep = rep
                             .OrderBy(x => x.Cost)
                             .ToList());

            case TypeSort.SortByNumber:
                return(rep = rep.
                             OrderBy(x => x.Number).
                             ToList());

            default:
                return(rep);
            }
        }
Example #7
0
    public static int degatPresume(Personnage lanceur, TypeSort type, int pdd)
    {
        Debug.Log("lanceur : " + lanceur);
        int degat = pdd + lanceur.Dommage;

        switch (type)
        {
        case TypeSort.feu:
            degat += lanceur.caracteristiqueFeu;
            break;

        case TypeSort.eau:
            degat += lanceur.caracteristiqueEau;
            break;

        case TypeSort.vent:
            degat += lanceur.caracteristiqueVent;
            break;

        case TypeSort.terre:
            degat += lanceur.caracteristiqueTerre;
            break;
        }
        return(degat);
    }
 /// <summary>
 /// Instancie dans un dico les sort de la quantité déterminé
 /// </summary>
 /// <param name="quantite">défini la quantité de loot</param>
 /// <param name="type">defini le type de sort</param>
 /// <param name="nom">defini le nom du sort</param>
 /// <param name="list">defini le dico affecté</param>
 public void InstanciationLootSort(int quantite, TypeSort type, NomSort nom, DicoLoot list)
 {
     for (int i = 0; i < quantite; i++)
     {
         Loot_Sort sort = new Loot_Sort();
         list.Add(this.CaseVide(), sort.CreationSort(type, nom));
     }
 }
        // без изменеия логики добавить еще 1 тип сортировки
        public static void Sort(int[][] array, TypeSort typeSort, OrderSort orderSort)
        {
            GetComparisonValue getComparisonValue;
            switch (typeSort)
            {
                case TypeSort.ByMaxElement:
                    getComparisonValue = (int[] a) => a.Max();
                    break;
                case TypeSort.ByMinElement:
                    getComparisonValue = (int[] a) => a.Min();
                    break;
                case TypeSort.BySumElements:
                    getComparisonValue = (int[] a) => a.Sum();
                    break;
                default:
                    throw new ArgumentException("Unkown element enumeration", "typeSort");
            }

            int[] comparisonValues = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                comparisonValues[i] = getComparisonValue(array[i]);
            }

            Compare less;
            switch (orderSort)
            {
                case OrderSort.Asc:
                    less = (int a, int b) => a < b;
                    break;
                case OrderSort.Desc:
                    less = (int a, int b) => a > b;
                    break;
                default:
                    throw new ArgumentException("Unkown element enumeration", "orderSort");
            }

            for (int i = 0; i < comparisonValues.Length - 1; i++)
            {
                int indexMin = i;
                for (int j = i + 1; j < comparisonValues.Length; j++)
                {
                    if (less(comparisonValues[j], comparisonValues[indexMin]))
                    {
                        indexMin = j;
                    }
                }
                int buffer = comparisonValues[i];
                comparisonValues[i] = comparisonValues[indexMin];
                comparisonValues[indexMin] = buffer;

                int[] bufferReference = array[i];
                array[i] = array[indexMin];
                array[indexMin] = bufferReference;
            }
        }       
Example #10
0
 public void LoadSoundTestOrder(List <SoundEntry> soundEntries, List <SoundEntry> soundEntriesBackup)
 {
     treeView.Nodes.Clear();
     foreach (SoundEntry sEntry in soundEntries.OrderBy(p => p.SoundTestOrder))
     {
         treeView.Nodes.Add(sEntry.SoundID.ToString(), sEntry.Title);
     }
     _TypeSort            = TypeSort.SoundTestOrder;
     _CurrentList         = soundEntries;
     _CurrentListOriginal = soundEntriesBackup;
 }
Example #11
0
		private static int GetValueFromArr(int[] array, TypeSort type) {
			int res = 0;
			if (type == TypeSort.Max) {
				res = array.Max ();
			} else if (type == TypeSort.Min) {
				res = array.Min ();
			} else if (type == TypeSort.Sum) {
				res = array.Sum ();
			}
			return res;
		}
Example #12
0
 public MaxMinOfRow(TypeSort typeSort)
 {
     if (TypeSort.Min == typeSort)
     {
         FunctypeSort = (value, min) => { return(value < min); };
     }
     else
     {
         FunctypeSort = (value, max) => { return(value > max); };
     }
 }
Example #13
0
        public void Sort(TypeSort typeSort)
        {
            switch (typeSort)
            {
            case TypeSort.ageUp:
                SortAgeUp();
                break;

            case TypeSort.ageDown:
                SortAgeDown();
                break;
            }
        }
Example #14
0
 public void Sort(TypeSort k)
 {
     for (int i = 0; i < length - 1; i++)
     {
         for (int j = i + 1; j < length; j++)
         {
             if (CheckCondition(a[i], a[j], k) > 0)
             {
                 Subscriber c = a[i];
                 a[i] = a[j];
                 a[j] = c;
             }
         }
     }
 }
Example #15
0
        /// <summary>
        /// Главная страница
        /// </summary>
        /// <returns>Список имеющихся товаров
        /// с сортировкой по цене</returns>
        public ActionResult Index(int pageNum = 0, TypeSort sort = TypeSort.NameAsc)
        {
            ProductData.Instance.PageNum    = pageNum;
            ProductData.Instance.ItemsCount = db.Products.Count();
            int pageSize = ProductData.Instance.PageSize;

            var products = db.Products.OrderBy(x => x.Name);

            switch (sort)
            {
            case TypeSort.NameAsc: products = products.OrderBy(x => x.Name); break;

            case TypeSort.NameDesc: products = products.OrderByDescending(x => x.Name); break;

            case TypeSort.PriceAsc: products = products.OrderBy(x => x.Price); break;

            case TypeSort.PriceDesc: products = products.OrderByDescending(x => x.Price); break;
            }
            return(View(products.Skip(pageSize * pageNum).Take(pageSize)));
        }
Example #16
0
        public int CheckCondition(Subscriber a, Subscriber b, TypeSort k)
        {
            switch (k)
            {
            case TypeSort.UpByFullName:
                //return (a.hoTen.CompareTo(b.hoTen));
                return(String.Compare(a.hoTen, b.hoTen, true));

            case TypeSort.DownByFullName:
                //return (b.hoTen.CompareTo(a.hoTen));
                return(String.Compare(b.hoTen, a.hoTen, true));

            case TypeSort.UpByDoB:
                return(a.ngaySinh > b.ngaySinh ? 1 : 0);

            case TypeSort.DownByDoB:
                return(b.ngaySinh > a.ngaySinh ? 1 : 0);
            }
            return(0);
        }
Example #17
0
 public void LoadStageCreationOrder(List <SoundEntry> soundEntries, List <SoundEntry> soundEntriesBackup)
 {
     treeView.Nodes.Clear();
     foreach (SoundEntry sEntry in soundEntries.OrderBy(p => p.StageCreationOrder))
     {
         TreeNode group    = null;
         string   groupKey = "g_" + sEntry.StageCreationGroupID;
         if (!treeView.Nodes.ContainsKey(groupKey))
         {
             group = treeView.Nodes.Add(groupKey, sEntry.StageCreationGroupName);
         }
         else
         {
             group = treeView.Nodes[groupKey];
         }
         group.Nodes.Add(sEntry.SoundID.ToString(), sEntry.Title);
     }
     _TypeSort            = TypeSort.StageCreationOrder;
     _CurrentList         = soundEntries;
     _CurrentListOriginal = soundEntriesBackup;
 }
Example #18
0
        /// <summary>
        /// renvoie un sort dont le type et le nom sont définie en argument et dont les valeurs sont issue du fichier des settings
        /// </summary>
        /// <param name="type"></param>
        /// <param name="nom"></param>
        /// <returns></returns>
        public Loot_Sort CreationSort(TypeSort type, NomSort nom)
        {
            Loot_Sort sort = new Loot_Sort();

            switch (type)
            {
            case TypeSort.Immediat:
                switch (nom)
                {
                case NomSort.Force:
                    Force        += constantesLoot.SortForce;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Vitesse:
                    Vitesse      += constantesLoot.SortVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Combine:
                    Force        += constantesLoot.SortForce;
                    Vitesse      += constantesLoot.SortVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Teleportation:
                    Position      = _position;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Vision:
                    Vision       += constantesLoot.SortVision;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;
                }
                break;

            case TypeSort.Potion:
                switch (nom)
                {
                case NomSort.Force:
                    Force        += constantesLoot.SortPotionForce;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Vitesse:
                    Vitesse      += constantesLoot.SortPotionVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Combine:
                    Force        += constantesLoot.SortPotionForce;
                    Vitesse      += constantesLoot.SortPotionVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Teleportation:
                    Position = _position;
                    break;

                case NomSort.Vision:
                    Vision       += constantesLoot.SortPotionVision;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;
                }
                break;

            case TypeSort.Carte:
                switch (nom)
                {
                case NomSort.Force:
                    Force        -= constantesLoot.SortCarteForce;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Vitesse:
                    Vitesse      -= constantesLoot.SortCarteVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Combine:
                    Force        -= constantesLoot.SortCarteForce;
                    Vitesse      -= constantesLoot.SortCarteVitesse;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Teleportation:
                    Position      = _position;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;

                case NomSort.Vision:
                    Vision       -= constantesLoot.SortCarteVision;
                    this.NomSort  = nom;
                    this.TypeSort = type;
                    break;
                }
                break;

            default:
                return(null);
            }
            return(sort);
        }
Example #19
0
        public PersonalityDebtView(string Name, TypeSort typeSort)
        {
            ChangeList = new ObservableCollection<ViewDebtModel>();

            System.Collections.Generic.List<DebtModel> _context = DBContext.getChangesByName(Name);

            switch (typeSort)
            {
                case TypeSort.ByDateOldFirst:

                    _context.Sort(delegate (DebtModel x, DebtModel y)
                    {
                        CultureInfo provider = CultureInfo.InvariantCulture;
                        DateTime a = DateTime.ParseExact(x.Date, "dd MM yyyy", provider);
                        DateTime b = DateTime.ParseExact(y.Date, "dd MM yyyy", provider);
                        if (a == b)
                        {
                            return 0;
                        }

                        return a > b ? 1 : -1;
                    });
                    break;

                case TypeSort.ByDateNewFirst:

                    _context.Sort(delegate (DebtModel x, DebtModel y)
                    {
                        CultureInfo provider = CultureInfo.InvariantCulture;
                        DateTime a = DateTime.ParseExact(x.Date, "dd MM yyyy", provider);
                        DateTime b = DateTime.ParseExact(y.Date, "dd MM yyyy", provider);
                        if (a == b)
                        {
                            return 0;
                        }

                        return a < b ? 1 : -1;
                    });
                    break;

                case TypeSort.ByValueLargeFirst:

                    _context.Sort(delegate (DebtModel x, DebtModel y)
                    {
                        if (x.DebtChange == y.DebtChange)
                        {
                            return 0;
                        }

                        return x.DebtChange < y.DebtChange ? 1 : -1;
                    });
                    break;

                case TypeSort.ByValueSmallFirst:

                    _context.Sort(delegate (DebtModel x, DebtModel y)
                    {
                        if (x.DebtChange == y.DebtChange)
                        {
                            return 0;
                        }

                        return x.DebtChange > y.DebtChange ? 1 : -1;
                    });
                    break;

                default:
                    break;
            }

            foreach (DebtModel item in _context)
            {
                ChangeList.Add(new ViewDebtModel()
                {
                    Name = item.Name,
                    Description = item.Description,
                    DebtChange = item.DebtChange,
                    Date = item.Date,
                    IsMoneyDebt = item.DebtChange != 0 ? true : false
                });
            }
        }
Example #20
0
 public MaxMinOfRows(TypeSort sortType)
 {
     _sortType = sortType;
 }
Example #21
0
        public void Sort_Array(TypeSort _sort, TypeOrder _order)
        {
            if (!Empty())
            {
                switch (_sort)
                {
                case TypeSort.Bubble:

                    for (int index_1 = 1; index_1 < this.lenght; index_1++)
                    {
                        Node auxnode_1 = this.Find(index_1);
                        for (int index_2 = index_1 + 1; index_2 <= this.lenght; index_2++)
                        {
                            Node auxnode_2 = this.Find(index_2);

                            switch (_order)
                            {
                            case TypeOrder.Ascending:
                                if (Compare_Info(auxnode_1, auxnode_2, ">") == true)             // Ascending order
                                {
                                    //Exchange values between nodes
                                    T temp = auxnode_2.info;
                                    auxnode_2.info = auxnode_1.info;
                                    auxnode_1.info = temp;
                                }
                                break;

                            case TypeOrder.Descending:
                                if (Compare_Info(auxnode_1, auxnode_2, "<") == true)             // Descending order
                                {
                                    //Exchange values between nodes
                                    T temp = auxnode_2.info;
                                    auxnode_2.info = auxnode_1.info;
                                    auxnode_1.info = temp;
                                }
                                break;
                            }
                        }
                    }

                    break;

                case TypeSort.ImprovedBubble:

                    bool swapIBubble = true;

                    for (int i = this.lenght; i >= 1 && swapIBubble; --i)
                    {
                        swapIBubble = false;

                        for (int j = 1; j < i; ++j)
                        {
                            Node auxnode_1 = this.Find(j);
                            Node auxnode_2 = this.Find(j + 1);

                            switch (_order)
                            {
                            case TypeOrder.Ascending:
                                if (Compare_Info(auxnode_1, auxnode_2, ">") == true)
                                {
                                    swapIBubble = true;
                                    T temp = auxnode_1.info;
                                    auxnode_1.info = auxnode_2.info;
                                    auxnode_2.info = temp;
                                }
                                break;

                            case TypeOrder.Descending:
                                if (Compare_Info(auxnode_1, auxnode_2, "<") == true)
                                {
                                    swapIBubble = true;
                                    T temp = auxnode_1.info;
                                    auxnode_1.info = auxnode_2.info;
                                    auxnode_2.info = temp;
                                }
                                break;
                            }
                        }
                    }

                    break;

                case TypeSort.Insertion:

                    for (int i = 1; i <= this.lenght - 1; i++)
                    {
                        for (int j = i + 1; j > 1; j--)
                        {
                            Node auxnode_1 = this.Find(j);
                            Node auxnode_2 = this.Find(j - 1);

                            switch (_order)
                            {
                            case TypeOrder.Ascending:
                                if (this.Compare_Info(auxnode_2, auxnode_1, ">") == true)
                                {
                                    T temp = auxnode_2.info;
                                    auxnode_2.info = auxnode_1.info;
                                    auxnode_1.info = temp;
                                }
                                break;

                            case TypeOrder.Descending:
                                if (this.Compare_Info(auxnode_2, auxnode_1, "<") == true)
                                {
                                    T temp = auxnode_2.info;
                                    auxnode_2.info = auxnode_1.info;
                                    auxnode_1.info = temp;
                                }
                                break;
                            }
                        }
                    }

                    break;
                }
            }
            else
            {
                Console.WriteLine("Elements not found");
            }
        }
Example #22
0
 public Comparisons(TypeSort sort)
 {
     _sort = (int)sort;
 }