Пример #1
0
 private void btnAddStarvingTimer_Click(object sender, EventArgs e)
 {
     if (speciesIndex >= 0)
     {
         CreateTimer(Loc.s("timerStarvingOf") + " " + Values.V.speciesNames[speciesIndex], starvingTime, null, TimerControl.TimerGroups.Starving.ToString());
     }
 }
Пример #2
0
        /// <summary>
        /// Update the info when all food can be fed at once.
        /// </summary>
        private void UpdateTimeToFeedAll(bool enoughFood = true)
        {
            double hunger = (double)(nudTotalFood.Value - nudCurrentFood.Value);

            if (hunger < 0)
            {
                hunger = 0;
            }
            if (hunger > neededHunger)
            {
                hunger = neededHunger;
            }
            var durationStarving = new TimeSpan(0, 0, (int)((neededHunger - hunger) / foodDepletion));

            lbTimeUntilStarving.Text = (enoughFood ? $"{Loc.s("TimeUntilFeedingAllFood")}: {Utils.duration(durationStarving)}" : "");
            if ((double)nudTotalFood.Value < neededHunger)
            {
                lbTimeUntilStarving.Text     += (lbTimeUntilStarving.Text.Length > 0 ? "\n" : "") + $"{Loc.s("WarningMoreStarvingThanFood")}";
                lbTimeUntilStarving.ForeColor = Color.DarkRed;
            }
            else
            {
                lbTimeUntilStarving.ForeColor = SystemColors.ControlText;
            }

            starvingTime = DateTime.Now.Add(durationStarving);
        }
Пример #3
0
 public static void initializeLocalizations()
 {
     statNames            = new[] { Loc.s("Health"), Loc.s("Stamina"), Loc.s("Torpidity"), Loc.s("Oxygen"), Loc.s("Food"), Loc.s("Water"), Loc.s("Temperature"), Loc.s("Weight"), Loc.s("Damage"), Loc.s("Speed"), Loc.s("Fortitude"), Loc.s("CraftingSpeed") };
     statNamesAbb         = new[] { Loc.s("Health_Abb"), Loc.s("Stamina_Abb"), Loc.s("Torpidity_Abb"), Loc.s("Oxygen_Abb"), Loc.s("Food_Abb"), Loc.s("Water_Abb"), Loc.s("Temperature_Abb"), Loc.s("Weight_Abb"), Loc.s("Damage_Abb"), Loc.s("Speed_Abb"), Loc.s("Fortitude_Abb"), Loc.s("CraftingSpeed_Abb") };
     statNamesAberrant    = new[] { Loc.s("Health"), Loc.s("ChargeCapacity"), Loc.s("Torpidity"), Loc.s("ChargeRegeneration"), Loc.s("Food"), Loc.s("Water"), Loc.s("Temperature"), Loc.s("Weight"), Loc.s("ChargeEmissionRange"), Loc.s("Speed"), Loc.s("Fortitude"), Loc.s("CraftingSpeed") };
     statNamesAberrantAbb = new[] { Loc.s("Health_Abb"), Loc.s("ChargeCapacity_Abb"), Loc.s("Torpidity_Abb"), Loc.s("ChargeRegeneration_Abb"), Loc.s("Food_Abb"), Loc.s("Water_Abb"), Loc.s("Temperature_Abb"), Loc.s("Weight_Abb"), Loc.s("ChargeEmissionRange_Abb"), Loc.s("Speed_Abb"), Loc.s("Fortitude_Abb"), Loc.s("CraftingSpeed_Abb") };
 }
Пример #4
0
        public void SetLocalizations()
        {
            Loc.ControlText(lbBreedingPlanHeader, "SelectSpeciesBreedingPlanner");
            Loc.ControlText(gbBPOffspring);
            Loc.ControlText(gbBPBreedingMode);
            Loc.ControlText(rbBPTopStatsCn);
            Loc.ControlText(rbBPTopStats);
            Loc.ControlText(rbBPHighStats);
            Loc.ControlText(cnBPIncludeCooldowneds);
            Loc.ControlText(btBPApplyNewWeights);
            Loc.ControlText(gbBPBreedingMode);
            Loc.ControlText(lbBPBreedingTimes);
            Loc.ControlText(btBPJustMated);
            columnHeader2.Text = Loc.s("Time");
            columnHeader3.Text = Loc.s("TotalTime");
            columnHeader4.Text = Loc.s("FinishedAt");

            // tooltips
            Loc.ControlText(lbBPBreedingScore, tt);
            Loc.ControlText(rbBPTopStatsCn, tt);
            Loc.ControlText(rbBPTopStats, tt);
            Loc.ControlText(rbBPHighStats, tt);
            Loc.ControlText(btBPJustMated, tt);
            Loc.setToolTip(nudBPMutationLimit, tt);
            Loc.setToolTip(cbBPTagExcludeDefault, tt);
        }
Пример #5
0
 private void buttonAddTorporTimer_Click(object sender, EventArgs e)
 {
     if (speciesIndex >= 0)
     {
         CreateTimer(Loc.s("timerWakeupOf") + " " + Values.V.speciesNames[speciesIndex], wakeUpTime, null, TimerControl.TimerGroups.Wakeup.ToString());
     }
 }
 public void SetLocalizations()
 {
     Loc.ControlText(gbCreatureInfo);
     Loc.ControlText(lbName, "Name", tt);
     Loc.ControlText(lbOwner, "Owner", tt);
     Loc.ControlText(lbTribe, "Tribe", tt);
     Loc.ControlText(lbServer, "Server");
     Loc.ControlText(lbMother, "Mother");
     Loc.ControlText(lbFather, "Father");
     Loc.ControlText(lbNote, "Note");
     Loc.ControlText(lbCooldown, "cooldown");
     Loc.ControlText(lbGrownIn, "grownIn");
     lbMaturationPerc.Text = Loc.s("Maturation") + " [%]";
     Loc.ControlText(lbMutations, "Mutations");
     Loc.ControlText(lbSex, "Sex");
     Loc.ControlText(lbStatus, "Status");
     Loc.ControlText(btClearColors, "Colors", tt);
     Loc.ControlText(btSaveChanges);
     Loc.ControlText(btAdd2Library);
     //tooltips
     Loc.setToolTip(buttonSex, "Sex", tt);
     Loc.setToolTip(buttonStatus, "Status", tt);
     Loc.setToolTip(dateTimePickerAdded, "domesticatedAt", tt);
     Loc.setToolTip(nudMutationsMother, "mutationCounter", tt);
     Loc.setToolTip(btnGenerateUniqueName, tt);
 }
Пример #7
0
        /// <summary>
        /// Displays infos that no taming data is available.
        /// </summary>
        private void NoTamingData()
        {
            // clear text fields
            labelResult.Text         = Loc.s("noTamingData");
            lbTimeUntilStarving.Text = Loc.s("noTamingData");

            // disable enture (i)? tab
            this.Enabled = false;
        }
Пример #8
0
 public void Clear()
 {
     ClearControls();
     SetBreedingData();
     listViewRaisingTimes.Items.Clear();
     currentSpecies = null;
     males.Clear();
     females.Clear();
     lbBreedingPlanHeader.Text = Loc.s("SelectSpeciesBreedingPlanner");
 }
Пример #9
0
 public static string quickInfoOneFood(Species species, int level, double tamingSpeedMultiplier, double tamingFoodRateMultiplier,
                                       string foodName, int foodAmount, string foodDisplayName)
 {
     tamingTimes(species, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodName, foodAmount,
                 out List <int> foodAmountUsed, out TimeSpan duration, out int _, out int narcotics, out int _, out double te,
                 out double hunger, out int bonusLevel, out bool _);
     return($"{string.Format(Loc.s("WithXFoodTamingTakesTime"), foodAmountUsed[0], foodDisplayName, Utils.durationUntil(duration))}\n" +
            $"{Loc.s("Narcotics")}: {narcotics}\n" +
            $"{Loc.s("TamingEffectiveness_Abb")}: {Math.Round(100 * te, 1)} %\n" +
            $"{Loc.s("BonusLevel")}: +{(level + bonusLevel)}\n" +
            $"{string.Format(Loc.s("FoodHasToDropUnits"), Math.Round(hunger, 1))}");
 }
Пример #10
0
        public static string KnockoutInfo(Species species, int level, double longneck, double crossbow, double bow, double slingshot,
                                          double club, double prod, double harpoon, double boneDamageAdjuster, out bool knockoutNeeded, out string koNumbers)
        {
            koNumbers      = string.Empty;
            knockoutNeeded = false;
            if (species?.taming != null)
            {
                //total torpor for level
                double totalTorpor = species.stats[(int)StatNames.Torpidity].BaseValue * (1 + species.stats[(int)StatNames.Torpidity].IncPerWildLevel * (level - 1));
                // torpor depletion per second for level
                double torporDeplPS = TorporDepletionPS(species.taming.torporDepletionPS0, level);

                knockoutNeeded = species.taming.violent;
                string warning = string.Empty;
                if (!knockoutNeeded)
                {
                    warning = "+++ Creature must not be knocked out for taming! +++\n\n";
                }

                // print needed tranq arrows needed to ko creature.
                // wooden club: 10 torpor
                // slingshot: 14 dmg, stone - tranq - mult: 1.75 ==> 24.5 torpor
                // Bow - arrow causes 20 dmg, tranqMultiplier are 2 + 2.5 = 4.5 ==> 90 Torpor / arrow.
                // crossbow 35 dmg * 4.5 ==> 157.5 torpor
                // longneck dart: 26 * 8.5 = 221
                // shocking tranq dart: 26*17 = 442
                // electric prod: 226

                koNumbers = (harpoon > 0 ? Math.Ceiling(totalTorpor / (306 * boneDamageAdjuster * harpoon)) + " × " + Loc.s("TranqSpearBolts") + "\n" : string.Empty)
                            + (longneck > 0 ? Math.Ceiling(totalTorpor / (442 * boneDamageAdjuster * longneck)) + " × " + Loc.s("ShockingTranqDarts") + "\n" : string.Empty)
                            + (longneck > 0 ? Math.Ceiling(totalTorpor / (221 * boneDamageAdjuster * longneck)) + " × " + Loc.s("TranqDarts") + "\n" : string.Empty)
                            + (prod > 0 ? Math.Ceiling(totalTorpor / (226 * boneDamageAdjuster * prod)) + " × " + Loc.s("ElectricProdHits") + "\n" : string.Empty)
                            + (crossbow > 0 ? Math.Ceiling(totalTorpor / (157.5 * boneDamageAdjuster * crossbow)) + " × " + Loc.s("TranqArrowsCrossBow") + "\n" : string.Empty)
                            + (bow > 0 ? Math.Ceiling(totalTorpor / (90 * boneDamageAdjuster * bow)) + " × " + Loc.s("TranqArrowsBow") + "\n" : string.Empty)
                            + (slingshot > 0 ? Math.Ceiling(totalTorpor / (24.5 * boneDamageAdjuster * slingshot)) + " × " + Loc.s("SlingshotHits") + "\n" : string.Empty)
                            + (club > 0 ? Math.Ceiling(totalTorpor / (10 * boneDamageAdjuster * club)) + " × " + Loc.s("WoodenClubHits") + "\n" : string.Empty);

                // torpor depletion per s
                string torporDepletion = string.Empty;
                if (torporDeplPS > 0)
                {
                    torporDepletion = "\n" + Loc.s("TimeUntilTorporDepleted") + ": " + Utils.durationUntil(new TimeSpan(0, 0, (int)Math.Round(totalTorpor / torporDeplPS)))
                                      + "\n" + Loc.s("TorporDepletion") + ": " + Math.Round(torporDeplPS, 2)
                                      + " / s;\n" + Loc.s("ApproxOneNarcoberryEvery") + " " + Math.Round(7.5 / torporDeplPS + 3, 1)
                                      + " s " + Loc.s("OrOneAscerbicMushroom") + " " + Math.Round(25 / torporDeplPS + 3, 1)
                                      + " s " + Loc.s("OrOneNarcoticEvery") + " " + Math.Round(40 / torporDeplPS + 8, 1)
                                      + " s " + Loc.s("OrOneBioToxinEvery") + " " + Math.Round(80 / torporDeplPS + 16, 1) + " s";
                }

                return(warning + koNumbers + torporDepletion);
            }
            return(string.Empty);
        }
Пример #11
0
        private void updateFirstFeedingWaiting()
        {
            int s = Taming.durationAfterFirstFeeding(speciesIndex, (int)nudLevel.Value, foodDepletion);

            if (s > 0)
            {
                firstFeedingWaiting = "\n\n" + String.Format(Loc.s("waitingAfterFirstFeeding"), Utils.duration(s));
            }
            else
            {
                firstFeedingWaiting = "";
            }
        }
Пример #12
0
 /// <summary>
 /// Probability of the occurence of a stat level, assuming a normal distribution of 180 levels on 7 stats.
 /// </summary>
 /// <param name="level"></param>
 /// <returns></returns>
 public static string LevelPercentile(int level)
 {
     double[] prb = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 99.99, 99.98, 99.95, 99.88, 99.72, 99.40, 98.83, 97.85, 96.28, 93.94, 90.62, 86.20, 80.61, 73.93, 66.33, 58.10, 49.59, 41.19, 33.26, 26.08, 19.85, 14.66, 10.50, 7.30, 4.92, 3.21, 2.04, 1.25, 0.75, 0.43, 0.24, 0.13 };
     if (level < 0)
     {
         level = 0;
     }
     if (level >= prb.Length)
     {
         level = prb.Length - 1;
     }
     return(string.Format(Loc.s("topPercentileLevel"), prb[level].ToString("N2")));
 }
Пример #13
0
 public static string levelPercentile(int l)
 {
     // percentiles assuming a normal distribution of 180 levels on 7 stats
     double[] prb = new double[] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 99.99, 99.98, 99.95, 99.88, 99.72, 99.40, 98.83, 97.85, 96.28, 93.94, 90.62, 86.20, 80.61, 73.93, 66.33, 58.10, 49.59, 41.19, 33.26, 26.08, 19.85, 14.66, 10.50, 7.30, 4.92, 3.21, 2.04, 1.25, 0.75, 0.43, 0.24, 0.13 };
     if (l < 0)
     {
         l = 0;
     }
     if (l >= prb.Length)
     {
         l = prb.Length - 1;
     }
     return(String.Format(Loc.s("topPercentileLevel"), prb[l].ToString("N2")));
 }
 public CreatureInfoInput()
 {
     InitializeComponent();
     speciesIndex                 = -1;
     textBoxName.Text             = "";
     parentComboBoxMother.naLabel = " - " + Loc.s("Mother") + " n/a";
     parentComboBoxMother.Items.Add(" - " + Loc.s("Mother") + " n/a");
     parentComboBoxFather.naLabel = " - " + Loc.s("Father") + " n/a";
     parentComboBoxFather.Items.Add(" - " + Loc.s("Father") + " n/a");
     parentComboBoxMother.SelectedIndex = 0;
     parentComboBoxFather.SelectedIndex = 0;
     updateMaturation = true;
     regionColorIDs   = new int[6];
 }
Пример #15
0
        public static bool ShowTextInput(string text, out string input, string title = "", string preInput = "")
        {
            Form inputForm = new Form()
            {
                Width           = 250,
                Height          = 150,
                FormBorderStyle = FormBorderStyle.FixedToolWindow,
                Text            = title,
                StartPosition   = FormStartPosition.CenterParent,
                ShowInTaskbar   = false
            };
            Label textLabel = new Label()
            {
                Left = 20, Top = 15, Text = text
            };
            TextBox textBox = new TextBox()
            {
                Left = 20, Top = 40, Width = 200
            };
            Button buttonOK = new Button()
            {
                Text = Loc.s("OK"), Left = 120, Width = 100, Top = 70, DialogResult = DialogResult.OK
            };
            Button buttonCancel = new Button()
            {
                Text = Loc.s("Cancel"), Left = 20, Width = 80, Top = 70, DialogResult = DialogResult.Cancel
            };

            buttonOK.Click     += (sender, e) => { inputForm.Close(); };
            buttonCancel.Click += (sender, e) => { inputForm.Close(); };
            inputForm.Controls.Add(textBox);
            inputForm.Controls.Add(buttonOK);
            inputForm.Controls.Add(buttonCancel);
            inputForm.Controls.Add(textLabel);
            inputForm.AcceptButton = buttonOK;
            inputForm.CancelButton = buttonCancel;
            textBox.Text           = preInput;
            textBox.SelectAll();

            input = "";
            if (inputForm.ShowDialog() == DialogResult.OK)
            {
                input = textBox.Text;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #16
0
        public static string quickInfoOneFood(int speciesIndex, int level, double tamingSpeedMultiplier, double tamingFoodRateMultiplier, string foodName, int foodAmount, string foodDisplayName)
        {
            List <int> foodAmountUsed;
            bool       enoughFood;
            TimeSpan   duration;
            int        narcoBerries, narcotics, bioToxines, bonusLevel;
            double     te, hunger;

            tamingTimes(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodName, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood);
            return(String.Format(Loc.s("WithXFoodTamingTakesTime"), foodAmountUsed[0], foodDisplayName, Utils.durationUntil(duration))
                   + "\n" + Loc.s("Narcotics") + ": " + narcotics
                   + "\n" + Loc.s("TamingEffectiveness_Abb") + ": " + Math.Round(100 * te, 1) + " %"
                   + "\n" + Loc.s("BonusLevel") + ": +" + (level + bonusLevel)
                   + "\n" + String.Format(Loc.s("FoodHasToDropUnits"), Math.Round(hunger, 1)));
        }
Пример #17
0
        public static string StatusText(CreatureStatus s)
        {
            switch (s)
            {
            case CreatureStatus.Available: return(Loc.s(CreatureStatus.Available.ToString()));

            case CreatureStatus.Dead: return(Loc.s(CreatureStatus.Dead.ToString()));

            case CreatureStatus.Unavailable: return(Loc.s(CreatureStatus.Unavailable.ToString()));

            case CreatureStatus.Obelisk: return(Loc.s(CreatureStatus.Obelisk.ToString()));

            case CreatureStatus.Cryopod: return(Loc.s(CreatureStatus.Cryopod.ToString()));

            default: return("n/a");
            }
        }
Пример #18
0
 public CreatureInfoInput()
 {
     InitializeComponent();
     selectedSpecies              = null;
     textBoxName.Text             = "";
     parentComboBoxMother.naLabel = " - " + Loc.s("Mother") + " n/a";
     parentComboBoxMother.Items.Add(" - " + Loc.s("Mother") + " n/a");
     parentComboBoxFather.naLabel = " - " + Loc.s("Father") + " n/a";
     parentComboBoxFather.Items.Add(" - " + Loc.s("Father") + " n/a");
     parentComboBoxMother.SelectedIndex = 0;
     parentComboBoxFather.SelectedIndex = 0;
     updateMaturation    = true;
     regionColorIDs      = new int[6];
     Cooldown            = new DateTime(2000, 1, 1);
     Grown               = new DateTime(2000, 1, 1);
     NamesOfAllCreatures = new List <string>();
 }
Пример #19
0
        private void numericUpDownCurrentTorpor_ValueChanged(object sender, EventArgs e)
        {
            var duration = new TimeSpan(0, 0, Taming.secondsUntilWakingUp(selectedSpecies, (int)nudLevel.Value, (double)numericUpDownCurrentTorpor.Value));

            lbTimeUntilWakingUp.Text = string.Format(Loc.s("lbTimeUntilWakingUp"), Utils.duration(duration));
            if (duration.TotalSeconds < 30)
            {
                lbTimeUntilWakingUp.ForeColor = Color.DarkRed;
            }
            else if (duration.TotalSeconds < 120)
            {
                lbTimeUntilWakingUp.ForeColor = Color.DarkGoldenrod;
            }
            else
            {
                lbTimeUntilWakingUp.ForeColor = Color.Black;
            }
            wakeUpTime = DateTime.Now.Add(duration);
        }
        public CreatureInfoInput()
        {
            InitializeComponent();
            selectedSpecies              = null;
            textBoxName.Text             = "";
            parentComboBoxMother.naLabel = " - " + Loc.s("Mother") + " n/a";
            parentComboBoxMother.Items.Add(" - " + Loc.s("Mother") + " n/a");
            parentComboBoxFather.naLabel = " - " + Loc.s("Father") + " n/a";
            parentComboBoxFather.Items.Add(" - " + Loc.s("Father") + " n/a");
            parentComboBoxMother.SelectedIndex = 0;
            parentComboBoxFather.SelectedIndex = 0;
            updateMaturation    = true;
            regionColorIDs      = new int[6];
            CooldownUntil       = new DateTime(2000, 1, 1);
            GrowingUntil        = new DateTime(2000, 1, 1);
            NamesOfAllCreatures = new List <string>();

            var namingPatternButtons = new List <Button> {
                btnGenerateUniqueName, btNamingPattern2, btNamingPattern3, btNamingPattern4, btNamingPattern5, btNamingPattern6
            };

            for (int bi = 0; bi < namingPatternButtons.Count; bi++)
            {
                int localIndex = bi;
                // apply naming pattern
                namingPatternButtons[bi].Click += (s, e) =>
                {
                    if (selectedSpecies != null)
                    {
                        CreatureDataRequested?.Invoke(this, false, true, localIndex);
                    }
                };
                // open naming pattern editor
                namingPatternButtons[bi].MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        CreatureDataRequested?.Invoke(this, true, false, localIndex);
                    }
                };
            }
        }
Пример #21
0
        private void setBreedingData(string species = "")
        {
            int si = Values.V.speciesNames.IndexOf(species);

            listViewRaisingTimes.Items.Clear();
            if (si < 0 || Values.V.species[si].breeding == null)
            {
                listViewRaisingTimes.Items.Add(Loc.s("naYet"));
                labelBreedingInfos.Text = "";
            }
            else
            {
                bool isGlowSpecies = Values.V.IsGlowSpecies(species);
                pedigreeCreature1.IsGlowSpecies = isGlowSpecies;
                pedigreeCreature2.IsGlowSpecies = isGlowSpecies;
                if (Raising.getRaisingTimes(speciesIndex, out string incubationMode, out incubationTime, out TimeSpan babyTime, out TimeSpan 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[] { 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));

                    string eggInfo = Raising.eggTemperature(speciesIndex);
                    if (eggInfo.Length > 0)
                    {
                        eggInfo = "\n\n" + eggInfo;
                    }

                    labelBreedingInfos.Text = $"{Loc.s("TimeBetweenMating")}: {nextMatingMin:d':'hh':'mm':'ss} to {nextMatingMax:d':'hh':'mm':'ss}{eggInfo}";
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Draws the lines that connect ancestors.
        /// </summary>
        /// <param name="g"></param>
        private void DrawLines(Graphics g)
        {
            // lines contains all the coordinates the arrows should be drawn: x1,y1,x2,y2,red/green,mutated/equal
            using (Pen myPen = new Pen(Color.Green, 3))
            {
                myPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;

                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                foreach (int[] line in lines[0])
                {
                    if (line[4] == 1)
                    {
                        myPen.Color = Color.DarkRed;
                    }
                    else if (line[4] == 2)
                    {
                        myPen.Color = Color.Green;
                    }
                    else
                    {
                        myPen.Color = Color.LightGray;
                    }
                    if (line[5] > 0)
                    {
                        // if stat is mutated
                        int mutationBoxWidth = 14;
                        g.FillEllipse(Brushes.LightGreen, (line[0] + line[2] - mutationBoxWidth) / 2, (line[1] + line[3] - mutationBoxWidth) / 2, mutationBoxWidth, mutationBoxWidth);
                    }
                    g.DrawLine(myPen, line[0], line[1], line[2], line[3]);
                }
                myPen.Color = Color.DarkGray;
                myPen.Width = 1;
                foreach (int[] line in lines[1])
                {
                    g.DrawLine(myPen, line[0], line[1], line[2], line[3]);
                }
                if (children.Any())
                {
                    g.DrawString(Loc.s("Descendants"), new Font("Arial", 14), new SolidBrush(Color.Black), 210, 170);
                }
            }
        }
Пример #23
0
        public static string boneDamageAdjustersImmobilization(int speciesIndex, out Dictionary <double, string> boneDamageAdjusters)
        {
            string text = "";

            boneDamageAdjusters = new Dictionary <double, string>();
            if (speciesIndex >= 0 && speciesIndex < Values.V.species.Count)
            {
                if (Values.V.species[speciesIndex].boneDamageAdjusters != null)
                {
                    boneDamageAdjusters = Values.V.species[speciesIndex].boneDamageAdjusters;
                    foreach (KeyValuePair <double, string> bd in Values.V.species[speciesIndex].boneDamageAdjusters)
                    {
                        text += (text.Length > 0 ? "\n" : "") + bd.Value + ": × " + bd.Key;
                    }
                }
                if (Values.V.species[speciesIndex].immobilizedBy != null && Values.V.species[speciesIndex].immobilizedBy.Count > 0)
                {
                    text += (text.Length > 0 ? "\n" : "") + Loc.s("ImmobilizedBy") + ": " + string.Join(", ", Values.V.species[speciesIndex].immobilizedBy);
                }
            }
            return(text);
        }
Пример #24
0
        public static string boneDamageAdjustersImmobilization(Species species, out Dictionary <double, string> boneDamageAdjusters)
        {
            string text = string.Empty;

            boneDamageAdjusters = new Dictionary <double, string>();
            if (species != null)
            {
                if (species.boneDamageAdjusters != null)
                {
                    boneDamageAdjusters = species.boneDamageAdjusters;
                    foreach (KeyValuePair <double, string> bd in boneDamageAdjusters)
                    {
                        text += (text.Length > 0 ? "\n" : string.Empty) + bd.Value + ": × " + bd.Key;
                    }
                }
                if (species.immobilizedBy != null && species.immobilizedBy.Count > 0)
                {
                    text += $"{(text.Length > 0 ? "\n" : string.Empty)}{Loc.s("ImmobilizedBy")}: " +
                            $"{string.Join(", ", species.immobilizedBy)}";
                }
            }
            return(text);
        }
Пример #25
0
        private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMode, bool updateBreedingData = false)
        {
            SuspendLayout();
            this.SuspendDrawing();
            Cursor.Current = Cursors.WaitCursor;
            ClearControls();

            // chosen Creature (only consider this one for its sex)
            bool considerChosenCreature = chosenCreature != null;

            // filter by tags
            int             crCountF = females.Count;
            int             crCountM = males.Count;
            List <Creature> chosenF, chosenM;

            if (considerChosenCreature && chosenCreature.sex == Sex.Female)
            {
                chosenF = new List <Creature>();
            }
            else
            {
                chosenF = FilterByTags(females);
            }
            if (considerChosenCreature && chosenCreature.sex == Sex.Male)
            {
                chosenM = new List <Creature>();
            }
            else
            {
                chosenM = FilterByTags(males);
            }

            // filter by servers
            if (cbServerFilterLibrary.Checked)
            {
                chosenF = chosenF.Where(c => (c.server == "" && !creatureCollection.hiddenServers.Contains("n/a")) ||
                                        (c.server != "" && !creatureCollection.hiddenServers.Contains(c.server))).ToList();
                chosenM = chosenM.Where(c => (c.server == "" && !creatureCollection.hiddenServers.Contains("n/a")) ||
                                        (c.server != "" && !creatureCollection.hiddenServers.Contains(c.server))).ToList();
            }
            // filter by owner
            if (cbOwnerFilterLibrary.Checked)
            {
                chosenF = chosenF.Where(c => (c.owner == "" && !creatureCollection.hiddenOwners.Contains("n/a")) ||
                                        (c.owner != "" && !creatureCollection.hiddenOwners.Contains(c.owner))).ToList();
                chosenM = chosenM.Where(c => (c.owner == "" && !creatureCollection.hiddenOwners.Contains("n/a")) ||
                                        (c.owner != "" && !creatureCollection.hiddenOwners.Contains(c.owner))).ToList();
            }

            bool creaturesTagFilteredOut = (crCountF != chosenF.Count) ||
                                           (crCountM != chosenM.Count);

            crCountF = chosenF.Count;
            crCountM = chosenM.Count;
            if (nudBPMutationLimit.Value >= 0)
            {
                chosenF = chosenF.Where(c => c.Mutations <= nudBPMutationLimit.Value).ToList();
                chosenM = chosenM.Where(c => c.Mutations <= nudBPMutationLimit.Value).ToList();
            }
            bool creaturesMutationsFilteredOut = (crCountF != chosenF.Count) ||
                                                 (crCountM != chosenM.Count);

            if (considerChosenCreature)
            {
                if (chosenCreature.sex == Sex.Female)
                {
                    chosenF.Add(chosenCreature);
                }
                if (chosenCreature.sex == Sex.Male)
                {
                    chosenM.Add(chosenCreature);
                }
            }

            lbBreedingPlanHeader.Text = currentSpecies.DescriptiveNameAndMod + (considerChosenCreature ? " (" + string.Format(Loc.s("onlyPairingsWith"), chosenCreature.name) + ")" : "");
            if (considerChosenCreature && (chosenCreature.flags.HasFlag(CreatureFlags.Neutered) || chosenCreature.status != CreatureStatus.Available))
            {
                lbBreedingPlanHeader.Text += $"{Loc.s("BreedingNotPossible")} ! ({(chosenCreature.flags.HasFlag(CreatureFlags.Neutered) ? Loc.s("Neutered") : Loc.s("notAvailable"))})";
            }

            string warningText = "";

            if (creaturesTagFilteredOut)
            {
                warningText = Loc.s("BPsomeCreaturesAreFilteredOutTags");
            }
            if (creaturesMutationsFilteredOut)
            {
                warningText += (warningText.Length > 0 ? " " + Loc.s("BPorMutations") : Loc.s("BPsomeCreaturesAreFilteredOutMutations"));
            }
            if (warningText.Length > 0)
            {
                SetMessageLabelText(warningText + ".\n" + Loc.s("BPTopStatsShownMightNotTotalTopStats"), MessageBoxIcon.Warning);
            }

            var combinedCreatures = new List <Creature>(chosenF);

            combinedCreatures.AddRange(chosenM);
            // determine top-stats for choosen creatures.
            int[] topStats = new int[Values.STATS_COUNT];
            foreach (Creature c in combinedCreatures)
            {
                for (int s = 0; s < Values.STATS_COUNT; s++)
                {
                    if (topStats[s] < c.levelsWild[s])
                    {
                        topStats[s] = c.levelsWild[s];
                    }
                }
            }

            if (Properties.Settings.Default.IgnoreSexInBreedingPlan)
            {
                chosenF = new List <Creature>(combinedCreatures);
                chosenM = new List <Creature>(combinedCreatures);
            }

            if (chosenF.Count > 0 && chosenM.Count > 0)
            {
                pedigreeCreature1.Show();
                pedigreeCreature2.Show();
                lbBPBreedingScore.Show();

                breedingPairs.Clear();
                short[] bestPossLevels = new short[Values.STATS_COUNT]; // best possible levels

                foreach (Creature female in chosenF)
                {
                    foreach (Creature male in chosenM)
                    {
                        if (male == female || // happens if Properties.Settings.Default.IgnoreSexInBreedingPlan (when using S+ mutator)
                            (nudBPMutationLimit.Value >= 0 && female.Mutations > nudBPMutationLimit.Value && male.Mutations > nudBPMutationLimit.Value)    // if one pair is below the limit, show this pair
                            )
                        {
                            continue;
                        }
                        double t    = 0;
                        int    nrTS = 0;
                        double eTS  = 0;

                        int topfemale = 0;
                        int topmale   = 0;

                        for (int s = 0; s < Values.STATS_COUNT; s++)
                        {
                            if (s == (int)StatNames.Torpidity)
                            {
                                continue;
                            }
                            bestPossLevels[s] = 0;
                            int higherLevel = Math.Max(female.levelsWild[s], male.levelsWild[s]);
                            int lowerlevel  = Math.Min(female.levelsWild[s], male.levelsWild[s]);
                            if (higherLevel < 0)
                            {
                                higherLevel = 0;
                            }
                            if (lowerlevel < 0)
                            {
                                lowerlevel = 0;
                            }

                            double tt = statWeights[s] * (probabilityHigherLevel * higherLevel + probabilityLowerLevel * lowerlevel) / 40;
                            if (tt > 0)
                            {
                                if (breedingMode == BreedingMode.TopStatsLucky)
                                {
                                    if (female.levelsWild[s] == topStats[s] || male.levelsWild[s] == topStats[s])
                                    {
                                        if (female.levelsWild[s] == topStats[s] && male.levelsWild[s] == topStats[s])
                                        {
                                            tt *= 1.142;
                                        }
                                    }
                                    else if (bestLevels[s] > 0)
                                    {
                                        tt *= .01;
                                    }
                                }
                                else if (breedingMode == BreedingMode.TopStatsConservative && bestLevels[s] > 0)
                                {
                                    bestPossLevels[s] = (short)Math.Max(female.levelsWild[s], male.levelsWild[s]);
                                    tt *= .01;
                                    if (female.levelsWild[s] == topStats[s] || male.levelsWild[s] == topStats[s])
                                    {
                                        nrTS++;
                                        eTS += female.levelsWild[s] == topStats[s] && male.levelsWild[s] == topStats[s] ? 1 : probabilityHigherLevel;
                                        if (female.levelsWild[s] == topStats[s])
                                        {
                                            topfemale++;
                                        }
                                        if (male.levelsWild[s] == topStats[s])
                                        {
                                            topmale++;
                                        }
                                    }
                                }
                            }
                            t += tt;
                        }

                        if (breedingMode == BreedingMode.TopStatsConservative)
                        {
                            if (topfemale < nrTS && topmale < nrTS)
                            {
                                t += eTS;
                            }
                            else
                            {
                                t += .1 * eTS;
                            }
                            // check if the best possible stat outcome already exists in a male
                            bool maleExists = false;

                            foreach (Creature cr in chosenM)
                            {
                                maleExists = true;
                                for (int s = 0; s < Values.STATS_COUNT; s++)
                                {
                                    if (s == (int)StatNames.Torpidity || cr.valuesDom[s] == 0)
                                    {
                                        continue;                                                        // TODO check if stat is used with cr.species.statsUsed[s]
                                    }
                                    if (cr.levelsWild[s] != bestPossLevels[s])
                                    {
                                        maleExists = false;
                                        break;
                                    }
                                }
                                if (maleExists)
                                {
                                    break;
                                }
                            }
                            if (maleExists)
                            {
                                t *= .4; // another male with the same stats is not worth much, the mating-cooldown of males is short.
                            }
                            else
                            {
                                // check if the best possible stat outcome already exists in a female
                                bool femaleExists = false;
                                foreach (Creature cr in chosenF)
                                {
                                    femaleExists = true;
                                    for (int s = 0; s < Values.STATS_COUNT; s++)
                                    {
                                        if (s == (int)StatNames.Torpidity || cr.valuesDom[s] == 0)
                                        {
                                            continue;                                                        // TODO check if stat is used with cr.species.statsUsed[s]
                                        }
                                        if (cr.levelsWild[s] != bestPossLevels[s])
                                        {
                                            femaleExists = false;
                                            break;
                                        }
                                    }
                                    if (femaleExists)
                                    {
                                        break;
                                    }
                                }
                                if (femaleExists)
                                {
                                    t *= .8; // another female with the same stats may be useful, but not so much in conservative breeding
                                }
                            }
                            //t *= 2; // scale conservative mode as it rather displays improvement, but only scarcely
                        }

                        breedingPairs.Add(new BreedingPair(female, male, t * 1.25));
                    }
                }

                breedingPairs = breedingPairs.OrderByDescending(p => p.BreedingScore).ToList();
                double minScore = (breedingPairs.Count > 0 ? breedingPairs[breedingPairs.Count - 1].BreedingScore : 0);
                if (minScore < 0)
                {
                    foreach (BreedingPair bp in breedingPairs)
                    {
                        bp.BreedingScore -= minScore;
                    }
                }

                // draw best parents
                int row = 0;
                // scrolloffsets
                int xS = AutoScrollPosition.X;
                int yS = AutoScrollPosition.Y;

                for (int i = 0; i < breedingPairs.Count && i < creatureCollection.maxBreedingSuggestions; i++)
                {
                    PedigreeCreature pc;
                    if (2 * i < pcs.Count)
                    {
                        pcs[2 * i].Creature            = breedingPairs[i].Female;
                        pcs[2 * i].enabledColorRegions = enabledColorRegions;
                        pcs[2 * i].comboId             = i;
                        pcs[2 * i].Show();
                    }
                    else
                    {
                        pc = new PedigreeCreature(breedingPairs[i].Female, enabledColorRegions, i);
                        //pc.Location = new Point(10 + xS, 5 + 35 * row + yS);
                        pc.CreatureClicked      += CreatureClicked;
                        pc.CreatureEdit         += CreatureEdit;
                        pc.BPRecalc             += RecalculateBreedingPlan;
                        pc.BestBreedingPartners += BestBreedingPartners;
                        pc.exportToClipboard    += ExportToClipboard;
                        flowLayoutPanelPairs.Controls.Add(pc);
                        pcs.Add(pc);
                    }

                    // draw score
                    PictureBox pb;
                    if (i < pbs.Count)
                    {
                        pb = pbs[i];
                        pbs[i].Show();
                    }
                    else
                    {
                        pb = new PictureBox
                        {
                            Size = new Size(87, 35)
                        };
                        //pb.Location = new Point(308 + xS, 19 + 35 * row + yS);
                        pbs.Add(pb);
                        flowLayoutPanelPairs.Controls.Add(pb);
                    }

                    if (2 * i + 1 < pcs.Count)
                    {
                        pcs[2 * i + 1].Creature            = breedingPairs[i].Male;
                        pcs[2 * i + 1].enabledColorRegions = enabledColorRegions;
                        pcs[2 * i + 1].comboId             = i;
                        pcs[2 * i + 1].Show();
                    }
                    else
                    {
                        pc = new PedigreeCreature(breedingPairs[i].Male, enabledColorRegions, i);
                        //pc.Location = new Point(397 + xS, 5 + 35 * row + yS);
                        pc.CreatureClicked      += CreatureClicked;
                        pc.CreatureEdit         += CreatureEdit;
                        pc.BPRecalc             += RecalculateBreedingPlan;
                        pc.BestBreedingPartners += BestBreedingPartners;
                        pc.exportToClipboard    += ExportToClipboard;
                        flowLayoutPanelPairs.Controls.Add(pc);
                        flowLayoutPanelPairs.SetFlowBreak(pc, true);
                        pcs.Add(pc);
                    }

                    Bitmap   bm = new Bitmap(pb.Width, pb.Height);
                    Graphics g;
                    using (g = Graphics.FromImage(bm))
                    {
                        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        Brush br  = new SolidBrush(Utils.getColorFromPercent((int)(breedingPairs[i].BreedingScore * 12.5), 0.5));
                        Brush brd = new SolidBrush(Utils.getColorFromPercent((int)(breedingPairs[i].BreedingScore * 12.5), -.2));
                        g.FillRectangle(brd, 0, 15, 87, 5);
                        g.FillRectangle(brd, 20, 10, 47, 15);
                        g.FillRectangle(br, 1, 16, 85, 3);
                        g.FillRectangle(br, 21, 11, 45, 13);
                        g.DrawString(breedingPairs[i].BreedingScore.ToString("N4"), new Font("Microsoft Sans Serif", 8.25f), new SolidBrush(Color.Black), 24, 12);
                        pb.Image = bm;
                    }

                    row++;
                }
                // hide unused controls
                for (int i = breedingPairs.Count; i < creatureCollection.maxBreedingSuggestions && 2 * i + 1 < pcs.Count && i < pbs.Count; i++)
                {
                    pcs[2 * i].Hide();
                    pcs[2 * i + 1].Hide();
                    pbs[i].Hide();
                }

                if (updateBreedingData)
                {
                    SetBreedingData(currentSpecies);
                }
                if (breedingPairs.Count > 0)
                {
                    SetParents(0);

                    // if breeding mode is conservative and a creature with top-stats already exists, the scoring might seem off
                    if (breedingMode == BreedingMode.TopStatsConservative)
                    {
                        bool            bestCreatureAlreadyAvailable = true;
                        Creature        bestCreature           = null;
                        List <Creature> choosenFemalesAndMales = chosenF.Concat(chosenM).ToList();
                        foreach (Creature cr in choosenFemalesAndMales)
                        {
                            bestCreatureAlreadyAvailable = true;
                            for (int s = 0; s < Values.STATS_COUNT; s++)
                            {
                                // if the stat is not a top stat and the stat is leveled in wild creatures
                                if (!cr.topBreedingStats[s] && cr.Species.stats[s].IncPerWildLevel != 0)
                                {
                                    bestCreatureAlreadyAvailable = false;
                                    break;
                                }
                            }
                            if (bestCreatureAlreadyAvailable)
                            {
                                bestCreature = cr;
                                break;
                            }
                        }

                        if (bestCreatureAlreadyAvailable)
                        {
                            SetMessageLabelText(string.Format(Loc.s("AlreadyCreatureWithTopStats"), bestCreature.name, Utils.sexSymbol(bestCreature.sex)), MessageBoxIcon.Warning);
                        }
                    }
                }
                else
                {
                    SetParents(-1);
                }
            }
            else
            {
                // hide unused controls
                pedigreeCreature1.Hide();
                pedigreeCreature2.Hide();
                lbBPBreedingScore.Hide();
                for (int i = 0; i < creatureCollection.maxBreedingSuggestions && 2 * i + 1 < pcs.Count && i < pbs.Count; i++)
                {
                    pcs[2 * i].Hide();
                    pcs[2 * i + 1].Hide();
                    pbs[i].Hide();
                }
                lbBreedingPlanInfo.Text    = string.Format(Loc.s("NoPossiblePairingForSpeciesFound"), currentSpecies);
                lbBreedingPlanInfo.Visible = true;
                if (updateBreedingData)
                {
                    SetBreedingData(currentSpecies);
                }
            }
            Cursor.Current = Cursors.Default;
            this.ResumeDrawing();

            if (considerChosenCreature)
            {
                btShowAllCreatures.Text = "Unset Restriction to " + chosenCreature.name;
            }
            btShowAllCreatures.Visible = considerChosenCreature;
            ResumeLayout();
        }
Пример #26
0
        private void setLocalizations(bool init = true)
        {
            if (init)
            {
                initLocalization();
            }

            // menu
            Loc.ControlText(fileToolStripMenuItem);
            Loc.ControlText(newToolStripMenuItem);
            Loc.ControlText(loadToolStripMenuItem);
            Loc.ControlText(loadAndAddToolStripMenuItem);
            Loc.ControlText(saveToolStripMenuItem);
            Loc.ControlText(saveAsToolStripMenuItem);
            Loc.ControlText(importingFromSavegameToolStripMenuItem);
            Loc.ControlText(importingFromSavegameEmptyToolStripMenuItem);
            //Loc.ControlText(runDefaultExtractionAndImportFileToolStripMenuItem);
            //Loc.ControlText(runDefaultExtractionToolStripMenuItem);
            //Loc.ControlText(importCreatedJsonfileToolStripMenuItem);
            Loc.ControlText(importExportedCreaturesToolStripMenuItem);
            //Loc.ControlText(runDefaultExtractionAndImportFileToolStripMenuItem);
            //Loc.ControlText(runDefaultExtractionToolStripMenuItem);
            //Loc.ControlText(importCreatedJsonfileToolStripMenuItem);
            Loc.ControlText(modValueManagerToolStripMenuItem);
            Loc.ControlText(settingsToolStripMenuItem);
            Loc.ControlText(openSettingsToolStripMenuItem);
            Loc.ControlText(quitToolStripMenuItem);
            Loc.ControlText(editToolStripMenuItem);
            Loc.ControlText(exportValuesToClipboardToolStripMenuItem);
            Loc.ControlText(importValuesFromClipboardToolStripMenuItem);
            Loc.ControlText(setStatusToolStripMenuItem);
            Loc.ControlText(multiSetterToolStripMenuItem);
            Loc.ControlText(deleteSelectedToolStripMenuItem);
            Loc.ControlText(findDuplicatesToolStripMenuItem);
            Loc.ControlText(copyCreatureToolStripMenuItem);
            Loc.ControlText(pasteCreatureToolStripMenuItem);
            Loc.ControlText(viewToolStripMenuItem);
            Loc.ControlText(deadCreaturesToolStripMenuItem);
            Loc.ControlText(unavailableCreaturesToolStripMenuItem);
            Loc.ControlText(obeliskCreaturesToolStripMenuItem);
            Loc.ControlText(neuteredCreaturesToolStripMenuItem);
            Loc.ControlText(mutatedCreaturesToolStripMenuItem);
            Loc.ControlText(femalesToolStripMenuItem);
            Loc.ControlText(malesToolStripMenuItem);
            Loc.ControlText(helpToolStripMenuItem);
            Loc.ControlText(aboutToolStripMenuItem);
            Loc.ControlText(onlinehelpToolStripMenuItem);
            Loc.ControlText(BreedingPlanHelpToolStripMenuItem);
            Loc.ControlText(extractionIssuesToolStripMenuItem);
            Loc.ControlText(checkForUpdatedStatsToolStripMenuItem);
            Loc.ControlText(toolStripButtonCopy2Tester);
            Loc.ControlText(toolStripButtonCopy2Extractor);
            Loc.ControlText(toolStripButtonClear);
            Loc.ControlText(toolStripButtonAddNote);
            Loc.ControlText(toolStripButtonRemoveNote);
            Loc.ControlText(toolStripButtonDeleteExpiredIncubationTimers);
            Loc.ControlText(toolStripButtonSaveCreatureValuesTemp);
            Loc.ControlText(toolStripButtonDeleteTempCreature);
            Loc.ControlText(tsBtAddAsExtractionTest);
            Loc.ControlText(copyToMultiplierTesterToolStripButton);

            // top bar
            Loc.ControlText(cbGuessSpecies, tt);
            Loc.ControlText(btReadValuesFromArk, tt);
            Loc.ControlText(btImportLastExported, tt);
            Loc.ControlText(cbToggleOverlay);

            // tester
            Loc.ControlText(tabPageStatTesting, "statTesting");
            Loc.ControlText(rbWildTester, "wild");
            Loc.ControlText(rbTamedTester, "tamed");
            Loc.ControlText(rbBredTester, "bred");
            Loc.ControlText(lbTesterWildLevel, "wildLvl");
            Loc.ControlText(lbTesterDomLevel, "domLvl");
            Loc.ControlText(lbCurrentValue, "currentValue");
            Loc.ControlText(lbBreedingValueTester, "breedingValue");
            Loc.ControlText(lbNotYetTamed);
            Loc.ControlText(gpPreviewEdit);
            Loc.ControlText(lbTestingInfo);
            Loc.ControlText(gbStatChart, "statChart");
            Loc.ControlText(lbCurrentCreature, "CurrentCreature");
            Loc.setToolTip(lbImprintedCount, tt);
            Loc.setToolTip(lbTesterDomLevel, "domLevelExplanation", tt);
            Loc.setToolTip(lbTesterWildLevel, "wildLevelExplanation", tt);

            // extractor
            Loc.ControlText(tabPageExtractor, "extractor");
            Loc.ControlText(lbCurrentStatEx, "currentStatValue");
            Loc.ControlText(lbExtractorWildLevel, "wildLvl");
            Loc.ControlText(lbExtractorDomLevel, "domLvl");
            Loc.ControlText(lbSum);
            Loc.ControlText(lbShouldBe);
            Loc.ControlText(lbImprintingFailInfo);
            Loc.ControlText(cbExactlyImprinting, tt);
            Loc.ControlText(btExtractLevels);
            Loc.ControlText(cbQuickWildCheck, tt);
            Loc.ControlText(rbWildExtractor, "wild");
            Loc.ControlText(rbTamedExtractor, "tamed");
            Loc.ControlText(rbBredExtractor, "bred");
            Loc.setToolTip(lbImprintingCuddleCountExtractor, tt);
            Loc.setToolTip(lbSumWild, tt);
            Loc.setToolTip(lbSumDom, tt);
            Loc.setToolTip(lbSumDomSB, tt);
            Loc.setToolTip(lbListening, tt);
            Loc.setToolTip(lbExtractorDomLevel, "domLevelExplanation", tt);
            Loc.setToolTip(lbExtractorWildLevel, "wildLevelExplanation", tt);

            // library
            Loc.ControlText(tabPageLibrary, "library");
            columnHeaderName.Text       = Loc.s("Name");
            columnHeaderOwner.Text      = Loc.s("Owner");
            columnHeaderNote.Text       = Loc.s("Note");
            columnHeaderServer.Text     = Loc.s("Server");
            columnHeaderHP.Text         = Utils.statName(StatNames.Health, true);
            columnHeaderSt.Text         = Utils.statName(StatNames.Stamina, true);
            columnHeaderOx.Text         = Utils.statName(StatNames.Oxygen, true);
            columnHeaderFo.Text         = Utils.statName(StatNames.Food, true);
            columnHeaderWe.Text         = Utils.statName(StatNames.Weight, true);
            columnHeaderDm.Text         = Utils.statName(StatNames.MeleeDamageMultiplier, true);
            columnHeaderSp.Text         = Utils.statName(StatNames.SpeedMultiplier, true);
            columnHeaderTo.Text         = Utils.statName(StatNames.Torpidity, true);
            columnHeaderWa.Text         = Utils.statName(StatNames.CraftingSpeedMultiplier, true);
            columnHeaderTemp.Text       = Utils.statName(StatNames.Temperature, true);
            columnHeaderCr.Text         = Utils.statName(StatNames.Water, true);
            columnHeaderFr.Text         = Utils.statName(StatNames.TemperatureFortitude, true);
            columnHeaderTopStatsNr.Text = Loc.s("Top");
            columnHeaderTopness.Text    = Loc.s("topPercentage");
            columnHeaderGen.Text        = Loc.s("Generation_Abb");
            columnHeaderLW.Text         = Loc.s("LevelWild_Abb");
            columnHeaderMutations.Text  = Loc.s("Mutations_Abb");
            columnHeaderAdded.Text      = Loc.s("added");
            columnHeaderCooldown.Text   = Loc.s("cooldownGrowing");
            columnHeaderColor0.Text     = Loc.s("C0");
            columnHeaderColor1.Text     = Loc.s("C1");
            columnHeaderColor2.Text     = Loc.s("C2");
            columnHeaderColor3.Text     = Loc.s("C3");
            columnHeaderColor4.Text     = Loc.s("C4");
            columnHeaderColor5.Text     = Loc.s("C5");

            // other tabs
            Loc.ControlText(tabPagePedigree, "pedigree");
            Loc.ControlText(tabPageTaming, "Taming");
            Loc.ControlText(tabPageBreedingPlan, "BreedingPlan");
            Loc.ControlText(tabPageRaising, "Raising");
            Loc.ControlText(tabPagePlayerTribes, "Player");

            // other controls
            creatureInfoInputTester.SetLocalizations();
            creatureInfoInputExtractor.SetLocalizations();
            pedigree1.SetLocalizations();
            tamingControl1.SetLocalizations();
            breedingPlan1.SetLocalizations();
        }
Пример #27
0
        /// <summary>
        /// Extract the levels by using the inputs of the statIOs and various other controls of the extractor.
        /// </summary>
        /// <param name="autoExtraction"></param>
        /// <param name="statInputsHighPrecision">Set to true if the data is from an export file which has a higher precision for stat-values so the tolerance of calculations can be smaller.</param>
        /// <returns></returns>
        private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPrecision = false)
        {
            SuspendLayout();
            int activeStatKeeper = activeStatIndex;

            ClearAll(clearExtractionCreatureData);

            if (cbExactlyImprinting.Checked)
            {
                extractor.possibleIssues |= IssueNotes.Issue.ImprintingLocked;
            }

            extractor.ExtractLevels(speciesSelector1.SelectedSpecies, (int)numericUpDownLevel.Value, statIOs,
                                    (double)numericUpDownLowerTEffBound.Value / 100, (double)numericUpDownUpperTEffBound.Value / 100,
                                    rbTamedExtractor.Checked, rbBredExtractor.Checked,
                                    (double)numericUpDownImprintingBonusExtractor.Value / 100, !cbExactlyImprinting.Checked,
                                    creatureCollection.allowMoreThanHundredImprinting, creatureCollection.serverMultipliers.BabyImprintingStatScaleMultiplier,
                                    Values.V.currentServerMultipliers.BabyCuddleIntervalMultiplier,
                                    creatureCollection.considerWildLevelSteps, creatureCollection.wildLevelStep, statInputsHighPrecision, out bool imprintingBonusChanged);

            numericUpDownImprintingBonusExtractor.ValueSave = (decimal)extractor.ImprintingBonus * 100;
            numericUpDownImprintingBonusExtractor_ValueChanged(null, null);

            if (imprintingBonusChanged && !autoExtraction)
            {
                extractor.possibleIssues |= IssueNotes.Issue.ImprintingNotPossible;
            }

            bool everyStatHasAtLeastOneResult = extractor.EveryStatHasAtLeastOneResult;

            // remove all results that require a total wild-level higher than the max
            // Tek-variants have 20% higher levels
            extractor.RemoveImpossibleTEsAccordingToMaxWildLevel((int)Math.Ceiling(creatureCollection.maxWildLevel * (speciesSelector1.SelectedSpecies.name.StartsWith("Tek ") ? 1.2 : 1)));

            if (everyStatHasAtLeastOneResult && !extractor.EveryStatHasAtLeastOneResult)
            {
                MessageBox.Show(string.Format(Loc.s("issueMaxWildLevelTooLow"), creatureCollection.maxWildLevel));
            }

            if (!extractor.SetStatLevelBoundsAndFilter(out int statIssue))
            {
                if (statIssue == -1)
                {
                    ExtractionFailed(IssueNotes.Issue.WildTamedBred
                                     | IssueNotes.Issue.CreatureLevel
                                     | (rbTamedExtractor.Checked ? IssueNotes.Issue.TamingEffectivenessRange : IssueNotes.Issue.None));
                    ResumeLayout();
                    return(false);
                }
                extractor.possibleIssues |= IssueNotes.Issue.Typo | IssueNotes.Issue.CreatureLevel;
                statIOs[statIssue].Status = StatIOStatus.Error;
                statIOs[(int)StatNames.Torpidity].Status = StatIOStatus.Error;
            }

            // get mean-level (most probable for the wild levels)
            // TODO handle species without wild levels in speed better (some flyers)
            double meanWildLevel  = Math.Round((double)extractor.levelWildSum / 7, 1);
            bool   nonUniqueStats = false;

            for (int s = 0; s < Values.STATS_COUNT; s++)
            {
                if (!activeStats[s])
                {
                    statIOs[s].Status = StatIOStatus.Neutral;
                }
                else if (extractor.results[s].Count > 0)
                {
                    // choose the most probable wild-level, aka the level nearest to the mean of the wild levels.
                    int r = 0;
                    for (int b = 1; b < extractor.results[s].Count; b++)
                    {
                        if (Math.Abs(meanWildLevel - extractor.results[s][b].levelWild) < Math.Abs(meanWildLevel - extractor.results[s][r].levelWild))
                        {
                            r = b;
                        }
                    }

                    SetLevelCombination(s, r);
                    if (extractor.results[s].Count > 1)
                    {
                        statIOs[s].Status = StatIOStatus.Nonunique;
                        nonUniqueStats    = true;
                    }
                    else
                    {
                        statIOs[s].Status = StatIOStatus.Unique;
                    }
                }
                else
                {
                    // no results for this stat
                    statIOs[s].Status      = StatIOStatus.Error;
                    extractor.validResults = false;
                    if (rbTamedExtractor.Checked && extractor.statsWithTE.Contains(s))
                    {
                        extractor.possibleIssues |= IssueNotes.Issue.TamingEffectivenessRange;
                    }
                    // if the stat is changed by singleplayer-settings, list that as a possible issue
                    if (s == (int)StatNames.Health ||
                        s == (int)StatNames.MeleeDamageMultiplier)
                    {
                        extractor.possibleIssues |= IssueNotes.Issue.Singleplayer;
                    }
                }
            }
            if (!extractor.validResults)
            {
                ExtractionFailed(IssueNotes.Issue.Typo | IssueNotes.Issue.WildTamedBred | IssueNotes.Issue.LockedDom |
                                 IssueNotes.Issue.OutdatedIngameValues | IssueNotes.Issue.ImprintingNotUpdated |
                                 (statIOs[(int)StatNames.Torpidity].LevelWild >= (int)numericUpDownLevel.Value ? IssueNotes.Issue.CreatureLevel : IssueNotes.Issue.None));
                ResumeLayout();
                return(false);
            }
            extractor.uniqueResults = !nonUniqueStats;
            if (!extractor.uniqueResults)
            {
                groupBoxPossibilities.Visible = true;
                lbInfoYellowStats.Visible     = true;
            }

            // if damage has a possibility for the dom-levels to make it a valid sum, take this
            int domLevelsChosenSum = 0;

            for (int s = 0; s < Values.STATS_COUNT; s++)
            {
                if (s != (int)StatNames.Torpidity)
                {
                    domLevelsChosenSum += extractor.results[s][extractor.chosenResults[s]].levelDom;
                }
            }
            if (domLevelsChosenSum != extractor.levelDomSum)
            {
                // sum of domlevels is not correct. Try to find another combination
                domLevelsChosenSum -= extractor.results[(int)StatNames.MeleeDamageMultiplier][extractor.chosenResults[(int)StatNames.MeleeDamageMultiplier]].levelDom;
                bool changeChosenResult = false;
                int  cR = 0;
                for (int r = 0; r < extractor.results[(int)StatNames.MeleeDamageMultiplier].Count; r++)
                {
                    if (domLevelsChosenSum + extractor.results[(int)StatNames.MeleeDamageMultiplier][r].levelDom == extractor.levelDomSum)
                    {
                        cR = r;
                        changeChosenResult = true;
                        break;
                    }
                }
                if (changeChosenResult)
                {
                    SetLevelCombination((int)StatNames.MeleeDamageMultiplier, cR);
                }
            }

            if (extractor.postTamed)
            {
                SetUniqueTE();
            }
            else
            {
                labelTE.Text      = Loc.s("notYetTamed");
                labelTE.BackColor = Color.Transparent;
            }

            SetWildSpeedLevelAccordingToOthers();

            lbSumDomSB.Text = extractor.levelDomSum.ToString();
            ShowSumOfChosenLevels();
            ShowLevelsInOverlay();

            SetActiveStat(activeStatKeeper);

            if (!extractor.postTamed)
            {
                labelFootnote.Text        = Loc.s("lbNotYetTamed");
                button2TamingCalc.Visible = true;

                // display taming info
                if (cbQuickWildCheck.Checked)
                {
                    tamingControl1.setLevel(statIOs[(int)StatNames.Torpidity].LevelWild + 1);
                }
                else
                {
                    tamingControl1.setLevel((int)numericUpDownLevel.Value);
                }
                labelTamingInfo.Text       = tamingControl1.quickTamingInfos;
                groupBoxTamingInfo.Visible = true;
            }

            ResumeLayout();
            return(true);
        }
Пример #28
0
 /// <summary>
 /// Returns the formated timespan and also the DateTime when the timespan is over
 /// </summary>
 /// <param name="ts">timespan of countdown</param>
 /// <returns>Returns the timespan and the DateTime when the timespan is over</returns>
 public static string durationUntil(TimeSpan ts)
 {
     return(ts.ToString("d':'hh':'mm':'ss") + " (" + Loc.s("until") + ": " + shortTimeDate(DateTime.Now.Add(ts)) + ")");
 }
Пример #29
0
        private void SetParents(int comboIndex)
        {
            if (comboIndex < 0 || comboIndex >= breedingPairs.Count)
            {
                pedigreeCreatureBest.Clear();
                pedigreeCreatureWorst.Clear();
                lbBreedingPlanInfo.Visible = false;
                lbBPProbabilityBest.Text   = "";
                return;
            }

            int?     levelStep = creatureCollection.getWildLevelStep();
            Creature crB       = new Creature(currentSpecies, "", "", "", 0, new int[Values.STATS_COUNT], null, 100, true, levelStep: levelStep);
            Creature crW       = new Creature(currentSpecies, "", "", "", 0, new int[Values.STATS_COUNT], null, 100, true, levelStep: levelStep);
            Creature mother    = breedingPairs[comboIndex].Female;
            Creature father    = breedingPairs[comboIndex].Male;

            crB.Mother = mother;
            crB.Father = father;
            crW.Mother = mother;
            crW.Father = father;
            double probabilityBest   = 1;
            bool   totalLevelUnknown = false; // if stats are unknown, total level is as well (==> oxygen, speed)

            for (int s = 0; s < Values.STATS_COUNT; s++)
            {
                if (s == (int)StatNames.Torpidity)
                {
                    continue;
                }
                crB.levelsWild[s]       = statWeights[s] < 0 ? Math.Min(mother.levelsWild[s], father.levelsWild[s]) : Math.Max(mother.levelsWild[s], father.levelsWild[s]);
                crB.valuesBreeding[s]   = StatValueCalculation.CalculateValue(currentSpecies, s, crB.levelsWild[s], 0, true, 1, 0);
                crB.topBreedingStats[s] = (crB.levelsWild[s] == bestLevels[s]);
                crW.levelsWild[s]       = statWeights[s] < 0 ? Math.Max(mother.levelsWild[s], father.levelsWild[s]) : Math.Min(mother.levelsWild[s], father.levelsWild[s]);
                crW.valuesBreeding[s]   = StatValueCalculation.CalculateValue(currentSpecies, s, crW.levelsWild[s], 0, true, 1, 0);
                crW.topBreedingStats[s] = (crW.levelsWild[s] == bestLevels[s]);
                if (crB.levelsWild[s] == -1 || crW.levelsWild[s] == -1)
                {
                    totalLevelUnknown = true;
                }
                if (crB.levelsWild[s] > crW.levelsWild[s])
                {
                    probabilityBest *= probabilityHigherLevel;
                }
            }
            crB.levelsWild[(int)StatNames.Torpidity] = crB.levelsWild.Sum();
            crW.levelsWild[(int)StatNames.Torpidity] = crW.levelsWild.Sum();
            crB.name = Loc.s("BestPossible");
            crW.name = Loc.s("WorstPossible");
            crB.RecalculateCreatureValues(levelStep);
            crW.RecalculateCreatureValues(levelStep);
            pedigreeCreatureBest.totalLevelUnknown  = totalLevelUnknown;
            pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown;
            int mutationCounterMaternal = mother.Mutations;
            int mutationCounterPaternal = father.Mutations;

            crB.mutationsMaternal          = mutationCounterMaternal;
            crB.mutationsPaternal          = mutationCounterPaternal;
            crW.mutationsMaternal          = mutationCounterMaternal;
            crW.mutationsPaternal          = mutationCounterPaternal;
            pedigreeCreatureBest.Creature  = crB;
            pedigreeCreatureWorst.Creature = crW;
            lbBPProbabilityBest.Text       = $"{Loc.s("ProbabilityForBest")}: {Math.Round(100 * probabilityBest, 1)}%";

            // set probability barChart
            offspringPossibilities1.Calculate(currentSpecies, mother.levelsWild, father.levelsWild);

            // highlight parents
            int hiliId = comboIndex * 2;

            for (int i = 0; i < pcs.Count; i++)
            {
                pcs[i].highlight = (i == hiliId || i == hiliId + 1);
            }
        }
Пример #30
0
        /// <summary>
        /// Call this method if an extraction failed. Possible causes of the failure are displayed for the user.
        /// </summary>
        /// <param name="issues"></param>
        private void ExtractionFailed(IssueNotes.Issue issues = IssueNotes.Issue.None)
        {
            issues |= extractor.possibleIssues; // add all issues that arised during extraction
            if (issues == IssueNotes.Issue.None)
            {
                // set background of inputs to neutral
                numericUpDownLevel.BackColor                    = SystemColors.Window;
                numericUpDownLowerTEffBound.BackColor           = SystemColors.Window;
                numericUpDownUpperTEffBound.BackColor           = SystemColors.Window;
                numericUpDownImprintingBonusExtractor.BackColor = SystemColors.Window;
                cbExactlyImprinting.BackColor                   = Color.Transparent;
                panelSums.BackColor                  = Color.Transparent;
                panelWildTamedBred.BackColor         = Color.Transparent;
                labelTE.BackColor                    = Color.Transparent;
                llOnlineHelpExtractionIssues.Visible = false;
                labelErrorHelp.Visible               = false;
                lbImprintingFailInfo.Visible         = false; // TODO move imprinting-fail to upper note-info
                extractor.possibleIssues             = IssueNotes.Issue.None;
            }
            else
            {
                // highlight controls which most likely need to be checked to solve the issue
                if (issues.HasFlag(IssueNotes.Issue.WildTamedBred))
                {
                    panelWildTamedBred.BackColor = Color.LightSalmon;
                }
                if (issues.HasFlag(IssueNotes.Issue.TamingEffectivenessRange))
                {
                    if (numericUpDownLowerTEffBound.Value > 0)
                    {
                        numericUpDownLowerTEffBound.BackColor = Color.LightSalmon;
                    }
                    if (numericUpDownUpperTEffBound.Value < 100)
                    {
                        numericUpDownUpperTEffBound.BackColor = Color.LightSalmon;
                    }
                    if (numericUpDownLowerTEffBound.Value == 0 && numericUpDownUpperTEffBound.Value == 100)
                    {
                        issues -= IssueNotes.Issue.TamingEffectivenessRange;
                    }
                }
                if (issues.HasFlag(IssueNotes.Issue.CreatureLevel))
                {
                    numericUpDownLevel.BackColor = Color.LightSalmon;
                    numericUpDownImprintingBonusExtractor.BackColor = Color.LightSalmon;
                    statIOs[(int)StatNames.Torpidity].Status        = StatIOStatus.Error;
                }
                if (issues.HasFlag(IssueNotes.Issue.ImprintingLocked))
                {
                    cbExactlyImprinting.BackColor = Color.LightSalmon;
                }
                if (issues.HasFlag(IssueNotes.Issue.ImprintingNotPossible))
                {
                    numericUpDownImprintingBonusExtractor.BackColor = Color.LightSalmon;
                }

                // don't show some issue notes if the input is not wrong
                if (issues.HasFlag(IssueNotes.Issue.LockedDom))
                {
                    bool oneStatIsDomLocked = false;
                    for (int s = 0; s < Values.STATS_COUNT; s++)
                    {
                        if (statIOs[s].DomLevelLockedZero)
                        {
                            oneStatIsDomLocked = true;
                            break;
                        }
                    }
                    if (!oneStatIsDomLocked)
                    {
                        // no stat is domLocked, remove this note (which is ensured to be there)
                        issues -= IssueNotes.Issue.LockedDom;
                    }
                }

                if (!issues.HasFlag(IssueNotes.Issue.StatMultipliers))
                {
                    issues |= IssueNotes.Issue.StatMultipliers; // add this always?
                }
                if (rbTamedExtractor.Checked && creatureCollection.considerWildLevelSteps)
                {
                    issues |= IssueNotes.Issue.WildLevelSteps;
                }

                labelErrorHelp.Text = "The extraction failed. See the following list of possible causes:\n\n" +
                                      IssueNotes.getHelpTexts(issues);
                labelErrorHelp.Visible = true;
                llOnlineHelpExtractionIssues.Visible = true;
                groupBoxPossibilities.Visible        = false;
                groupBoxRadarChartExtractor.Visible  = false;
                lbInfoYellowStats.Visible            = false;
                if (rbBredExtractor.Checked && numericUpDownImprintingBonusExtractor.Value > 0)
                {
                    lbImprintingFailInfo.Text    = Loc.s("lbImprintingFailInfo");
                    lbImprintingFailInfo.Visible = true;
                }
                else if (rbTamedExtractor.Checked && "Procoptodon,Pulmonoscorpius,Troodon".Split(',').ToList().Contains(speciesSelector1.SelectedSpecies.name))
                {
                    // creatures that display wrong stat-values after taming
                    lbImprintingFailInfo.Text = $"The {speciesSelector1.SelectedSpecies.name} is known for displaying wrong stat-values after taming. " +
                                                "Please try the extraction again after the server restarted.";
                    lbImprintingFailInfo.Visible = true;
                }
                toolStripButtonSaveCreatureValuesTemp.Visible = true;

                // check for updates
                if (DateTime.Now.AddHours(-5) > Properties.Settings.Default.lastUpdateCheck)
                {
                    CheckForUpdates(true);
                }
            }
        }