// セーブファイルを読み込む private void ReadOldFile() { do { Buffer = ContentsFileIO.Read(gameChoice).Split(','); if (Buffer.Length != Settings.PMAX + Settings.CMAX + 1) // 最大人数変更後のセーブデータ初期化 { Console.WriteLine("セーブデータが使用できません。\n現在のセーブデータをバックアップし、初期化します。\n"); ContentsFileIO.BackUp(gameChoice); WriteFile(true); } } while (Buffer.Length != Settings.PMAX + Settings.CMAX + 1); }
//////////////////////// 起動処理 //////////////////////// private void StartUp() { // 前回勝率の表示 if (ContentsFileIO.Read(gameChoice) == string.Empty) { NewFile(); } else { ReadOldFile(); UseOldFile(); } if (!IsContinue || !ConsoleIO.YesNoQ("続きから始めますか?(Y/N)>")) { NewGame(); } }
// Stringの生成と書込 private void WriteFile(bool init) { string s = string.Empty; for (int i = 0; i < Settings.PMAX + Settings.CMAX; i++) { if (init) { s += ','; } else { s += Buffer[i] + ','; if (i == Settings.PMAX + Settings.CMAX - 1) { s += Buffer[i + 1]; } } } ContentsFileIO.Write(gameChoice, s); }