public SavedState LoadGame(SavedState game, Player playe, string name) { string file; string line; Configuration.ConfigurationMap.TryGetValue(Constants.STATEFILe, out file); System.IO.StreamReader file2 = new System.IO.StreamReader(Constants.getFile(file)); while ((line = file2.ReadLine()) != null) { if (!line.StartsWith("#")) { string[] data = line.Split(':'); if (data[1].Equals(name)) { game.Id = Int32.Parse(data[0]); game.Time = DateTime.Parse(data[2]); game.Name = data[1]; game.Steps = Int32.Parse(data[3]); game.State = data[4]; file2.Close(); return game; } } } file2.Close(); return null; }
public bool CheckCredentials(ref Player player) { foreach (Player player1 in players) { if (player1.UserName.Equals(player.UserName) && (player1.Password.Equals(player.Password))) { player = player1; return true; } } return false; }
private void button1_Click(object sender, EventArgs e) { Player player = new Player(); player.UserName = textBox1.Text; player.Password = textBox2.Text; if (Player.CheckCredential(ref player)) { this.Hide(); MainForm form = new MainForm(); form.setPlayer(player); form.ShowDialog(); this.Close(); } else { PuzzleMessage.showMessage(3); } }
public void SaveScore(int score, Player player) { }
public void SaveGame(SavedState game , Player player) { }
public SavedState LoadGame(SavedState game, Player playe, string name) { return null; }
public bool CheckCredentials( ref Player player) { return false; }
public void SaveGame(Player player) { Configuration.da.SaveGame(this, player); }
public SavedState LoadGame(Player player, string name) { return Configuration.da.LoadGame(this, player, name); }
public static bool CheckCredential(ref Player potentialPlayer) { return Configuration.da.CheckCredentials(ref potentialPlayer); }
private static Player loadFileToPlayer(string line) { List<Player> players = new List<Player>(); char[] separators = { ':' }; if (line.StartsWith("#")) { return null; } String[] values = line.Split(separators); Player player = new Player(); player.Id = int.Parse( values[0]); player.Name = values[1]; player.UserName = values[2]; player.Password = values[3]; player.photo =values[4]; player.Admin = bool.Parse( values[5]); return player; }
public void SaveScore(int score, Player player) { List<int> highScores = new List<int>(); string file; string line; Configuration.ConfigurationMap.TryGetValue(Constants.SCOREFILE, out file); System.IO.StreamReader file2 = new System.IO.StreamReader(Constants.getFile(file)); while ((line = file2.ReadLine()) != null) { if (!line.StartsWith("#")) { string[] data = line.Split(':'); highScores.Add(Int32.Parse(data[2])); } } file2.Close(); bool newHighScore = false; for (int i = 0;i < highScores.Count;i++) { if (score < highScores[i]) newHighScore = true; } if (newHighScore) { Configuration.ConfigurationMap.TryGetValue(Constants.SCOREFILE, out file); using (StreamWriter sw = new StreamWriter(Constants.getFile(file), true)) { //#id:name:score sw.Write(Environment.NewLine + player.Id.ToString() + ":" + player.Name + ":" + score); } } }
public void SaveGame(SavedState game , Player player) { string file; Configuration.ConfigurationMap.TryGetValue(Constants.STATEFILe, out file); using (StreamWriter sw = new StreamWriter(Constants.getFile(file),true)) { //#id:date:steps:state sw.Write(Environment.NewLine+player.Id.ToString() + ":" + game.Name+ ":" +game.Time.ToLongDateString() + ":" + game.Steps + ":" + game.State); } }