/// <summary> /// Loads the players. /// </summary> /// <param name="game">The game.</param> public static void LoadPlayers(Game game) { game.Players = new Dictionary<string, Player>(); List<string> pemails = Directory.GetDirectories("Games\\" + game.Settings.GameName + "\\Players").Select(d => d.Substring(d.LastIndexOf('\\') + 1)).ToList(); foreach (string email in pemails) { Player p = new Player(); p.ReadFromFile(game.Settings.GameName, email); game.Players.Add(p.Identifier, p); } }
/// <summary> /// Initializes the specified player. /// </summary> /// <param name="p">The player.</param> public void Init(Player p) { this.Identifier = p.Identifier; this.Name = p.Name; this.Email = p.Email; this.TurnJoined = p.TurnJoined; this.QueuedOrders = p.QueuedOrders; }
/// <summary> /// Creates a new player for the specified game, using the specified name and email. /// </summary> /// <param name="game">The game.</param> /// <param name="name">The name.</param> /// <param name="email">The email.</param> /// <param name="turnJoined">The turn joined.</param> /// <returns></returns> public static Player CreatePlayer(Game game, string name, string email, int turnJoined) { Player p = new Player(); p.Identifier = game.Pool.ConsumeIdentifier(); p.Name = name; p.Email = email; p.TurnJoined = turnJoined; Hero h = new Hero(); h.Identifier = game.Pool.ConsumeIdentifier(); h.Name = "New Hero"; p.Heroes.Add(h.Identifier, h); game.Players.Add(p.Identifier, p); return p; }