Ejemplo n.º 1
0
    public static IEnumerable <PKM> GetCompatible(this SaveFile sav, IEnumerable <PKM> pks)
    {
        var savtype = sav.PKMType;

        foreach (var temp in pks)
        {
            var pk = EntityConverter.ConvertToType(temp, savtype, out var c);
            if (pk == null)
            {
                Debug.WriteLine(c.GetDisplayString(temp, savtype));
                continue;
            }

            if (sav is ILangDeviantSave il && EntityConverter.IsIncompatibleGB(temp, il.Japanese, pk.Japanese))
            {
                var str = EntityConverterResult.IncompatibleLanguageGB.GetIncompatibleGBMessage(pk, il.Japanese);
                Debug.WriteLine(str);
                continue;
            }

            var compat = sav.EvaluateCompatibility(pk);
            if (compat.Count > 0)
            {
                continue;
            }

            yield return(pk);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Checks a <see cref="PKM"/> file for compatibility to the <see cref="SaveFile"/>.
    /// </summary>
    /// <param name="sav"><see cref="SaveFile"/> that is being checked.</param>
    /// <param name="pk"><see cref="PKM"/> that is being tested for compatibility.</param>
    public static bool IsCompatiblePKM(this SaveFile sav, PKM pk)
    {
        if (sav.PKMType != pk.GetType())
        {
            return(false);
        }

        if (sav is ILangDeviantSave il && EntityConverter.IsIncompatibleGB(pk, il.Japanese, pk.Japanese))
        {
            return(false);
        }

        return(true);
    }