Minor tweaks

Handle some compiler/extension suggestions
This commit is contained in:
Kurt 2020-04-12 16:07:59 -07:00
parent e83f2a7dd0
commit 33bdacebe8
8 changed files with 21 additions and 22 deletions

View file

@ -15,7 +15,7 @@ namespace PKHeX.Core
public static int[] GetMoveSet(this PKM pk, bool random = false)
{
var la = new LegalityAnalysis(pk);
var moves = pk.GetMoveSet(la, random);
var moves = la.GetMoveSet(random);
if (random)
return moves;
@ -31,16 +31,16 @@ namespace PKHeX.Core
/// <summary>
/// Gets a moveset for the provided <see cref="PKM"/> data.
/// </summary>
/// <param name="pk">PKM to generate for</param>
/// <param name="la">Precomputed optional</param>
/// <param name="random">Full movepool &amp; shuffling</param>
/// <returns>4 moves</returns>
public static int[] GetMoveSet(this PKM pk, LegalityAnalysis la, bool random = false)
public static int[] GetMoveSet(this LegalityAnalysis la, bool random = false)
{
int[] m = la.GetSuggestedMoves(tm: random, tutor: random, reminder: random);
if (!m.All(z => la.AllSuggestedMovesAndRelearn().Contains(z)))
m = m.Intersect(la.AllSuggestedMovesAndRelearn()).ToArray();
var learn = la.AllSuggestedMovesAndRelearn();
if (!m.All(z => learn.Contains(z)))
m = m.Intersect(learn).ToArray();
if (random)
Util.Shuffle(m);

View file

@ -251,7 +251,7 @@ namespace PKHeX.Core
if (cmd.PropertyValue.StartsWith(CONST_SUGGEST))
return SetSuggestedPKMProperty(cmd.PropertyName, info, cmd.PropertyValue);
if (cmd.PropertyValue == CONST_RAND && cmd.PropertyName == nameof(PKM.Moves))
return SetMoves(pk, pk.GetMoveSet(info.Legality, true));
return SetMoves(pk, info.Legality.GetMoveSet(true));
if (SetComplexProperty(pk, cmd))
return ModifyResult.Modified;
@ -427,7 +427,7 @@ namespace PKHeX.Core
return ModifyResult.Modified;
case nameof(PKM.Moves):
return SetMoves(pk, pk.GetMoveSet(la: info.Legality));
return SetMoves(pk, info.Legality.GetMoveSet());
case nameof(PKM.Ball):
BallApplicator.ApplyBallLegalByColor(pk);

View file

@ -31,13 +31,13 @@ namespace PKHeX.Core
/// <summary>Format text for exporting a legality check result for a Relearn Move.</summary>
public static string L_F0_RM_1_2 { get; set; } = "{0} Relearn Move {1}: {2}";
/// <summary>Format text for exporting the type of Encounter that was matched for the the <see cref="PKM"/></summary>
/// <summary>Format text for exporting the type of Encounter that was matched for the <see cref="PKM"/></summary>
public static string L_FEncounterType_0 { get; set; } = "Encounter Type: {0}";
/// <summary>Format text for exporting the <see cref="PIDIV.OriginSeed"/> that was matched for the the <see cref="PKM"/></summary>
/// <summary>Format text for exporting the <see cref="PIDIV.OriginSeed"/> that was matched for the <see cref="PKM"/></summary>
public static string L_FOriginSeed_0 { get; set; } = "Origin Seed: {0}";
/// <summary>Format text for exporting the <see cref="PIDIV.Type"/> that was matched for the the <see cref="PKM"/></summary>
/// <summary>Format text for exporting the <see cref="PIDIV.Type"/> that was matched for the <see cref="PKM"/></summary>
public static string L_FPIDType_0 { get; set; } = "PID Type: {0}";
/// <summary>Severity string for <see cref="Severity.Indeterminate"/></summary>

View file

@ -76,7 +76,7 @@ namespace PKHeX.Core
private const uint KMyStatus = 0xf25c070e; // Trainer Details
private const uint KFriendLeagueCards = 0x28e707f5; // League Cards received from other players
private const uint KNPCLeagueCards = 0xb1c26fb0; // League Cards received from NPCs
// Rental Teams - Objects (Blocks) (Incrementing internal names?)
private const uint KRentalTeam1 = 0x149A1DD0;
//private const uint KRentalTeam2 = 0x159A1F63; // does not exist

View file

@ -72,7 +72,7 @@ namespace PKHeX.Core
public bool PoketchFlag6 { get => (PoketchPacked & 0x40) != 0; set => PoketchPacked = (byte)(value ? (PoketchPacked | 0x40) : (PoketchPacked & ~0x40)); }
public bool PoketchFlag7 { get => (PoketchPacked & 0x80) != 0; set => PoketchPacked = (byte)(value ? (PoketchPacked | 0x80) : (PoketchPacked & ~0x80)); }
private byte Poketch1 { get => General[PoketchStart + 1]; set => General[PoketchStart + 1] = value; }
public byte Poketch1 { get => General[PoketchStart + 1]; set => General[PoketchStart + 1] = value; }
public sbyte CurrentPoketchApp { get => (sbyte)General[PoketchStart + 2]; set => General[PoketchStart + 2] = (byte)Math.Min((sbyte)PoketchApp.Alarm_Clock, value); }
public bool GetPoketchAppUnlocked(PoketchApp index)

View file

@ -84,11 +84,10 @@ namespace PKHeX.Core
public static int GetSuggestedCount(InventoryType t, int item, int requestVal)
{
switch (t)
return t switch
{
default:
return requestVal;
}
_ => requestVal
};
}
}
}
}

View file

@ -97,7 +97,7 @@ namespace PKHeX.WinForms.Controls
public bool Unicode { get; set; } = true;
private bool _hax;
public bool HaX { get => _hax; set => _hax = Stats.HaX = value; }
public byte[] LastData { private get; set; }
private byte[] LastData;
public PKM Data { get => Entity; set => Entity = value; }
public PKM Entity { get; private set; }
@ -581,7 +581,7 @@ namespace PKHeX.WinForms.Controls
private void ClickPPUps(object sender, EventArgs e)
{
bool min = ModifierKeys.HasFlag(Keys.Control);
static int getValue(ComboBox cb, bool zero) => zero || WinFormsUtil.GetIndex(cb) == 0 ? 0 : 3;
static int getValue(ListControl cb, bool zero) => zero || WinFormsUtil.GetIndex(cb) == 0 ? 0 : 3;
CB_PPu1.SelectedIndex = getValue(CB_Move1, min);
CB_PPu2.SelectedIndex = getValue(CB_Move2, min);
CB_PPu3.SelectedIndex = getValue(CB_Move3, min);
@ -703,8 +703,8 @@ namespace PKHeX.WinForms.Controls
private bool SetSuggestedMoves(bool random = false, bool silent = false)
{
int[] m = Entity.GetMoveSet(random);
if (m.Any(z => z != 0) != true)
var m = Entity.GetMoveSet(random);
if (m.All(z => z == 0) || m.Length == 0)
{
if (!silent)
WinFormsUtil.Alert(MsgPKMSuggestionFormat);

View file

@ -849,7 +849,7 @@ namespace PKHeX.WinForms
private static bool IsFileLocked(string path)
{
try { return File.GetAttributes(path).HasFlag(FileAttributes.ReadOnly); }
try { return (File.GetAttributes(path) & FileAttributes.ReadOnly) != 0; }
catch { return true; }
}