Ejemplo n.º 1
0
 public DefaultBreedingEvaluator(
     [NotNull] ILogger logger,
     [NotNull] DefaultBreedingEvaluatorOptions options)
 {
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     this.logger  = logger;
     this.options = options;
 }
Ejemplo n.º 2
0
        public BreedingAdvisor(
            [NotNull] FormGrangerMain mainForm,
            [NotNull] string advisorId,
            [NotNull] GrangerContext context,
            [NotNull] ILogger logger,
            [NotNull] DefaultBreedingEvaluatorOptions defaultBreedingEvaluatorOptions)
        {
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (advisorId == null)
            {
                throw new ArgumentNullException(nameof(advisorId));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (defaultBreedingEvaluatorOptions == null)
            {
                throw new ArgumentNullException(nameof(defaultBreedingEvaluatorOptions));
            }
            this.mainForm  = mainForm;
            this.AdvisorId = advisorId;
            this.context   = context;
            this.logger    = logger;

            IsDisabled = false;
            if (advisorId == DisabledId)
            {
                breedEvalutator = new DisabledBreedingEvaluator(logger);
                IsDisabled      = true;
            }

            if (advisorId == DefaultId)
            {
                breedEvalutator = new DefaultBreedingEvaluator(logger, defaultBreedingEvaluatorOptions);
            }
        }
        public BreedingEvaluatorDefaultConfig(
            [NotNull] DefaultBreedingEvaluatorOptions options,
            [NotNull] ILogger logger)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            this.options = options;
            this.logger  = logger;
            InitializeComponent();

            checkBoxSkipNotInMood.Checked             = this.options.IgnoreNotInMood;
            checkBoxSkipPregnant.Checked              = this.options.IgnorePregnant;
            checkBoxSkipGaveBirthInLast24h.Checked    = this.options.IgnoreRecentlyPregnant;
            checkBoxSkipCreaturesInOtherHerds.Checked = this.options.IgnoreOtherHerds;
            checkBoxSkipPaired.Checked = this.options.IgnorePairedCreatures;

            checkBoxIgnoreSold.Checked = this.options.IgnoreSold;
            checkBoxIgnoreDead.Checked = this.options.IgnoreDead;

            checkBoxExcludeFoals.Checked      = this.options.IgnoreFoals;
            checkBoxExcludeYoung.Checked      = this.options.IgnoreYoung;
            checkBoxExcludeAdolescent.Checked = this.options.IgnoreAdolescent;

            checkBoxKeepComparingSelected.Checked = this.options.AgeIgnoreOnlyOtherCreatures;

            numericUpDownBadTraitWeight.Value     = ((decimal)this.options.BadTraitWeight).ConstrainToRange(0, 100);
            checkBoxDiscardWithBadTraits.Checked  = this.options.DiscardOnAnyNegativeTraits;
            checkBoxIncludePotentialValue.Checked = this.options.IncludePotentialValue;
            numericUpDownPotValGoodWeight.Value   = ((decimal)this.options.PotentialValuePositiveWeight).ConstrainToRange(0, 100);
            numericUpDownPotValBadWeight.Value    = ((decimal)this.options.PotentialValueNegativeWeight).ConstrainToRange(0, 100);

            checkBoxPreferUniqueTraits.Checked   = this.options.PreferUniqueTraits;
            numericUpDownUniqueTraitWeight.Value = ((decimal)this.options.UniqueTraitWeight).ConstrainToRange(0, 100);

            numericUpDownInbreedPenaltyWeight.Value  = ((decimal)this.options.InbreedingPenaltyWeight.ConstrainToRange(0, 100));
            checkBoxDiscardAllCausingInbreed.Checked = this.options.DiscardOnInbreeding;

            checkBoxExcludeExactAge.Checked = this.options.ExcludeExactAgeEnabled;
            UpdateCheckBoxEcludeExactAge();
            timeSpanInputExcludeExactAge.Value = this.options.ExcludeExactAgeValue;

            olvColumnColorWeight.AspectPutter +=
                ((rowObject, value) =>
            {
                var colorWeight = (ColorWeight)rowObject;
                try
                {
                    var val = float.Parse(value.ToString());
                    colorWeight.Weight = val;
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Could not insert new value: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    logger.Info(exception, "Attempted to insert invalid value to color weight");
                }
            });

            objectListViewColorWeights.SetObjects(this.options.CreatureColorValues);

            UpdateCtrlsEnabledStates();

            Tip(checkBoxSkipPregnant, SkipPregnantCreaturesTooltip);
            Tip(checkBoxSkipGaveBirthInLast24h, SkipPregnantLast24HTooltip);
            Tip(numericUpDownBadTraitWeight, BadTraitWeightTooltip);
            Tip(checkBoxDiscardWithBadTraits, DiscardWithAnyBadTraitsTooltip);
            Tip(checkBoxIncludePotentialValue, IncludePotentialValueTooltip);
            Tip(numericUpDownPotValGoodWeight, PotentialGoodWeightTooltip);
            Tip(numericUpDownPotValBadWeight, PotentialBadWeightTooltip);
            Tip(checkBoxPreferUniqueTraits, PreferUniqueTraitsTooltop);
            Tip(numericUpDownUniqueTraitWeight, UniqTraitWeightTooltip);
            Tip(numericUpDownInbreedPenaltyWeight, InbreedWeightTooltip);
            Tip(checkBoxSkipPaired, SkipPairedCreaturesTooltip);
        }