private static List<Pokemon> extractImportable(string importable) { List<Pokemon> pokemon = new List<Pokemon>(); Pokemon aktpkm = null; importable = importable.Replace("\r",""); string[] splitArray = importable.Split('\n'); int count = 0; foreach (string line in splitArray) { string s = line; if (s.Trim().StartsWith("===")) { count++; continue; } if((line.Contains("@") || (splitArray.Length > count + 1 && splitArray[count + 1].Contains("Ability:")) || (count - 1 >= 0 && splitArray[count - 1] == "") || (count - 1 < 0)) && line.Trim() != "") { if (aktpkm != null) { pokemon.Add(aktpkm); } aktpkm = new Pokemon(); if (s.Contains("(M)")) { s = s.Replace("(M)", ""); aktpkm.gender = "m"; } else if (s.Contains("(F)")) { s = s.Replace("(F)", ""); aktpkm.gender = "f"; } if (s.Contains("(")) { aktpkm.nickname = s.Substring(0, s.IndexOf("(")).Trim(); aktpkm.name = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - (s.IndexOf("(") + 1)); if (s.Contains("@")) { aktpkm.item = s.Substring(s.IndexOf("@") + 1).Trim(); } } else { if (s.Contains("@")) { aktpkm.name = s.Substring(0, s.IndexOf("@")); aktpkm.item = s.Substring(s.IndexOf("@") + 1).Trim(); } else { aktpkm.name = s; } } aktpkm.name = aktpkm.name.Trim(); } else if(s.Contains("Ability:")) { aktpkm.ability = s.Substring(s.IndexOf(":") + 1).Trim(); } else if (s.Contains("Level:")) { aktpkm.level = s.Substring(s.IndexOf(":") + 1).Trim(); } else if (s.Contains("EVs:")) { aktpkm.evs = s.Substring(s.IndexOf(":") + 1).Trim(); } else if (s.Contains("IVs:")) { aktpkm.ivs = s.Substring(s.IndexOf(":") + 1).Trim(); } else if (s.Contains("Happiness:")) { aktpkm.happiness = s.Substring(s.IndexOf(":") + 1).Trim(); } else if (s.Contains("Shiny:")) { aktpkm.shiny = true; } else if (s.Trim().EndsWith("Nature")) { aktpkm.nature = s.Substring(0, s.IndexOf("Nature")).Trim(); } else if (s.Trim().StartsWith("-")) { aktpkm.moves.Add(s.Substring(1).Trim()); } count += 1; } pokemon.Add(aktpkm); return pokemon; }
private void mainMenuSave(Pokemon p) { string pokemon = p.name; string item = p.item; string ability = p.ability; string nature = p.nature; string move1 = p.moves[0]; string move2 = p.moves[1]; string move3 = p.moves[2]; string move4 = p.moves[3]; SavePKX.FileName = TB_Nickname.Text + " - " + TB_PID.Text; if (!extractPath.Trim().EndsWith("\\") && !extractPath.Trim().EndsWith("/")) { extractPath = extractPath + "\\"; } string path = extractPath + pokemon + "_" + item + "_" + ability + "_" + nature + "_" + move1 + "_" + move2 + "_" + move3 + "_" + move4 + ".ekx"; //Debug Help Console.WriteLine(pokemon + "_" + item + "_" + ability + "_" + nature + "_" + move1 + "_" + move2 + "_" + move3 + "_" + move4); string ext = ".ekx"; byte[] pkx = preparepkx(buff); if ((ext == ".ekx") || (ext == ".bin") || (ext == ".pkx") || (ext == ".ek6") || (ext == ".pk6")) { if ((ext == ".ekx") || (ext == ".bin") || (ext == ".ek6")) pkx = PKX.encryptArray(pkx); File.WriteAllBytes(path, pkx.ToArray()); } else { Util.Error("Foreign File Extension", "Exporting as encrypted."); pkx = PKX.encryptArray(pkx); File.WriteAllBytes(path, pkx); } }
private void mainMenuSave(Pokemon p) { string pokemon = p.name; string item = p.item; string ability = p.ability; string nature = p.nature; string move1 = (p.moves.Count > 0) ? p.moves[0] : "(None)"; string move2 = (p.moves.Count > 1) ? p.moves[1] : "(None)"; string move3 = (p.moves.Count > 2) ? p.moves[2] : "(None)"; string move4 = (p.moves.Count > 3) ? p.moves[3] : "(None)"; PKM pk = preparePKM(); string fileName = TB_Nickname.Text + " - " + TB_PID.Text; if (!extractPath.Trim().EndsWith("\\") && !extractPath.Trim().EndsWith("/")) { extractPath = extractPath + "\\"; } string path = extractPath + pokemon + "_" + item + "_" + ability + "_" + nature + "_" + move1 + "_" + move2 + "_" + move3 + "_" + move4 + ".ekx"; //Debug Help Console.WriteLine(pokemon + "_" + item + "_" + ability + "_" + nature + "_" + move1 + "_" + move2 + "_" + move3 + "_" + move4); string ext = ".ekx"; File.WriteAllBytes(path, pkm.EncryptedPartyData); }