protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            var xName = x.Troop.Character.Culture.Name?.ToString();
            var yName = y.Troop.Character.Culture.Name?.ToString();

            if (xName == null || yName == null)
            {
                return(1);
            }

            xName = CustomSettingsList.Contains(xName) ? xName : CultureCode.AnyOtherCulture.ToString();
            yName = CustomSettingsList.Contains(yName) ? yName : CultureCode.AnyOtherCulture.ToString();

            if (xName.Equals(yName))
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            foreach (var setting in CustomSettingsList)
            {
                bool xMatch = xName.Equals(setting);
                bool yMatch = yName.Equals(setting);

                if (xMatch && !yMatch)
                {
                    return(Descending ? -1 : 1);
                }
                if (yMatch && !xMatch)
                {
                    return(Descending ? 1 : -1);
                }
            }

            return(1);
        }
Exemple #2
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (Descending ? x.Troop.WoundedNumber > y.Troop.WoundedNumber : y.Troop.WoundedNumber > x.Troop.WoundedNumber)
            {
                return(-1);
            }

            if (x.Troop.WoundedNumber == y.Troop.WoundedNumber)
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(1);
        }
Exemple #3
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (Descending ? x.Character.Level > y.Character.Level : y.Character.Level > x.Character.Level)
            {
                return(-1);
            }

            if (x.Character.Level == y.Character.Level)
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(1);
        }
Exemple #4
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (Descending ? x.Character.Tier <y.Character.Tier : x.Character.Tier> y.Character.Tier)
            {
                return(1);
            }

            if (x.Character.Tier == y.Character.Tier)
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(-1);
        }
Exemple #5
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (Descending
                ? x.Character.GetFormationClass() < y.Character.GetFormationClass()
                : x.Character.GetFormationClass() > y.Character.GetFormationClass())
            {
                return(1);
            }

            if (y.Character.GetFormationClass() == x.Character.GetFormationClass())
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(-1);
        }
Exemple #6
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (Descending
                ? x.NumOfReadyToUpgradeTroops > y.NumOfReadyToUpgradeTroops
                : y.NumOfReadyToUpgradeTroops > x.NumOfReadyToUpgradeTroops)
            {
                return(-1);
            }


            if (y.NumOfReadyToUpgradeTroops == x.NumOfReadyToUpgradeTroops)
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(1);
        }
Exemple #7
0
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            if (_compDictionary == null)
            {
                FillDictionary();
            }

            var xChar = x.Character;
            var yChar = y.Character;

            if (xChar == null || yChar == null)
            {
                return(1);
            }

            bool isXHorseArcher = xChar.IsRanged && xChar.IsMounted;
            bool isYHorseArcher = yChar.IsRanged && yChar.IsMounted;

            if (isXHorseArcher || isYHorseArcher)
            {
                if (isXHorseArcher && isYHorseArcher)
                {
                    return(EqualSorter?.Compare(x, y) ?? 0);
                }
            }
            else
            {
                if ((x.Character.IsInfantry && y.Character.IsInfantry) || (x.Character.IsMounted && y.Character.IsMounted) || (x.Character.IsRanged && y.Character.IsRanged))
                {
                    return(EqualSorter?.Compare(x, y) ?? 0);
                }
            }

            foreach (var order in CustomSettingsList)
            {
                var function = _compDictionary[order];
                int value    = function(xChar, yChar);

                if (value != int.MaxValue)
                {
                    return(value);
                }
            }

            return(1);
        }
        protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM y)
        {
            int result;

            if (Descending)
            {
                result = StringComparer.CurrentCulture.Compare(y.Name.ToString(), x.Name.ToString());
            }
            else
            {
                result = StringComparer.CurrentCulture.Compare(x.Name.ToString(), y.Name.ToString());
            }

            if (result == 0)
            {
                return(EqualSorter?.Compare(x, y) ?? 0);
            }

            return(result);
        }