union / count usages
remove unnecessary stuff
This commit is contained in:
Kurt
2017-10-06 21:03:23 -07:00
parent 762b55e957
commit c7dfc3d9b0
6 changed files with 8 additions and 8 deletions

View File

@@ -1639,7 +1639,7 @@ private static IEnumerable<int> GetValidMoves(PKM pkm, GameVersion Version, IRea
if (vs[gen].Any())
r.AddRange(GetValidMoves(pkm, Version, vs[gen], gen, minLvLG1: minLvLG1, minLvLG2: minLvLG2, LVL: LVL, Relearn: false, Tutor: Tutor, Machine: Machine, MoveReminder: MoveReminder, RemoveTransferHM: RemoveTransferHM));
return r.Distinct().ToArray();
return r.Distinct();
}
private static IEnumerable<int> GetValidMoves(PKM pkm, GameVersion Version, DexLevel[] vs, int Generation, int minLvLG1 = 1, int minLvLG2 = 1, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false, bool MoveReminder = true, bool RemoveTransferHM = true)
{

View File

@@ -745,7 +745,7 @@ private static int GetRequiredBaseMoveCount(int[] Moves, EggInfoSource infoset)
int inheritCt = inherited.Count;
// Get required amount of base moves
int unique = infoset.Base.Concat(inherited).Distinct().Count();
int unique = infoset.Base.Union(inherited).Count();
int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt;
if (Moves.Count(m => m != 0) < Math.Min(4, infoset.Base.Count))
reqBase = Math.Min(4, unique);

View File

@@ -172,9 +172,9 @@ private static int GetRequiredBaseMoves(int[] RelearnMoves, IReadOnlyList<int> b
int inheritCt = inherited.Count;
// Get required amount of base moves
int unique = baseMoves.Concat(inherited).Distinct().Count();
int unique = baseMoves.Union(inherited).Count();
int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt;
if (RelearnMoves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Count))
if (RelearnMoves.Count(m => m != 0) < Math.Min(4, baseMoves.Count))
reqBase = Math.Min(4, unique);
return reqBase;
}

View File

@@ -40,7 +40,7 @@ private static string[][] GetPropArray()
p[i] = ReflectFrameworkUtil.GetPropertiesCanWritePublicDeclared(types[i]).Concat(CustomProperties).OrderBy(a => a).ToArray();
// Properties for any PKM
var any = ReflectFrameworkUtil.GetPropertiesCanWritePublic(typeof(PK1)).Concat(p.SelectMany(a => a)).Distinct().OrderBy(a => a).ToArray();
var any = ReflectFrameworkUtil.GetPropertiesCanWritePublic(typeof(PK1)).Union(p.SelectMany(a => a)).OrderBy(a => a).ToArray();
// Properties shared by all PKM
var all = p.Aggregate(new HashSet<string>(p.First()), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray();

View File

@@ -207,7 +207,8 @@ private void LoadDatabase()
RawDB.AddRange(Legal.MGDB_G6);
RawDB.AddRange(Legal.MGDB_G7);
RawDB = new List<MysteryGift>(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct().Concat(Legal.MGDB_G3).OrderBy(mg => mg.Species));
RawDB = new List<MysteryGift>(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct()
.Concat(Legal.MGDB_G3).OrderBy(mg => mg.Species));
foreach (var mg in RawDB)
mg.GiftUsed = false;
BeginInvoke(new MethodInvoker(delegate

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using PKHeX.Core;