mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 20:43:07 +00:00
Simplify expression, emit inner error messages
existing logic had been overwriting the inner error messages with the generic fail message Remove backwards conversion precondition check; the ConvertPKM method has no branches that allow conversion so it'll naturally fail -- end result is the same with less upfront logic.
This commit is contained in:
parent
86d10af78b
commit
5a53c2490a
1 changed files with 3 additions and 11 deletions
|
@ -239,19 +239,11 @@ namespace PKHeX.Core
|
|||
string fromName = fromType.Name;
|
||||
Debug.WriteLine($"Trying to convert {fromName} to {toName}.");
|
||||
|
||||
int fromFormat = fromName.Last() - '0';
|
||||
int toFormat = toName.Last() - '0';
|
||||
if (fromFormat > toFormat && fromFormat != 2)
|
||||
{
|
||||
comment = string.Format(MsgPKMConvertFailFormat, fromName, toName);
|
||||
return null;
|
||||
}
|
||||
|
||||
var pkm = ConvertPKM(pk, PKMType, toFormat, ref comment);
|
||||
|
||||
comment = pkm == null
|
||||
? string.Format(MsgPKMConvertFailFormat, fromName, toName)
|
||||
: string.Format(MsgPKMConvertSuccess, fromName, toName);
|
||||
var msg = pkm == null ? MsgPKMConvertFailFormat : MsgPKMConvertSuccess;
|
||||
var formatted = string.Format(msg, fromName, toName);
|
||||
comment = comment == null ? formatted : string.Concat(formatted, Environment.NewLine, comment);
|
||||
return pkm;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue