Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Apr 30, 2023
2 parents f5ed110 + b1f795e commit 0fc7e9f
Show file tree
Hide file tree
Showing 18 changed files with 638 additions and 363 deletions.
3 changes: 0 additions & 3 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,6 @@
<setting name="AutoImportedExportFileRename" serializeAs="String">
<value>False</value>
</setting>
<setting name="BreedingPlannerConsiderOnlyEvenForHighStats" serializeAs="String">
<value>False</value>
</setting>
<setting name="AutoImportGotoLibraryAfterSuccess" serializeAs="String">
<value>False</value>
</setting>
Expand Down
41 changes: 20 additions & 21 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 17 additions & 20 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ public partial class BreedingPlan : UserControl
private List<BreedingPair> _breedingPairs;
private Species _currentSpecies;
/// <summary>
/// how much are the stats weighted when looking for the best
/// How much are the stats weighted when looking for the best
/// </summary>
private double[] _statWeights = new double[Stats.StatsCount];
/// <summary>
/// Indicates if high stats are only considered if any, odd or even.
/// </summary>
private byte[] _statOddEvens = new byte[Stats.StatsCount];
/// <summary>
/// The best possible levels of the selected species for each stat.
/// If the weighting is negative, a low level is considered better.
/// </summary>
Expand Down Expand Up @@ -65,8 +69,6 @@ public partial class BreedingPlan : UserControl
public CreatureCollection CreatureCollection;
private readonly ToolTip _tt = new ToolTip { AutoPopDelay = 10000 };



public BreedingPlan()
{
InitializeComponent();
Expand Down Expand Up @@ -105,7 +107,6 @@ public BreedingPlan()
cbBPOnlyOneSuggestionForFemales.Checked = Settings.Default.BreedingPlanOnlyBestSuggestionForEachFemale;
cbBPMutationLimitOnlyOnePartner.Checked = Settings.Default.BreedingPlanOnePartnerMoreMutationsThanLimit;
CbIgnoreSexInPlanning.Checked = Settings.Default.IgnoreSexInBreedingPlan;
CbConsiderOnlyEvenForHighStats.Checked = Settings.Default.BreedingPlannerConsiderOnlyEvenForHighStats;
CbDontSuggestOverLimitOffspring.Checked = Settings.Default.BreedingPlanDontSuggestOverLimitOffspring;

tagSelectorList1.OnTagChanged += TagSelectorList1_OnTagChanged;
Expand All @@ -117,18 +118,21 @@ public BreedingPlan()
private void StatWeighting_WeightingsChanged()
{
// check if sign of a weighting changed (then the best levels change)
bool signChanged = false;
bool signChangedOrOddEven = false;
var newWeightings = StatWeighting.Weightings;
var newOddEvens = StatWeighting.AnyOddEven;
for (int s = 0; s < Stats.StatsCount; s++)
{
if (Math.Sign(_statWeights[s]) != Math.Sign(newWeightings[s]))
if (_statOddEvens[s] != newOddEvens[s]
|| Math.Sign(_statWeights[s]) != Math.Sign(newWeightings[s]))
{
signChanged = true;
signChangedOrOddEven = true;
break;
}
}
_statWeights = newWeightings;
if (signChanged) DetermineBestLevels();
_statOddEvens = newOddEvens;
if (signChangedOrOddEven) DetermineBestLevels();

CalculateBreedingScoresAndDisplayPairs();
}
Expand Down Expand Up @@ -177,6 +181,7 @@ public void DetermineBestBreeding(Creature chosenCreature = null, bool forceUpda
}

_statWeights = StatWeighting.Weightings;
_statOddEvens = StatWeighting.AnyOddEven;

if (forceUpdate || BreedingPlanNeedsUpdate || _onlyShowingASubset)
{
Expand Down Expand Up @@ -394,7 +399,7 @@ private void DoCalculateBreedingScoresAndDisplayPairs()
bestPossLevels, _statWeights, _bestLevels, _breedingMode,
considerChosenCreature, considerMutationLimit, (int)nudBPMutationLimit.Value,
ref creaturesMutationsFilteredOut, levelLimitWithOutDomLevels, CbDontSuggestOverLimitOffspring.Checked,
cbBPOnlyOneSuggestionForFemales.Checked);
cbBPOnlyOneSuggestionForFemales.Checked, _statOddEvens);

//double minScore = _breedingPairs.LastOrDefault()?.BreedingScore ?? 0;
//if (minScore < 0)
Expand Down Expand Up @@ -773,7 +778,7 @@ private void DetermineBestLevels(List<Creature> creatures = null)
/// <param name="bestInSpecies">If true, the display of the best species library will be updated, if false the best filtered species will be updated.</param>
private void SetBestLevels(int[] bestLevels, IEnumerable<Creature> creatures, bool bestInSpecies)
{
BreedingScore.SetBestLevels(creatures, bestLevels, _statWeights, CbConsiderOnlyEvenForHighStats.Checked);
BreedingScore.SetBestLevels(creatures, bestLevels, _statWeights, _statOddEvens);

// display top levels in species
int? levelStep = CreatureCollection.getWildLevelStep();
Expand Down Expand Up @@ -839,7 +844,7 @@ private void SetParents(int comboIndex)
for (int s = 0; s < Stats.StatsCount; s++)
{
if (s == Stats.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.levelsWild[s] = _statWeights[s] < 0 ? Math.Min(mother.levelsWild[s], father.levelsWild[s]) : BreedingScore.GetHigherBestLevel(mother.levelsWild[s], father.levelsWild[s], _statOddEvens[s]);
crB.valuesBreeding[s] = StatValueCalculation.CalculateValue(_currentSpecies, s, crB.levelsWild[s], 0, true, 1, 0);
crB.topBreedingStats[s] = (_currentSpecies.stats[s].IncPerTamedLevel != 0 && 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]);
Expand Down Expand Up @@ -936,8 +941,7 @@ public void SetSpecies(Species species)

// automatically set preset if preset with the species name exists
_updateBreedingPlanAllowed = false;
if (!StatWeighting.TrySetPresetByName(species.name))
StatWeighting.TrySetPresetByName("Default");
StatWeighting.TrySetPresetBySpecies(species);
_updateBreedingPlanAllowed = true;

DetermineBestBreeding(setSpecies: species);
Expand Down Expand Up @@ -1179,13 +1183,6 @@ private void CbIgnoreSexInPlanning_CheckedChanged(object sender, EventArgs e)
CalculateBreedingScoresAndDisplayPairs();
}

private void CbConsiderOnlyEvenForHighStats_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.BreedingPlannerConsiderOnlyEvenForHighStats = CbConsiderOnlyEvenForHighStats.Checked;
CalculateBreedingScoresAndDisplayPairs();
DetermineBestLevels();
}

private void CbDontSuggestOverLimitOffspring_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.BreedingPlanDontSuggestOverLimitOffspring = CbDontSuggestOverLimitOffspring.Checked;
Expand Down
27 changes: 15 additions & 12 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.resx
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,21 @@
</resheader>
<data name="statWeighting1.CustomWeightings" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAPkBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XSxbU3lzdGVtLkRvdWJsZVtdLCBt
c2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3
N2E1YzU2MTkzNGUwODldXSwgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5DAMAAACaAW1zY29ybGliLCBWZXJzaW9uPTQu
MC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dLCBt
c2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3
N2E1YzU2MTkzNGUwODkFAQAAADZTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5EaWN0aW9uYXJ5YDJb
W1N5c3RlbS5TdHJpbmcDAAAAB1ZlcnNpb24IQ29tcGFyZX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