public void SaveGame(GameState gameState, string fileName) { var fileNameWithExtension = AddFileNameExtension(fileName); var persistedBoardState = new PersistedGameState() { BoardType = gameState.Board.GetType().ToString(), BoardProcessorType = gameState.BoardProcessor.GetType().ToString(), RuleSet = gameState.BoardProcessor.RuleSet, TickNumber = gameState.TickNumber, CellArray = gameState.Board.GetCellArray() }; WritePersistedGameState(persistedBoardState, fileNameWithExtension); }
private void WritePersistedGameState(PersistedGameState persistedGameState, string saveFileName) { var path = $"{_saveDirectory}{saveFileName}"; File.WriteAllText(path, JsonConvert.SerializeObject(persistedGameState)); }