Пример #1
0
 public bool GetName(int id, out string name)
 {
     name = string.Empty;
     if (PlayerByID.ContainsKey(id))
     {
         name = PlayerByID[id].Name;
     }
     return(true);
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }