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;
|
string fromName = fromType.Name;
|
||||||
Debug.WriteLine($"Trying to convert {fromName} to {toName}.");
|
Debug.WriteLine($"Trying to convert {fromName} to {toName}.");
|
||||||
|
|
||||||
int fromFormat = fromName.Last() - '0';
|
|
||||||
int toFormat = toName.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);
|
var pkm = ConvertPKM(pk, PKMType, toFormat, ref comment);
|
||||||
|
var msg = pkm == null ? MsgPKMConvertFailFormat : MsgPKMConvertSuccess;
|
||||||
comment = pkm == null
|
var formatted = string.Format(msg, fromName, toName);
|
||||||
? string.Format(MsgPKMConvertFailFormat, fromName, toName)
|
comment = comment == null ? formatted : string.Concat(formatted, Environment.NewLine, comment);
|
||||||
: string.Format(MsgPKMConvertSuccess, fromName, toName);
|
|
||||||
return pkm;
|
return pkm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue