private static void LoadTMHM(Stream stream, TMHMTutorLearnset tm, TMHMTutorLearnset hm) { var tmmoves = new List <int>(); var hmmoves = hm == null ? null : new List <int>(); using (var sr = new StreamReader(stream)) for (string line = sr.ReadLine(); !string.IsNullOrWhiteSpace(line); line = sr.ReadLine()) { //[0].[1] [2],[3]... var s = line.Split(SPLIT_CHARS, StringSplitOptions.RemoveEmptyEntries); for (int i = 2; i < s.Length; ++i) { //move:TM## move:HM## var mm = s[i]; var colon = mm.Length - 5; if (mm[colon] != ':') { colon--; } var move = int.Parse(mm.Substring(0, colon)); if (mm[colon + 1] == 'T') { tmmoves.Add(move); } else if (hmmoves == null) { break; } else { hmmoves.Add(move); } } var number = int.Parse(s[0]); var form = int.Parse(s[1]); if (tmmoves.Any()) { tm.Set(number, form, tmmoves.ToArray()); tmmoves.Clear(); } if (hmmoves != null && hmmoves.Any()) { hm.Set(number, form, hmmoves.ToArray()); hmmoves.Clear(); } } }
private static void LoadTutor(Stream stream, TMHMTutorLearnset tutor) { var moves = new List <int>(); using (var sr = new StreamReader(stream)) for (string line = sr.ReadLine(); !string.IsNullOrWhiteSpace(line); line = sr.ReadLine()) { //[0].[1] [2],[3]... var s = line.Split(SPLIT_CHARS, StringSplitOptions.RemoveEmptyEntries); for (int i = 2; i < s.Length; ++i) { moves.Add(int.Parse(s[i])); } if (moves.Any()) { tutor.Set(int.Parse(s[0]), int.Parse(s[1]), moves.ToArray()); moves.Clear(); } } }