Exemple #1
0
        /// <summary>
        /// Updates the general raising data for the given species
        /// </summary>
        /// <param name="species"></param>
        /// <param name="forceUpdate"></param>
        public void UpdateRaisingData(Species species, bool forceUpdate = false)
        {
            if (forceUpdate || _selectedSpecies != species)
            {
                _selectedSpecies = species;
                if (_selectedSpecies?.taming != null && _selectedSpecies.breeding != null)
                {
                    this.SuspendLayout();

                    listViewRaisingTimes.Items.Clear();

                    if (Raising.GetRaisingTimes(_selectedSpecies, out TimeSpan matingTime, out string incubationMode,
                                                out TimeSpan incubationTime, out _babyTime, out _maturationTime, out TimeSpan nextMatingMin,
                                                out TimeSpan nextMatingMax))
                    {
                        if (matingTime != TimeSpan.Zero)
                        {
                            listViewRaisingTimes.Items.Add(new ListViewItem(new[]
                                                                            { Loc.S("matingTime"), matingTime.ToString("d':'hh':'mm':'ss") }));
                        }

                        TimeSpan totalTime = incubationTime;
                        DateTime until     = DateTime.Now.Add(totalTime);
                        string[] times     =
                        {
                            incubationMode,                         incubationTime.ToString("d':'hh':'mm':'ss"),
                            totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                        };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime += _babyTime;
                        until      = DateTime.Now.Add(totalTime);
                        times      = new[]
                        {
                            Loc.S("Baby"), _babyTime.ToString("d':'hh':'mm':'ss"),
                            totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                        };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime = incubationTime + _maturationTime;
                        until     = DateTime.Now.Add(totalTime);
                        times     = new[]
                        {
                            Loc.S("Maturation"), _maturationTime.ToString("d':'hh':'mm':'ss"),
                            totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                        };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        // food amount needed
                        string foodAmount = null;
                        if (_selectedSpecies.taming.eats != null &&
                            _selectedSpecies.taming.eats.Any() &&
                            uiControls.Trough.foodAmount(_selectedSpecies,
                                                         Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier,
                                                         out double babyFood, out double totalFood))
                        {
                            foodAmount = FoodAmountString("Raw Meat");
                            if (string.IsNullOrEmpty(foodAmount))
                            {
                                foodAmount = FoodAmountString("Mejoberries");
                            }
                            if (string.IsNullOrEmpty(foodAmount))
                            {
                                foodAmount = FoodAmountString("Raw Prime Meat");
                            }
                            if (string.IsNullOrEmpty(foodAmount))
                            {
                                foodAmount = FoodAmountString("Raw Mutton");
                            }
                            if (string.IsNullOrEmpty(foodAmount))
                            {
                                foodAmount = FoodAmountString(_selectedSpecies.taming.eats[0]);
                            }

                            string FoodAmountString(string _foodName)
                            {
                                if (Array.IndexOf(_selectedSpecies.taming.eats, _foodName) == -1)
                                {
                                    return(null);
                                }
                                double foodValue;

                                if (_selectedSpecies.taming.specialFoodValues.TryGetValue(_foodName, out TamingFood tf))
                                {
                                    foodValue = tf.foodValue;
                                }
                                else if (Values.V.defaultFoodData.TryGetValue(_foodName, out tf))
                                {
                                    foodValue = tf.foodValue;
                                }
                                else
                                {
                                    return(null);
                                }
                                if (foodValue == 0)
                                {
                                    return(null);
                                }
                                return($"\n\nFood for Baby-Phase: ~{Math.Ceiling(babyFood / foodValue)} {_foodName}"
                                       + $"\nTotal Food for maturation: ~{Math.Ceiling(totalFood / foodValue)} {_foodName}");
                            }

                            foodAmount += "\n - Loss by spoiling is only a rough estimate and may vary.";
                        }


                        var raisingInfo = new StringBuilder();
                        if (nextMatingMin != TimeSpan.Zero)
                        {
                            raisingInfo.AppendLine(
                                $"{Loc.S("TimeBetweenMating")}: {nextMatingMin:d':'hh':'mm':'ss} to {nextMatingMax:d':'hh':'mm':'ss}");
                        }

                        string eggInfo = Raising.EggTemperature(_selectedSpecies);
                        if (!string.IsNullOrEmpty(eggInfo))
                        {
                            raisingInfo.AppendLine(eggInfo);
                        }
                        if (!string.IsNullOrEmpty(foodAmount))
                        {
                            raisingInfo.AppendLine(foodAmount);
                        }

                        labelRaisingInfos.Text = raisingInfo.ToString().Trim();

                        tabPageMaturationProgress.Enabled = true;
                    }
                    else
                    {
                        labelRaisingInfos.Text            = "No raising-data available.";
                        tabPageMaturationProgress.Enabled = false;
                    }

                    ResumeLayout();
                }
                else
                {
                    // no taming- or breeding-data available
                    labelRaisingInfos.Text            = "No raising-data available.";
                    tabPageMaturationProgress.Enabled = false;
                }
            }
Exemple #2
0
        /// <summary>
        /// Updates the general raising data for the given species
        /// </summary>
        /// <param name="species"></param>
        /// <param name="forceUpdate"></param>
        public void UpdateRaisingData(Species species, bool forceUpdate = false)
        {
            if (forceUpdate || this.selectedSpecies != species)
            {
                selectedSpecies = species;
                if (selectedSpecies?.taming != null && selectedSpecies.breeding != null)
                {
                    this.SuspendLayout();

                    listViewRaisingTimes.Items.Clear();

                    if (Raising.GetRaisingTimes(selectedSpecies, out string incubationMode, out TimeSpan incubationTime, out babyTime, out maturationTime, out TimeSpan nextMatingMin, out TimeSpan nextMatingMax))
                    {
                        TimeSpan totalTime = incubationTime;
                        DateTime until     = DateTime.Now.Add(totalTime);
                        string[] times     = { incubationMode, incubationTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime += babyTime;
                        until      = DateTime.Now.Add(totalTime);
                        times      = new[] { "Baby", babyTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime = incubationTime + maturationTime;
                        until     = DateTime.Now.Add(totalTime);
                        times     = new[] { "Maturation", maturationTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        // food amount needed
                        string foodamount = null;
                        if (selectedSpecies.taming.eats != null &&
                            selectedSpecies.taming.eats.Any() &&
                            uiControls.Trough.foodAmount(selectedSpecies, Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier, out double babyfood, out double totalfood))
                        {
                            foodamount = FoodAmountString("Raw Meat");
                            if (string.IsNullOrEmpty(foodamount))
                            {
                                foodamount = FoodAmountString("Mejoberries");
                            }
                            if (string.IsNullOrEmpty(foodamount))
                            {
                                foodamount = FoodAmountString("Raw Prime Meat");
                            }
                            if (string.IsNullOrEmpty(foodamount))
                            {
                                foodamount = FoodAmountString("Raw Mutton");
                            }
                            if (string.IsNullOrEmpty(foodamount))
                            {
                                foodamount = FoodAmountString(selectedSpecies.taming.eats[0]);
                            }

                            string FoodAmountString(string _foodName)
                            {
                                if (selectedSpecies.taming.eats.IndexOf(_foodName) == -1)
                                {
                                    return(null);
                                }
                                double foodValue;

                                if (selectedSpecies.taming.specialFoodValues.TryGetValue(_foodName, out TamingFood tf))
                                {
                                    foodValue = tf.foodValue;
                                }
                                else if (Values.V.defaultFoodData.TryGetValue(_foodName, out tf))
                                {
                                    foodValue = tf.foodValue;
                                }
                                else
                                {
                                    return(null);
                                }
                                if (foodValue == 0)
                                {
                                    return(null);
                                }
                                return($"\n\nFood for Baby-Phase: ~{Math.Ceiling(babyfood / foodValue)} {_foodName}"
                                       + $"\nTotal Food for maturation: ~{Math.Ceiling(totalfood / foodValue)} {_foodName}");
                            }

                            foodamount += "\n - Loss by spoiling is only a rough estimate and may vary.";
                        }

                        string eggInfo = Raising.EggTemperature(selectedSpecies);

                        labelRaisingInfos.Text = "Time between mating: " + nextMatingMin.ToString("d':'hh':'mm':'ss") + " to " + nextMatingMax.ToString("d':'hh':'mm':'ss")
                                                 + (!string.IsNullOrEmpty(eggInfo) ? "\n\n" + eggInfo : string.Empty)
                                                 + (foodamount ?? string.Empty);

                        tabPageMaturationProgress.Enabled = true;
                    }
                    else
                    {
                        labelRaisingInfos.Text            = "No raising-data available.";
                        tabPageMaturationProgress.Enabled = false;
                    }

                    ResumeLayout();
                }
                else
                {
                    // no taming- or breeding-data available
                    labelRaisingInfos.Text            = "No raising-data available.";
                    tabPageMaturationProgress.Enabled = false;
                }
            }
Exemple #3
0
        /// <summary>
        /// Updates the general raising data for the given species
        /// </summary>
        /// <param name="speciesIndex"></param>
        /// <param name="forceUpdate"></param>
        public void UpdateRaisingData(Species species, bool forceUpdate = false)
        {
            if (forceUpdate || this.selectedSpecies != species)
            {
                selectedSpecies = species;
                if (selectedSpecies != null && selectedSpecies.taming != null && selectedSpecies.breeding != null)
                {
                    this.SuspendLayout();

                    listViewRaisingTimes.Items.Clear();

                    if (Raising.getRaisingTimes(selectedSpecies, out string incubationMode, out TimeSpan incubationTime, out babyTime, out maturationTime, out TimeSpan nextMatingMin, out TimeSpan nextMatingMax))
                    {
                        string eggInfo = Raising.eggTemperature(selectedSpecies);
                        if (eggInfo.Length > 0)
                        {
                            eggInfo = "\n\n" + eggInfo;
                        }

                        TimeSpan totalTime = incubationTime;
                        DateTime until     = DateTime.Now.Add(totalTime);
                        string[] times     = { incubationMode, incubationTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.shortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime += babyTime;
                        until      = DateTime.Now.Add(totalTime);
                        times      = new[] { "Baby", babyTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.shortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        totalTime = incubationTime + maturationTime;
                        until     = DateTime.Now.Add(totalTime);
                        times     = new[] { "Maturation", maturationTime.ToString("d':'hh':'mm':'ss"), totalTime.ToString("d':'hh':'mm':'ss"), Utils.shortTimeDate(until) };
                        listViewRaisingTimes.Items.Add(new ListViewItem(times));

                        // food amount needed
                        string foodamount = "";
                        if (selectedSpecies.taming.eats != null &&
                            uiControls.Trough.foodAmount(selectedSpecies, Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier, out double babyfood, out double totalfood))
                        {
                            if (selectedSpecies.taming.eats.IndexOf("Raw Meat") >= 0)
                            {
                                foodamount = "\n\nFood for Baby-Phase: ~" + Math.Ceiling(babyfood / 50) + " Raw Meat"
                                             + "\nTotal Food for maturation: ~" + Math.Ceiling(totalfood / 50) + " Raw Meat";
                            }
                            else if (selectedSpecies.taming.eats.IndexOf("Mejoberry") >= 0)
                            {
                                foodamount = "\n\nFood for Baby-Phase: ~" + Math.Ceiling(babyfood / 30) + " Mejoberries"
                                             + "\nTotal Food for maturation: ~" + Math.Ceiling(totalfood / 30) + " Mejoberries";
                            }
                            foodamount += "\n - Loss by spoiling is only a rough estimate and may vary.";
                        }


                        labelRaisingInfos.Text = "Time between mating: " + nextMatingMin.ToString("d':'hh':'mm':'ss") + " to " + nextMatingMax.ToString("d':'hh':'mm':'ss")
                                                 + eggInfo
                                                 + foodamount;

                        tabPageMaturationProgress.Enabled = true;
                    }
                    else
                    {
                        labelRaisingInfos.Text            = "No raising-data available.";
                        tabPageMaturationProgress.Enabled = false;
                    }

                    ResumeLayout();
                }
                else
                {
                    // no taming- or breeding-data available
                    labelRaisingInfos.Text            = "No raising-data available.";
                    tabPageMaturationProgress.Enabled = false;
                }
            }
Exemple #4
0
        /// <summary>
        /// Updates the general raising data for the given species
        /// </summary>
        public void UpdateRaisingData(Species species, bool forceUpdate = false)
        {
            if (!forceUpdate && _selectedSpecies == species)
            {
                return;
            }

            _selectedSpecies         = species;
            CbGrowingFood.DataSource = null;
            listViewRaisingTimes.Items.Clear();

            if (_selectedSpecies?.taming == null || _selectedSpecies.breeding == null)
            {
                // no taming- or breeding-data available
                labelRaisingInfos.Text            = "No raising-data available.";
                tabPageMaturationProgress.Enabled = false;
                return;
            }

            SuspendLayout();

            var eats = new List <string>();

            if (_selectedSpecies.taming.eats != null)
            {
                eats.AddRange(_selectedSpecies.taming.eats);
            }
            if (_selectedSpecies.taming.eatsAlsoPostTame != null)
            {
                eats.AddRange(_selectedSpecies.taming.eatsAlsoPostTame);
            }

            _ignoreChangedFood       = true;
            CbGrowingFood.DataSource = eats;
            _ignoreChangedFood       = false;
            var selectIndex = string.IsNullOrEmpty(_lastSelectedFood) ? 0 : eats.IndexOf(_lastSelectedFood);

            if (selectIndex == -1)
            {
                selectIndex = 0;
            }
            if (CbGrowingFood.Items.Count > 0)
            {
                CbGrowingFood.SelectedIndex = selectIndex;
            }

            if (Raising.GetRaisingTimes(_selectedSpecies, out TimeSpan matingTime, out string incubationMode,
                                        out TimeSpan incubationTime, out _babyTime, out _maturationTime, out TimeSpan nextMatingMin,
                                        out TimeSpan nextMatingMax))
            {
                if (matingTime != TimeSpan.Zero)
                {
                    listViewRaisingTimes.Items.Add(new ListViewItem(new[]
                                                                    { Loc.S("matingTime"), matingTime.ToString("d':'hh':'mm':'ss") }));
                }

                TimeSpan totalTime = incubationTime;
                DateTime until     = DateTime.Now.Add(totalTime);
                string[] times     =
                {
                    incubationMode,                         incubationTime.ToString("d':'hh':'mm':'ss"),
                    totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                };
                listViewRaisingTimes.Items.Add(new ListViewItem(times));

                totalTime += _babyTime;
                until      = DateTime.Now.Add(totalTime);
                times      = new[]
                {
                    Loc.S("Baby"), _babyTime.ToString("d':'hh':'mm':'ss"),
                    totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                };
                listViewRaisingTimes.Items.Add(new ListViewItem(times));

                totalTime = incubationTime + _maturationTime;
                until     = DateTime.Now.Add(totalTime);
                times     = new[]
                {
                    Loc.S("Maturation"), _maturationTime.ToString("d':'hh':'mm':'ss"),
                    totalTime.ToString("d':'hh':'mm':'ss"), Utils.ShortTimeDate(until)
                };
                listViewRaisingTimes.Items.Add(new ListViewItem(times));

                var raisingInfo = new StringBuilder();
                if (nextMatingMin != TimeSpan.Zero)
                {
                    raisingInfo.AppendLine(
                        $"{Loc.S("TimeBetweenMating")}: {nextMatingMin:d':'hh':'mm':'ss} to {nextMatingMax:d':'hh':'mm':'ss}");
                }

                string eggInfo = Raising.EggTemperature(_selectedSpecies);
                if (!string.IsNullOrEmpty(eggInfo))
                {
                    raisingInfo.AppendLine(eggInfo);
                }

                labelRaisingInfos.Text = raisingInfo.ToString().Trim();

                tabPageMaturationProgress.Enabled = true;
            }