public bool equalsCurrentGame(Game game) { String filetrn = Directory.GetFiles(game.path, "*.trn")[0]; String currenttrn = Directory.GetFiles(gamefolder, "*.trn")[0]; return doCompare(filetrn, currenttrn); }
public void changeName(Game game) { StreamReader reader = new StreamReader(Path.Combine(game.path, "data.txt")); List<String> lines = new List<string>(); while (!reader.EndOfStream) { lines.Add(reader.ReadLine()); } reader.Close(); StreamWriter writer = new StreamWriter(Path.Combine(game.path, "data.txt")); writer.WriteLine(game.name); for (int n = 1; n < lines.Count; n++) { writer.WriteLine(lines[n]); } writer.Close(); }
private void recursivelyAddChildren(Game game, TreeNode node) { String[] children = saver.getChildrenPaths(game.path); if (currentGame == null) { if (saver.equalsCurrentGame(game)) { currentGame = node; } } foreach (String path in children) { Game newGame = saver.getGame(path); TreeNode newNode = node.Nodes.Add(newGame.name); newNode.Tag = newGame; recursivelyAddChildren(newGame, newNode); } }
public void SetTo(Game source) { copyFiles(source.path, gamefolder); String dataFilePath = Path.Combine(gamefolder, "data.txt"); if (File.Exists(dataFilePath)) File.Delete(dataFilePath); lastSave = File.GetLastWriteTime(savefile); }
public Game saveGame(String currentPath) { Game newGame = new Game(); String savePath = currentPath + "t"; newGame.path = currentPath; int n = 0; while (Directory.Exists(newGame.path)) { newGame.path = savePath + n++; } Directory.CreateDirectory(newGame.path); copyFiles(gamefolder, newGame.path); newGame.name = "turn" + ((n == 0) ? "" : " (" + n + ")"); StreamWriter writer = new StreamWriter(Path.Combine(currentPath, "data.txt"), true); writer.WriteLine(newGame.path); writer.Close(); System.Diagnostics.Debug.Print(newGame.path); writer = new StreamWriter(Path.Combine(newGame.path, "data.txt")); writer.WriteLine(newGame.name); writer.Close(); return newGame; }
public Game getGame(String currentPath) { Game game = new Game(); game.path = currentPath; if (!Directory.Exists(currentPath)) saveGame(currentPath); StreamReader reader = new StreamReader(Path.Combine(currentPath, "data.txt")); game.name = reader.ReadLine(); reader.Close(); return game; }