Skip to content

Commit

Permalink
changed .Count>0 to .Any().
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed Mar 17, 2020
1 parent eed547f commit 69e75ee
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/ARKOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public bool enableOverlayTimer

private void TimerUpdateTimer_Tick(object sender, EventArgs e)
{
if (timers.Count > 0)
if (timers.Any())
SetTimerText();

// info
Expand Down
12 changes: 6 additions & 6 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ private List<Creature> FilterByTags(List<Creature> cl)

List<Creature> filteredList = new List<Creature>();

if (excludingTagList.Count > 0 || cbBPTagExcludeDefault.Checked)
if (excludingTagList.Any() || cbBPTagExcludeDefault.Checked)
{
foreach (Creature c in cl)
{
bool exclude = cbBPTagExcludeDefault.Checked;
if (!exclude && excludingTagList.Count > 0)
if (!exclude && excludingTagList.Any())
{
foreach (string t in c.tags)
{
Expand All @@ -183,7 +183,7 @@ private List<Creature> FilterByTags(List<Creature> cl)
}
}
}
if (exclude && includingTagList.Count > 0)
if (exclude && includingTagList.Any())
{
foreach (string t in c.tags)
{
Expand Down Expand Up @@ -314,7 +314,7 @@ private void CalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMode, b
chosenM = new List<Creature>(combinedCreatures);
}

if (chosenF.Count > 0 && chosenM.Count > 0)
if (chosenF.Any() && chosenM.Any())
{
pedigreeCreature1.Show();
pedigreeCreature2.Show();
Expand Down Expand Up @@ -433,7 +433,7 @@ private void CalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMode, b
}

breedingPairs = breedingPairs.OrderByDescending(p => p.BreedingScore).ToList();
double minScore = (breedingPairs.Count > 0 ? breedingPairs[breedingPairs.Count - 1].BreedingScore : 0);
double minScore = (breedingPairs.Any() ? breedingPairs[breedingPairs.Count - 1].BreedingScore : 0);
if (minScore < 0)
{
foreach (BreedingPair bp in breedingPairs)
Expand Down Expand Up @@ -535,7 +535,7 @@ private void CalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMode, b

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

Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public bool EveryStatHasAtLeastOneResult
public double UniqueTE()
{
double eff = -2;
if (statsWithTE.Count > 0 && results[statsWithTE[0]].Count > chosenResults[statsWithTE[0]])
if (statsWithTE.Any() && results[statsWithTE[0]].Count > chosenResults[statsWithTE[0]])
{
for (int s = 0; s < statsWithTE.Count; s++)
{
Expand Down
10 changes: 5 additions & 5 deletions ARKBreedingStats/Form1.Designer.cs

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

4 changes: 2 additions & 2 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void NewCollection()
"Discard Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
return;

if (creatureCollection.modIDs?.Count > 0)
if (creatureCollection.modIDs?.Any() ?? false)
{
// if old collection had additionalValues, load the original ones to reset all modded values
var (statValuesLoaded, _) = LoadStatAndKibbleValues(applySettings: false);
Expand Down Expand Up @@ -416,7 +416,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
// calculate creature values
RecalculateAllCreaturesValues();

if (!keepCurrentSelections && creatureCollection.creatures.Count > 0)
if (!keepCurrentSelections && creatureCollection.creatures.Any())
tabControlMain.SelectedTab = tabPageLibrary;

creatureBoxListView.maxDomLevel = creatureCollection.maxDomLevel;
Expand Down
10 changes: 5 additions & 5 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void Form1_Load(object sender, EventArgs e)
{
speciesSelector1.SetSpecies(Values.V.SpeciesByBlueprint(Properties.Settings.Default.lastSpecies[0]));
}
if (speciesSelector1.SelectedSpecies == null && Values.V.species.Count > 0)
if (speciesSelector1.SelectedSpecies == null && Values.V.species.Any())
speciesSelector1.SetSpecies(Values.V.species[0]);
tamingControl1.SetSpecies(speciesSelector1.SelectedSpecies);

Expand Down Expand Up @@ -469,7 +469,7 @@ private void TellTamingData(string speciesName, int level)
speciesSelector1.SetSpeciesByName(speciesName);
if (speciesSelector1.SelectedSpecies != null && speciesSelector1.SelectedSpecies.taming != null &&
speciesSelector1.SelectedSpecies.taming.eats != null &&
speciesSelector1.SelectedSpecies.taming.eats.Count > 0)
speciesSelector1.SelectedSpecies.taming.eats.Any())
{
tamingControl1.SetLevel(level, false);
tamingControl1.SetSpecies(speciesSelector1.SelectedSpecies);
Expand Down Expand Up @@ -964,7 +964,7 @@ private void CreateOwnerList()
{
if (c.tags.Count == 0)
removeWOTag = false;
else if (c.tags.Count > 0)
else if (c.tags.Any())
{
for (int t = 0; t < c.tags.Count; t++)
{
Expand Down Expand Up @@ -1970,7 +1970,7 @@ private void SetStatusOfSelected(CreatureStatus s)
List<Creature> cs = new List<Creature>();
foreach (ListViewItem i in listViewLibrary.SelectedItems)
cs.Add((Creature)i.Tag);
if (cs.Count > 0)
if (cs.Any())
SetStatus(cs, s);
}

Expand Down Expand Up @@ -3034,7 +3034,7 @@ private void LoadMultipliersFromTestCase(testCases.ExtractionTestCase etc)
if (Values.V.loadedModsHash == 0 || Values.V.loadedModsHash != etc.modListHash)
LoadStatAndKibbleValues(false); // load original multipliers if they were changed

if (etc.ModIDs.Count > 0)
if (etc.ModIDs.Any())
LoadModValueFiles(Values.V.modsManifest.modsByFiles.Where(mi => etc.ModIDs.Contains(mi.Value.mod.id)).Select(mi => mi.Value.mod.FileName).ToList(),
false, false, out _);

Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPreci
{
statIOs[s].Status = StatIOStatus.Neutral;
}
else if (extractor.results[s].Count > 0)
else if (extractor.results[s].Any())
{
if (existingCreature != null)
{
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.importSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private async void RunSavegameImport(object sender, EventArgs e)
SetCollectionChanged(true);
UpdateCreatureListings();

if (creatureCollection.creatures.Count > 0)
if (creatureCollection.creatures.Any())
tabControlMain.SelectedTab = tabPageLibrary;

// reapply last sorting
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/Form1.values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static bool CheckAvailabilityAndUpdateModFiles(List<string> modValueFile

bool filesDownloaded = false;

if (modValueFilesWithAvailableUpdate.Count > 0
if (modValueFilesWithAvailableUpdate.Any()
&& MessageBox.Show("For " + modValueFilesWithAvailableUpdate.Count.ToString() + " value files there is an update available. It is strongly recommended to use the updated versions.\n"
+ "The updated files can be downloaded automatically if you want.\n"
+ "The following files can be downloaded\n\n- "
Expand All @@ -107,7 +107,7 @@ private static bool CheckAvailabilityAndUpdateModFiles(List<string> modValueFile
filesDownloaded |= values.modsManifest.DownloadModFiles(modValueFilesWithAvailableUpdate);
}

if (missingModValueFilesOnlineAvailable.Count > 0
if (missingModValueFilesOnlineAvailable.Any()
&& MessageBox.Show(missingModValueFilesOnlineAvailable.Count.ToString() + " mod-value files are not available locally. Without these files the library will not display all creatures.\n"
+ "The missing files can be downloaded automatically if you want.\n"
+ "The following files can be downloaded\n\n- "
Expand All @@ -119,7 +119,7 @@ private static bool CheckAvailabilityAndUpdateModFiles(List<string> modValueFile
filesDownloaded |= values.modsManifest.DownloadModFiles(missingModValueFilesOnlineAvailable);
}

if (missingModValueFilesOnlineNotAvailable.Count > 0)
if (missingModValueFilesOnlineNotAvailable.Any())
{
MessageBox.Show(missingModValueFilesOnlineNotAvailable.Count.ToString() + " mod-value files are neither available locally nor online. The creatures of the missing mod will not be displayed.\n"
+ "The following files are missing\n\n- "
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Pedigree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void drawLines(Graphics g)
{
g.DrawLine(myPen, line[0], line[1], line[2], line[3]);
}
if (children.Count > 0)
if (children.Any())
g.DrawString("Descendants", new Font("Arial", 14), new SolidBrush(Color.Black), 210, 170);
}
}
Expand Down
3 changes: 2 additions & 1 deletion ARKBreedingStats/Taming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ARKBreedingStats.values;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ARKBreedingStats
{
Expand Down Expand Up @@ -325,7 +326,7 @@ public static string BoneDamageAdjustersImmobilization(Species species, out Dict
text += (text.Length > 0 ? "\n" : string.Empty) + bd.Key + ": × " + bd.Value.ToString();
}
}
if (species.immobilizedBy != null && species.immobilizedBy.Count > 0)
if (species.immobilizedBy != null && species.immobilizedBy.Any())
text += $"{(text.Length > 0 ? "\n" : string.Empty)}{Loc.s("ImmobilizedBy")}: " +
$"{string.Join(", ", species.immobilizedBy)}";
}
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/TimerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private ListViewItem CreateLvi(string name, DateTime finishTime, TimerListEntry

public void Tick()
{
if (timerListEntries != null && timerListEntries.Count > 0)
if (timerListEntries != null && timerListEntries.Any())
{
listViewTimer.BeginUpdate();
DateTime now = DateTime.Now;
Expand Down Expand Up @@ -239,7 +239,7 @@ public string TimerAlertsCSV
if (int.TryParse(c.Trim(), out int o))
list.Add(o);
}
if (list.Count > 0)
if (list.Any())
TimerAlerts = list;
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public CreatureCollection CreatureCollection
}
}
}
// timer.Enabled = (timerListEntries.Count > 0); invoke event to check if there are any timers and if not disable ticking? todo
// timer.Enabled = (timerListEntries.Any()); invoke event to check if there are any timers and if not disable ticking? todo
}
}

Expand Down
28 changes: 0 additions & 28 deletions ARKBreedingStats/ocr/OCRTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@ private void initLabelNames()
labelNameIndices = new Dictionary<string, int>();
for (int i = 0; i < labelNames.Count; i++)
labelNameIndices.Add(labelNames[i], i);

//if (labelRecs.Count > 0)
//{
// Rectangle r = new Rectangle(labelRecs[0].Left, labelRecs[0].Top, labelRecs[0].Width, labelRecs[0].Height);
// for (int i = 0; i < 9 && i < labelRecs.Count; i++)
// {
// labelRectangles.Add(new Rectangle(r.Left, r.Top, r.Width, r.Height));
// r.Offset(0, statDistance);
// }

// for (int i = 1; i < labelRecs.Count && i + 9 < labelNames.Count; i++)
// labelRectangles.Add(labelRecs[i]);
//}


//labelNameIndices.Add("Health", 0);
//labelNameIndices.Add("Stamina", 1);
//labelNameIndices.Add("Oxygen", 2);
//labelNameIndices.Add("Food", 3);
//labelNameIndices.Add("Weight", 4);
//labelNameIndices.Add("MeleeDamage", 5);
//labelNameIndices.Add("MovementSpeed", 6);
//labelNameIndices.Add("Torpor", 7);
//labelNameIndices.Add("Imprinting", 8);
//labelNameIndices.Add("Level", 9);
//labelNameIndices.Add("NameSpecies", 10);
//labelNameIndices.Add("Tribe", 11);
//labelNameIndices.Add("Owner", 12);
}

private void initReducedIndices()
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/species/Species.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void Initialize(StreamingContext context)
if (string.IsNullOrEmpty(blueprintPath))
blueprintPath = string.Empty;

if (boneDamageAdjusters != null && boneDamageAdjusters.Count > 0)
if (boneDamageAdjusters != null && boneDamageAdjusters.Any())
{
// cleanup boneDamageMultipliers. Remove duplicates. Improve names.
var boneDamageAdjustersCleanedUp = new Dictionary<string, double>();
Expand Down

0 comments on commit 69e75ee

Please sign in to comment.