예제 #1
0
        public static void JoinRoom(Client client, string roomName)
        {
            client.account.chatroomList.Add(roomName);

            RoomAPI.AddPlayer(roomName, client.account.username);
            List<string> playerList = RoomAPI.GetPlayerList(roomName);

            RoomEnter roomEnterServer = new RoomEnter();
            roomEnterServer.roomName = roomName;

            client.Send(roomEnterServer);

            RoomInfo roomInfo = new RoomInfo();
            roomInfo.updated  = new List<RoomInfo.PlayerInfo>();
            roomInfo.roomName = roomName;
            roomInfo.reset    = false;

            foreach (string playerName in playerList)
            {
                Client roomClient = PlayerAPI.GetSession(playerName, false);

                RoomInfo.PlayerInfo playerInfo = new RoomInfo.PlayerInfo();
                playerInfo.id               = roomClient.account.id;
                playerInfo.name             = roomClient.account.username;
                playerInfo.acceptChallenges = roomClient.account.acceptChallenges;
                playerInfo.acceptTrades     = roomClient.account.acceptTrades;
                playerInfo.adminRole        = roomClient.account.adminRole;

                roomInfo.updated.Add(playerInfo);
            }

            client.Send(roomInfo);

            RoomAPI.Message(roomName, "Scrolls", "You have joined \"" + roomName + "\"", client);

            RoomInfo newPlayerAlert = new RoomInfo();
            newPlayerAlert.updated  = new List<RoomInfo.PlayerInfo>();
            newPlayerAlert.roomName = roomName;

            RoomInfo.PlayerInfo newPlayerInfo = new RoomInfo.PlayerInfo();
            newPlayerInfo.id               = client.account.id;
            newPlayerInfo.name             = client.account.username;
            newPlayerInfo.acceptChallenges = client.account.acceptChallenges;
            newPlayerInfo.acceptTrades     = client.account.acceptTrades;
            newPlayerInfo.adminRole        = client.account.adminRole;

            newPlayerAlert.updated.Add(newPlayerInfo);

            foreach (string playerName in playerList)
            {
                PlayerAPI.GetSession(playerName, false).Send(newPlayerAlert);
            }
        }
예제 #2
0
        private static void RemovePlayerAlert(string roomName, string playerName)
        {
            List<string> playerList = GetPlayerList(roomName);

            RoomInfo roomInfo = new RoomInfo();
            roomInfo.removed  = new List<RoomInfo.PlayerInfo>();
            roomInfo.roomName = roomName;

            RoomInfo.PlayerInfo playerInfo = new RoomInfo.PlayerInfo();
            playerInfo.name = playerName;

            roomInfo.removed.Add(playerInfo);

            foreach (string roomPlayerName in playerList)
            {
                PlayerAPI.GetSession(roomPlayerName, false).Send(roomInfo);
            }
        }