//The following methods are all related to reading/writing to or from various files #region Reading and writing to and from files #region Game saves //The following method will save the current state of a game to a text file private bool SaveGame() { StreamWriter writer; int gameSaveIndex; if (saveLoadedFrom == -1) { for (gameSaveIndex = 0; gameSaveIndex < 99; gameSaveIndex++) { if (!File.Exists("Saves\\Save" + p1.Name + p2.Name + gameSaveIndex + ".txt")) { writer = new StreamWriter("Saves\\Save" + p1.Name + p2.Name + gameSaveIndex + ".txt"); writer.WriteLine(logFileName); turnPlayer.SaveGameData(writer); standbyPlayer.SaveGameData(writer); writer.Close(); Console.WriteLine("\nYour game has been saved in file: Save" + p1.Name + p2.Name + gameSaveIndex + "\n"); writer = new StreamWriter("Logs\\" + logFileName + ".txt", true); writer.WriteLine("Game Saved"); writer.Close(); return(true); } } } else { gameSaveIndex = saveLoadedFrom; writer = new StreamWriter("Saves\\Save" + p1.Name + p2.Name + gameSaveIndex + ".txt"); writer.WriteLine(logFileName); turnPlayer.SaveGameData(writer); standbyPlayer.SaveGameData(writer); writer.Close(); Console.WriteLine("\nYour game has been saved in file: Save" + p1.Name + p2.Name + gameSaveIndex + "\n"); writer = new StreamWriter("Logs\\" + logFileName + ".txt", true); writer.WriteLine("Game Saved"); writer.Close(); return(true); } DisplayError("You have used up all 100 save slots for this player combination. You cannot save any more games between these two players until you delete some saves."); return(false); }