From 1c8603ff196e43243f8cb6fc0bda3dd17fbb87c6 Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 19 Sep 2023 18:47:08 +0200 Subject: [PATCH 1/2] fix when auto importing creature with non unique extracted levels --- ARKBreedingStats/Form1.extractor.cs | 70 ++++++++++++++++++++++++ ARKBreedingStats/Form1.importExported.cs | 8 +++ ARKBreedingStats/Form1.library.cs | 58 +------------------- 3 files changed, 80 insertions(+), 56 deletions(-) diff --git a/ARKBreedingStats/Form1.extractor.cs b/ARKBreedingStats/Form1.extractor.cs index e3a32368..b84cc534 100644 --- a/ARKBreedingStats/Form1.extractor.cs +++ b/ARKBreedingStats/Form1.extractor.cs @@ -1105,6 +1105,76 @@ private void SetCreatureValuesToExtractor(CreatureValues cv, bool setInfoInput = numericUpDownImprintingBonusExtractor.ValueSave = (decimal)cv.imprintingBonus * 100; } + /// + /// Creates a creature from the infos in inputs, extractor or tester. + /// + /// + /// + /// + /// Use this Ark Id instead of the ones of the input if not 0 + /// Use this Ark Id instead of the ones of the input if not 0 + /// + private Creature GetCreatureFromInput(bool fromExtractor, Species species, int? levelStep, long motherArkId = 0, long fatherArkId = 0) + { + CreatureInfoInput input; + bool bred; + double te, imprinting; + if (fromExtractor) + { + input = creatureInfoInputExtractor; + bred = rbBredExtractor.Checked; + te = rbWildExtractor.Checked ? -3 : _extractor.UniqueTamingEffectiveness(); + imprinting = _extractor.ImprintingBonus; + } + else + { + input = creatureInfoInputTester; + bred = rbBredTester.Checked; + te = TamingEffectivenessTester; + imprinting = (double)numericUpDownImprintingBonusTester.Value / 100; + } + + Creature creature = new Creature(species, input.CreatureName, input.CreatureOwner, input.CreatureTribe, input.CreatureSex, GetCurrentWildLevels(fromExtractor), GetCurrentDomLevels(fromExtractor), te, bred, imprinting, levelStep: levelStep) + { + // set parents + Mother = input.Mother, + Father = input.Father, + + // cooldown-, growing-time + cooldownUntil = input.CooldownUntil, + growingUntil = input.GrowingUntil, + + flags = input.CreatureFlags, + note = input.CreatureNote, + server = input.CreatureServer, + + domesticatedAt = input.DomesticatedAt.HasValue && input.DomesticatedAt.Value.Year > 2014 ? input.DomesticatedAt.Value : default(DateTime?), + addedToLibrary = DateTime.Now, + mutationsMaternal = input.MutationCounterMother, + mutationsPaternal = input.MutationCounterFather, + Status = input.CreatureStatus, + colors = input.RegionColors, + ColorIdsAlsoPossible = input.ColorIdsAlsoPossible, + guid = fromExtractor && input.CreatureGuid != Guid.Empty ? input.CreatureGuid : Guid.NewGuid(), + ArkId = input.ArkId + }; + + creature.ArkIdImported = Utils.IsArkIdImported(creature.ArkId, creature.guid); + creature.InitializeArkInGame(); + + // parent guids + if (motherArkId != 0) + creature.motherGuid = Utils.ConvertArkIdToGuid(motherArkId); + else if (input.MotherArkId != 0) + creature.motherGuid = Utils.ConvertArkIdToGuid(input.MotherArkId); + if (fatherArkId != 0) + creature.fatherGuid = Utils.ConvertArkIdToGuid(fatherArkId); + else if (input.FatherArkId != 0) + creature.fatherGuid = Utils.ConvertArkIdToGuid(input.FatherArkId); + + return creature; + } + /// /// Gives feedback to the user if the current creature in the extractor is already in the library. /// This uses the ARK-ID and only works if exported creatures are imported diff --git a/ARKBreedingStats/Form1.importExported.cs b/ARKBreedingStats/Form1.importExported.cs index 09d9ee45..ea63f8c1 100644 --- a/ARKBreedingStats/Form1.importExported.cs +++ b/ARKBreedingStats/Form1.importExported.cs @@ -234,6 +234,14 @@ private void ImportExportedAddIfPossible(string filePath) default: return; } + if (creature == null) + { + // extraction did not work automatically, user input needed, create creature file for error message + var levelStep = _creatureCollection.getWildLevelStep(); + var species = speciesSelector1.SelectedSpecies; + creature = GetCreatureFromInput(true, species, levelStep); + } + OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExists, addedToLibrary, copiedNameToClipboard, out bool hasTopLevels, out bool hasNewTopLevels); if (addedToLibrary) diff --git a/ARKBreedingStats/Form1.library.cs b/ARKBreedingStats/Form1.library.cs index 6c48f4b0..e97f8a4a 100644 --- a/ARKBreedingStats/Form1.library.cs +++ b/ARKBreedingStats/Form1.library.cs @@ -36,63 +36,9 @@ public partial class Form1 /// go to library tab after the creature is added private Creature AddCreatureToCollection(bool fromExtractor = true, long motherArkId = 0, long fatherArkId = 0, bool goToLibraryTab = true) { - CreatureInfoInput input; - bool bred; - double te, imprinting; - Species species = speciesSelector1.SelectedSpecies; - if (fromExtractor) - { - input = creatureInfoInputExtractor; - bred = rbBredExtractor.Checked; - te = rbWildExtractor.Checked ? -3 : _extractor.UniqueTamingEffectiveness(); - imprinting = _extractor.ImprintingBonus; - } - else - { - input = creatureInfoInputTester; - bred = rbBredTester.Checked; - te = TamingEffectivenessTester; - imprinting = (double)numericUpDownImprintingBonusTester.Value / 100; - } - var levelStep = _creatureCollection.getWildLevelStep(); - Creature creature = new Creature(species, input.CreatureName, input.CreatureOwner, input.CreatureTribe, input.CreatureSex, GetCurrentWildLevels(fromExtractor), GetCurrentDomLevels(fromExtractor), te, bred, imprinting, levelStep: levelStep) - { - // set parents - Mother = input.Mother, - Father = input.Father, - - // cooldown-, growing-time - cooldownUntil = input.CooldownUntil, - growingUntil = input.GrowingUntil, - - flags = input.CreatureFlags, - note = input.CreatureNote, - server = input.CreatureServer, - - domesticatedAt = input.DomesticatedAt.HasValue && input.DomesticatedAt.Value.Year > 2014 ? input.DomesticatedAt.Value : default(DateTime?), - addedToLibrary = DateTime.Now, - mutationsMaternal = input.MutationCounterMother, - mutationsPaternal = input.MutationCounterFather, - Status = input.CreatureStatus, - colors = input.RegionColors, - ColorIdsAlsoPossible = input.ColorIdsAlsoPossible, - guid = fromExtractor && input.CreatureGuid != Guid.Empty ? input.CreatureGuid : Guid.NewGuid(), - ArkId = input.ArkId - }; - - creature.ArkIdImported = Utils.IsArkIdImported(creature.ArkId, creature.guid); - creature.InitializeArkInGame(); - - // parent guids - if (motherArkId != 0) - creature.motherGuid = Utils.ConvertArkIdToGuid(motherArkId); - else if (input.MotherArkId != 0) - creature.motherGuid = Utils.ConvertArkIdToGuid(input.MotherArkId); - if (fatherArkId != 0) - creature.fatherGuid = Utils.ConvertArkIdToGuid(fatherArkId); - else if (input.FatherArkId != 0) - creature.fatherGuid = Utils.ConvertArkIdToGuid(input.FatherArkId); + var species = speciesSelector1.SelectedSpecies; + var creature = GetCreatureFromInput(fromExtractor, species, levelStep, motherArkId, fatherArkId); // if creature is placeholder: add it // if creature's ArkId is already in library, suggest updating of the creature From 769ce2fa3bf08d2a59df6393a49abb5e92e228f1 Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 19 Sep 2023 18:49:15 +0200 Subject: [PATCH 2/2] ver --- ARKBreedingStats/Properties/AssemblyInfo.cs | 2 +- ARKBreedingStats/_manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index 8a380389..9e9af66b 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // Revision // [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.56.1.0")] +[assembly: AssemblyFileVersion("0.56.2.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index d2eb766f..5e9db163 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.56.1.0" + "version": "0.56.2.0" }, "SpeciesColorImages": { "Id": "SpeciesColorImages",