Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Feb 18, 2024
2 parents a82c13c + 0629dd0 commit baa0f7b
Show file tree
Hide file tree
Showing 52 changed files with 2,269 additions and 1,933 deletions.
27 changes: 21 additions & 6 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@
<Compile Include="Pedigree\PedigreeCreation.cs" />
<Compile Include="Pedigree\IPedigreeCreature.cs" />
<Compile Include="species\ArkColors.cs" />
<Compile Include="uiControls\ArkVersionDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="uiControls\ColorPickerWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="uiControls\ColorPickerWindow.Designer.cs">
<DependentUpon>ColorPickerWindow.cs</DependentUpon>
</Compile>
<Compile Include="uiControls\CreatureAnalysis.cs">
<SubType>UserControl</SubType>
</Compile>
Expand All @@ -132,6 +141,9 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="uiControls\LibraryInfo.cs" />
<Compile Include="uiControls\LibraryInfoControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="uiControls\PopupMessage.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -518,11 +530,11 @@
<Compile Include="uiControls\MultiSetter.Designer.cs">
<DependentUpon>MultiSetter.cs</DependentUpon>
</Compile>
<Compile Include="uiControls\MyColorPicker.cs">
<SubType>Form</SubType>
<Compile Include="uiControls\ColorPickerControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="uiControls\MyColorPicker.Designer.cs">
<DependentUpon>MyColorPicker.cs</DependentUpon>
<Compile Include="uiControls\ColorPickerControl.Designer.cs">
<DependentUpon>ColorPickerControl.cs</DependentUpon>
</Compile>
<Compile Include="uiControls\ParentComboBox.cs">
<SubType>Component</SubType>
Expand Down Expand Up @@ -702,6 +714,9 @@
<EmbeddedResource Include="ocr\PatternMatching\RecognitionTrainingForm.resx">
<DependentUpon>RecognitionTrainingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="uiControls\ColorPickerWindow.resx">
<DependentUpon>ColorPickerWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="uiControls\CreatureAnalysis.resx">
<DependentUpon>CreatureAnalysis.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -928,8 +943,8 @@
<EmbeddedResource Include="uiControls\MultiSetter.resx">
<DependentUpon>MultiSetter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="uiControls\MyColorPicker.resx">
<DependentUpon>MyColorPicker.cs</DependentUpon>
<EmbeddedResource Include="uiControls\ColorPickerControl.resx">
<DependentUpon>ColorPickerControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pedigree\PedigreeControl.resx">
<DependentUpon>PedigreeControl.cs</DependentUpon>
Expand Down
10 changes: 5 additions & 5 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,6 @@
<setting name="AskSaveSettingsOnClose" serializeAs="String">
<value>True</value>
</setting>
<setting name="KeepMultipliersForNewLibrary" serializeAs="String">
<value>True</value>
</setting>
<setting name="ExportServerToken" serializeAs="String">
<value />
</setting>
Expand All @@ -517,8 +514,11 @@
<setting name="LibraryDisplayZeroMutationLevels" serializeAs="String">
<value>False</value>
</setting>
<setting name="CustomStatWeightsOddEven" serializeAs="String">
<value />
<setting name="KeepMultipliersForNewLibrary" serializeAs="String">
<value>True</value>
</setting>
<setting name="DisplayPopupForServerToken" serializeAs="String">
<value>True</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
Expand Down
21 changes: 16 additions & 5 deletions ARKBreedingStats/Ark.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace ARKBreedingStats
using ARKBreedingStats.values;

namespace ARKBreedingStats
{
/// <summary>
/// Constants of the game Ark.
Expand Down Expand Up @@ -103,14 +105,18 @@ public static class Ark
public const byte UndefinedColorIdAsa = 255;

/// <summary>
/// When choosing a random color for a mutation, ARK can erroneously select an undefined color. Usually this is color id 227 (one too high to be defined).
/// When choosing a random color for a mutation, ARK can erroneously select an undefined color. 227 for ASE, 255 for ASA.
/// </summary>
public static byte UndefinedColorId = UndefinedColorIdAse;

/// <summary>
/// Sets the undefined color id to the one of ASE or ASA.
/// </summary>
public static void SetUndefinedColorId(bool asa) => UndefinedColorId = asa ? UndefinedColorIdAsa : UndefinedColorIdAse;
public static void SetUndefinedColorId(bool asa)
{
UndefinedColorId = asa ? UndefinedColorIdAsa : UndefinedColorIdAse;
Values.V.Colors.SetUndefinedColorId(UndefinedColorId);
}

/// <summary>
/// Number of possible color regions for all species.
Expand All @@ -126,14 +132,19 @@ public static class Ark

public enum Game
{
Unknown,
/// <summary>
/// ARK: Survival Evolved (2015)
/// </summary>
ASE,
Ase,
/// <summary>
/// ARK: Survival Ascended (2023)
/// </summary>
ASA
Asa,
/// <summary>
/// Use the same version that was already loaded
/// </summary>
SameAsBefore
}

/// <summary>
Expand Down
11 changes: 6 additions & 5 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,17 @@ public void DetermineBestBreeding(Creature chosenCreature = null, bool forceUpda
}
else
{
var includeWithCooldown = cbBPIncludeCooldowneds.Checked;
var ignoreBreedingCooldown = _currentSpecies?.noGender == true; // for hermaphrodites only one partner needs to be not on cooldown
Creatures = CreatureCollection.creatures
.Where(c => c.speciesBlueprint == _currentSpecies.blueprintPath
&& !c.flags.HasFlag(CreatureFlags.Neutered)
&& !c.flags.HasFlag(CreatureFlags.Placeholder)
&& (c.Status == CreatureStatus.Available
|| (c.Status == CreatureStatus.Cryopod && cbBPIncludeCryoCreatures.Checked))
&& (cbBPIncludeCooldowneds.Checked
|| !(c.cooldownUntil > DateTime.Now
|| c.growingUntil > DateTime.Now
)
&& (includeWithCooldown
|| !(c.growingUntil > DateTime.Now
|| (!ignoreBreedingCooldown && c.cooldownUntil > DateTime.Now))
)
)
.ToList();
Expand Down Expand Up @@ -414,7 +415,7 @@ private void DoCalculateBreedingScoresAndDisplayPairs()
bestPossLevels, _statWeights, _bestLevels, _breedingMode,
considerChosenCreature, considerMutationLimit, (int)nudBPMutationLimit.Value,
ref creaturesMutationsFilteredOut, levelLimitWithOutDomLevels, CbDontSuggestOverLimitOffspring.Checked,
cbBPOnlyOneSuggestionForFemales.Checked, _statOddEvens);
cbBPOnlyOneSuggestionForFemales.Checked, _statOddEvens, !cbBPIncludeCooldowneds.Checked && _currentSpecies.noGender);

double minScore = _breedingPairs.LastOrDefault()?.BreedingScore.OneNumber ?? 0;
var displayScoreOffset = (minScore < 0 ? -minScore : 0) + .5; // don't display negative scores, could be confusing
Expand Down
14 changes: 13 additions & 1 deletion ARKBreedingStats/BreedingPlanning/BreedingScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public static class BreedingScore
/// <param name="downGradeOffspringWithLevelHigherThanLimit">Downgrade score if level is higher than limit.</param>
/// <param name="onlyBestSuggestionForFemale">Only the pairing with the highest score is kept for each female. Is not used if species has no sex or sex is ignored in breeding planner.</param>
/// <param name="anyOddEven">Array for each stat if the higher level should be considered for score: 0: consider any level, 1: consider only if odd, 2: consider only if even.</param>
/// <param name="checkIfAtLeastOnePartnerIsNotOnCooldown">For hermaphrodites only one partner needs to be not on cooldown. If creatures of a hermaphrodite species are passed and at least one needs to be not on cooldown, set this to true.</param>
/// <returns></returns>
public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Creature[] males, Species species,
short[] bestPossLevels, double[] statWeights, int[] bestLevelsOfSpecies, BreedingMode breedingMode,
bool considerChosenCreature, bool considerMutationLimit, int mutationLimit,
ref bool creaturesMutationsFilteredOut, int offspringLevelLimit = 0, bool downGradeOffspringWithLevelHigherThanLimit = false,
bool onlyBestSuggestionForFemale = false, StatValueEvenOdd[] anyOddEven = null)
bool onlyBestSuggestionForFemale = false, StatValueEvenOdd[] anyOddEven = null, bool checkIfAtLeastOnePartnerIsNotOnCooldown = false)
{
var breedingPairs = new List<BreedingPair>();
var ignoreSex = Properties.Settings.Default.IgnoreSexInBreedingPlan || species.noGender;
Expand All @@ -48,6 +49,8 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
customIgnoreTopStatsEvenOdd[s] = anyOddEven != null && statWeights[s] > 0;
}

var now = DateTime.Now;

for (int fi = 0; fi < females.Length; fi++)
{
var female = females[fi];
Expand All @@ -73,6 +76,15 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
continue;
}

// if species is hermaphrodite, only one partner needs to be not on cooldown
if (checkIfAtLeastOnePartnerIsNotOnCooldown
&& female.cooldownUntil > now
&& male.cooldownUntil > now
)
{
continue;
}

double t = 0;
int offspringPotentialTopStatCount = 0;
double offspringExpectedTopStatCount = 0; // a guaranteed top stat counts 1, otherwise the inheritance probability of the top stat is counted
Expand Down
3 changes: 2 additions & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public bool TribeLock
}

/// <summary>
/// If set to true, it's assumed the creature is already existing.
/// If not null it's assumed the creature is already existing in the library.
/// </summary>
public Creature AlreadyExistingCreature
{
Expand All @@ -709,6 +709,7 @@ public Creature AlreadyExistingCreature
_alreadyExistingCreature = value;
SetAdd2LibColor(btAdd2Library.Enabled);
}
get => _alreadyExistingCreature;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static bool LoadJsonFile<T>(string filePath, out T data, out string error
if (data != null)
return true;

errorMessage = $"File\n{Path.GetFullPath(filePath)}\n contains no readable data.";
errorMessage = $"File\n{Path.GetFullPath(filePath)}\ncontains no readable data.";
return false;
}
}
Expand Down
Loading

0 comments on commit baa0f7b

Please sign in to comment.