Beispiel #1
0
        public int GetValueForTrait(HorseTrait trait)
        {
            if (_thisValueMapIsNoMore)
            {
                _usingDefault = true;
                MainForm.InvalidateTraitValuator();
            }

            if (_usingDefault) return HorseTrait.GetDefaultValue(trait);

            int result = 0;
            ValueMap.TryGetValue(trait, out result);
            return result;
        }
 private void UpdateTraitView()
 {
     flowLayoutPanel1.Controls.Clear();
     if (CurrentTraitValueMap != null)
     {
         foreach (var keyval in CurrentTraitValueMap.ValueMap)
         {
             HorseTrait trait = new HorseTrait(keyval.Key);
             var control = new UCGrangerTraitValueEditBox()
             {
                 Trait = trait,
                 Value = keyval.Value,
                 ReadOnly = CurrentTraitValueMap.ReadOnly
             };
             flowLayoutPanel1.Controls.Add(control);
             control.TraitValueChanged += control_TraitValueChanged;
         }
     }
 }
Beispiel #3
0
 internal int Evaluate(HorseTrait[] traits)
 {
     int result = 0;
     foreach (var trait in traits)
     {
         result += GetValueForTrait(trait);
     }
     return result;
 }
Beispiel #4
0
 internal int Evaluate(HorseTrait[] traits, bool positiveOnly)
 {
     int result = 0;
     foreach (var trait in traits)
     {
         int val = GetValueForTrait(trait);
         if (positiveOnly && val > 0) result += GetValueForTrait(trait);
         else if (!positiveOnly && val < 0) result += GetValueForTrait(trait);
     }
     return result;
 }
Beispiel #5
0
 internal static HorseTrait[] GetBadTraits(HorseTrait[] traits, TraitValuator traitValuator)
 {
     return traits.Where(x => x.GetTraitValue(traitValuator) < 0).ToArray();
 }
Beispiel #6
0
        public bool Equals(HorseTrait p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return this.Trait == p.Trait;
        }
Beispiel #7
0
 internal static float GetAHSkillForThisTrait(HorseTrait horseTrait, bool epicCurve)
 {
     if (epicCurve) return EnumToAHSkillMapEpic[horseTrait.Trait];
     else return EnumToAHSkillMapFreedom[horseTrait.Trait];
 }
 private double EvaluatePotentialValue(Horse horse, TraitValuator valuator, HorseTrait trait)
 {
     double result = 0;
     if (trait.IsUnknownForThisHorse(horse))
     {
         var traitval = trait.GetTraitValue(valuator);
         if (traitval > 0)
         {
             result += traitval * _options.PotentialValuePositiveWeight;
         }
         else if (traitval < 0)
         {
             result += traitval * _options.PotentialValueNegativeWeight;
         }
         // we dont care when its 0
     }
     return result;
 }
Beispiel #9
0
 internal static string GetShortString(HorseTrait[] traits, TraitValuator valuator)
 {
     List<string> shorts = new List<string>();
     foreach (var trait in traits)
     {
         int value = 0;
         if (valuator != null) value = valuator.GetValueForTrait(trait);
         shorts.Add(Helper.GetShortcutForTrait(trait, value));
     }
     return string.Join(",", shorts.OrderBy(x => x));
 }
Beispiel #10
0
 internal static float GetMinSkillForTraits(HorseTrait[] traitlist, bool epicCurve)
 {
     return Helper.MinSkillForTheseTraits(traitlist, epicCurve);
 }
Beispiel #11
0
 public static int GetDefaultValue(HorseTrait trait)
 {
     return Helper.GetDefaultValue(trait);
 }
Beispiel #12
0
            internal static HorseTrait[] GetMissingTraits(HorseTrait[] horseTraits, float inspectSkill, bool epicCurve)
            {
                var correctDict = (epicCurve ? EnumToAHSkillMapEpic : EnumToAHSkillMapFreedom);
                List<HorseTrait> missingTraits = new List<HorseTrait>();

                foreach (var keyval in correctDict)
                {
                    if (inspectSkill < keyval.Value && horseTraits.Where(x => x.Trait == keyval.Key).Count() == 0)
                        missingTraits.Add(new HorseTrait(keyval.Key));
                }

                return missingTraits.ToArray();
            }
Beispiel #13
0
 internal static string GetShortcutForTrait(HorseTrait trait, int value)
 {
     string prefix = string.Empty;
     if (value > 0) prefix = "+";
     if (value < 0) prefix = "-";
     return prefix + EnumToShortcutMap[trait.Trait];
 }
Beispiel #14
0
 internal static string GetCompactNameForTrait(HorseTrait horseTrait)
 {
     return EnumToCompactNameMap[horseTrait.Trait];
 }
Beispiel #15
0
 internal static int GetDefaultValue(HorseTrait trait)
 {
     int result;
     if (!DefaultTraitValues.TryGetValue(trait.Trait, out result))
         Logger.LogError("no default value found for trait: " + trait.Trait.ToString());
     return result;
 }
Beispiel #16
0
 internal static HorseTrait[] GetMissingTraits(HorseTrait[] horseTraits, float inspectSkill, bool epicCurve)
 {
     return Helper.GetMissingTraits(horseTraits, inspectSkill, epicCurve);
 }
 HorseTrait[] GetUniqueTraits(HorseTrait[] allPresentTraits, HorseTrait[] traitGroup1, HorseTrait[] traitGroup2)
 {
     List<HorseTrait> uniqueTraits = new List<HorseTrait>();
     foreach (var trait in allPresentTraits)
     {
         if (!(traitGroup1.Contains(trait) && traitGroup2.Contains(trait)))
             uniqueTraits.Add(trait);
     }
     return uniqueTraits.ToArray();
 }
Beispiel #18
0
 private static float GetSkillForTrait(HorseTrait horseTrait, bool epicCurve)
 {
     return Helper.GetAHSkillForThisTrait(horseTrait, epicCurve);
 }
Beispiel #19
0
        public void ModifyTraitValue(HorseTrait.TraitEnum trait, int newValue)
        {
            if (ReadOnly) throw new InvalidOperationException("this list is read-only");

            ValueMap[trait] = newValue;
        }
Beispiel #20
0
            internal static float MinSkillForTheseTraits(HorseTrait[] traits, bool epicCurve)
            {
                float result = 0;
                foreach (var trait in traits)
                {
                    float skillForThisTrait = GetAHSkillForThisTrait(trait, epicCurve);

                    if (skillForThisTrait > result) result = skillForThisTrait;
                }
                return result;
            }