public bool GetName(int id, out string name) { name = string.Empty; if (PlayerByID.ContainsKey(id)) { name = PlayerByID[id].Name; } return(true); }
public bool AddMessage(int playerId, string playerMessage) { if (PlayerByID.ContainsKey(playerId)) { return(false); } var playerInfo = PlayerByID[playerId]; var message = String.Format("[{0}]: {1}", playerInfo.Name, playerMessage); chat.Add(message); return(true); }
public int AddPlayer(string name, int position) { if (PlayerBySeat.ContainsKey(position)) { return(-1); } var player = new PlayerInfo(name, position); var id = IDs.Where(x => !PlayerByID.ContainsKey(x)).FirstOrDefault(); PlayerByID.Add(id, player); PlayerBySeat.Add(position, player); return(id); }
public bool RemovePlayer(int playerId) { if (!PlayerByID.ContainsKey(playerId)) { return(false); } var playerInfo = PlayerByID[playerId]; var seat = playerInfo.Position; PlayerBySeat.Remove(seat); PlayerByID.Remove(playerId); if (Ready[seat]) { Ready[seat] = false; Count--; } return(true); }