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 4, 2024
2 parents bd979b3 + 986609f commit a82c13c
Show file tree
Hide file tree
Showing 13 changed files with 1,453 additions and 829 deletions.
1 change: 1 addition & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@
</EmbeddedResource>
<EmbeddedResource Include="BreedingPlanning\BreedingPlan.resx">
<DependentUpon>BreedingPlan.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CreatureBox.resx">
<DependentUpon>CreatureBox.cs</DependentUpon>
Expand Down
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@
<setting name="LibraryDisplayZeroMutationLevels" serializeAs="String">
<value>False</value>
</setting>
<setting name="CustomStatWeightsOddEven" serializeAs="String">
<value />
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
28 changes: 14 additions & 14 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.Designer.cs

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

3 changes: 2 additions & 1 deletion ARKBreedingStats/BreedingPlanning/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using ARKBreedingStats.uiControls;
using ARKBreedingStats.utils;
using ARKBreedingStats.values;
using static ARKBreedingStats.uiControls.StatWeighting;

namespace ARKBreedingStats.BreedingPlanning
{
Expand All @@ -36,7 +37,7 @@ public partial class BreedingPlan : UserControl
/// <summary>
/// Indicates if high stats are only considered if any, odd or even.
/// </summary>
private byte[] _statOddEvens = new byte[Stats.StatsCount];
private StatValueEvenOdd[] _statOddEvens = new StatValueEvenOdd[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.
Expand Down
21 changes: 11 additions & 10 deletions ARKBreedingStats/BreedingPlanning/BreedingScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using ARKBreedingStats.Library;
using ARKBreedingStats.species;
using static ARKBreedingStats.uiControls.StatWeighting;

namespace ARKBreedingStats.BreedingPlanning
{
Expand Down Expand Up @@ -34,7 +35,7 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
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, byte[] anyOddEven = null)
bool onlyBestSuggestionForFemale = false, StatValueEvenOdd[] anyOddEven = null)
{
var breedingPairs = new List<BreedingPair>();
var ignoreSex = Properties.Settings.Default.IgnoreSexInBreedingPlan || species.noGender;
Expand Down Expand Up @@ -99,10 +100,10 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
// 0: consider all levels, 1: consider only odd levels, 2: consider only even levels
switch (anyOddEven[s])
{
case 1:
case StatValueEvenOdd.Odd:
ignoreTopStats = higherLevel % 2 == 0;
break;
case 2:
case StatValueEvenOdd.Even:
ignoreTopStats = higherLevel % 2 != 0;
break;
}
Expand Down Expand Up @@ -230,7 +231,7 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
/// <summary>
/// Sets the best levels in the passed bestLevels array, depending on the statWeights and onlyHighEvenLevels.
/// </summary>
public static void SetBestLevels(IEnumerable<Creature> creatures, int[] bestLevels, double[] statWeights, byte[] anyOddEven = null)
public static void SetBestLevels(IEnumerable<Creature> creatures, int[] bestLevels, double[] statWeights, StatValueEvenOdd[] anyOddEven = null)
{
for (int s = 0; s < Stats.StatsCount; s++)
bestLevels[s] = -1;
Expand All @@ -241,9 +242,9 @@ public static void SetBestLevels(IEnumerable<Creature> creatures, int[] bestLeve
{
if ((s == Stats.Torpidity || statWeights[s] >= 0) && c.levelsWild[s] > bestLevels[s])
{
if ((anyOddEven?[s] ?? 0) == 0
|| (anyOddEven[s] == 1 && c.levelsWild[s] % 2 == 1)
|| (anyOddEven[s] == 2 && c.levelsWild[s] % 2 == 0)
if ((anyOddEven?[s] ?? StatValueEvenOdd.Indifferent) == StatValueEvenOdd.Indifferent
|| (anyOddEven[s] == StatValueEvenOdd.Odd && c.levelsWild[s] % 2 == 1)
|| (anyOddEven[s] == StatValueEvenOdd.Even && c.levelsWild[s] % 2 == 0)
)
bestLevels[s] = c.levelsWild[s];
}
Expand All @@ -257,16 +258,16 @@ public static void SetBestLevels(IEnumerable<Creature> creatures, int[] bestLeve
/// Returns better of two given levels. If anyOddEven == 0: higher of both, if == 1: higher of odd levels, if == 2: higher of even levels.
/// If both levels don't match odd/even, -1 is returned.
/// </summary>
public static int GetHigherBestLevel(int level1, int level2, byte anyOddEven)
public static int GetHigherBestLevel(int level1, int level2, StatValueEvenOdd anyOddEven)
{
switch (anyOddEven)
{
case 1:
case StatValueEvenOdd.Odd:
if (level1 % 2 == 1 && level2 % 2 == 1) return Math.Max(level1, level2);
if (level1 % 2 == 1) return level1;
if (level2 % 2 == 1) return level2;
return -1;
case 2:
case StatValueEvenOdd.Even:
if (level1 % 2 == 0 && level2 % 2 == 0) return Math.Max(level1, level2);
if (level1 % 2 == 0) return level1;
if (level2 % 2 == 0) return level2;
Expand Down
32 changes: 25 additions & 7 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using static ARKBreedingStats.settings.Settings;
using Color = System.Drawing.Color;
using ARKBreedingStats.AsbServer;
using static ARKBreedingStats.uiControls.StatWeighting;

namespace ARKBreedingStats
{
Expand Down Expand Up @@ -292,14 +293,31 @@ private void Form1_Load(object sender, EventArgs e)

// load stat weights
double[][] custWd = Properties.Settings.Default.customStatWeights;
var customStatWeightsOddEven = Properties.Settings.Default.CustomStatWeightsOddEven;

// backwards compatibility
var customStatWeightOddEven = Properties.Settings.Default.CustomStatWeightOddEven;
if (customStatWeightOddEven != null)
{
customStatWeightsOddEven = new StatValueEvenOdd[customStatWeightOddEven.Length][];
for (var i = 0; i < customStatWeightOddEven.Length; i++)
{
customStatWeightsOddEven[i] = customStatWeightOddEven[i].Select(w =>
w == 1 ? StatValueEvenOdd.Odd :
w == 2 ? StatValueEvenOdd.Even : StatValueEvenOdd.Indifferent)
.ToArray();
}
customStatWeightOddEven = null;
Properties.Settings.Default.CustomStatWeightOddEven = null;
}

string[] custWs = Properties.Settings.Default.customStatWeightNames;
var custW = new Dictionary<string, (double[], byte[])>();
var custW = new Dictionary<string, (double[], StatValueEvenOdd[])>();
if (custWs != null && custWd != null)
{
for (int i = 0; i < custWs.Length && i < custWd.Length && i < customStatWeightOddEven.Length; i++)
for (int i = 0; i < custWs.Length && i < custWd.Length && i < customStatWeightsOddEven.Length; i++)
{
custW.Add(custWs[i], (custWd[i], customStatWeightOddEven[i]));
custW.Add(custWs[i], (custWd[i], customStatWeightsOddEven[i]));
}
}

Expand All @@ -308,7 +326,7 @@ private void Form1_Load(object sender, EventArgs e)
if (custWs != null && custWd != null && custWd.Length > custWs.Length)
breedingPlan1.StatWeighting.WeightValues = custWd[custWs.Length];
if (custWs != null && customStatWeightOddEven != null && customStatWeightOddEven.Length > custWs.Length)
breedingPlan1.StatWeighting.AnyOddEven = customStatWeightOddEven[custWs.Length];
breedingPlan1.StatWeighting.AnyOddEven = customStatWeightsOddEven[custWs.Length];

// load weapon damages
tamingControl1.WeaponDamages = Properties.Settings.Default.weaponDamages;
Expand Down Expand Up @@ -1308,8 +1326,8 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e)
// save custom statWeights
var custWs = new List<string>();
var custWd = new List<double[]>();
var custOddEven = new List<byte[]>();
foreach (KeyValuePair<string, (double[], byte[])> w in breedingPlan1.StatWeighting.CustomWeightings)
var custOddEven = new List<StatValueEvenOdd[]>();
foreach (KeyValuePair<string, (double[], StatValueEvenOdd[])> w in breedingPlan1.StatWeighting.CustomWeightings)
{
custWs.Add(w.Key);
custWd.Add(w.Value.Item1);
Expand All @@ -1322,7 +1340,7 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e)

Properties.Settings.Default.customStatWeightNames = custWs.ToArray();
Properties.Settings.Default.customStatWeights = custWd.ToArray();
Properties.Settings.Default.CustomStatWeightOddEven = custOddEven.ToArray();
Properties.Settings.Default.CustomStatWeightsOddEven = custOddEven.ToArray();

// save weaponDamages for KO calculation
Properties.Settings.Default.weaponDamages = tamingControl1.WeaponDamages;
Expand Down
8 changes: 4 additions & 4 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private void CalculateTopStats(List<Creature> creatures)
var statPreferences = new StatWeighting.StatValuePreference[Stats.StatsCount];
for (int s = 0; s < Stats.StatsCount; s++)
{
var statWeight = statWeights.Item1[s];
var statWeight = statWeights.Item1?[s] ?? 1;
statPreferences[s] = statWeight > 0 ? StatWeighting.StatValuePreference.High :
statWeight < 0 ? StatWeighting.StatValuePreference.Low :
StatWeighting.StatValuePreference.Indifferent;
Expand Down Expand Up @@ -374,9 +374,9 @@ private void CalculateTopStats(List<Creature> creatures)
{
// creature has a higher level than the current highest level
// check if highest stats are only counted if odd or even
if ((statWeights.Item2?[s] ?? 0) == 0 // even/odd doesn't matter
|| (statWeights.Item2[s] == 1 && c.levelsWild[s] % 2 == 1)
|| (statWeights.Item2[s] == 2 && c.levelsWild[s] % 2 == 0)
if ((statWeights.Item2?[s] ?? StatWeighting.StatValueEvenOdd.Indifferent) == StatWeighting.StatValueEvenOdd.Indifferent // even/odd doesn't matter
|| (statWeights.Item2[s] == StatWeighting.StatValueEvenOdd.Odd && c.levelsWild[s] % 2 == 1)
|| (statWeights.Item2[s] == StatWeighting.StatValueEvenOdd.Even && c.levelsWild[s] % 2 == 0)
)
{
bestCreaturesWildLevels[s] = new List<Creature> { c };
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.60.0.0")]
[assembly: AssemblyFileVersion("0.60.0.1")]
[assembly: NeutralResourcesLanguage("en")]

Loading

0 comments on commit a82c13c

Please sign in to comment.