Пример #1
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Init(IQueryAdapter dbClient)
        {
            Polls.Clear();

            dbClient.SetQuery("SELECT * FROM polls_data WHERE enabled = '1'");

            var table = dbClient.GetTable();

            if (table == null)
                return;

            foreach (DataRow dataRow in table.Rows)
            {
                var num = uint.Parse(dataRow["id"].ToString());

                dbClient.SetQuery($"SELECT * FROM polls_questions WHERE poll_id = {num}");

                var table2 = dbClient.GetTable();

                var list = (from DataRow dataRow2 in table2.Rows select new PollQuestion(uint.Parse(dataRow2["id"].ToString()), (string) dataRow2["question"], int.Parse(dataRow2["answertype"].ToString()), dataRow2["answers"].ToString().Split('|'), (string) dataRow2["correct_answer"])).ToList();

                var value = new Poll(num, uint.Parse(dataRow["room_id"].ToString()), (string) dataRow["caption"], (string) dataRow["invitation"], (string) dataRow["greetings"], (string) dataRow["prize"], int.Parse(dataRow["type"].ToString()), list);

                Polls.Add(num, value);
            }
        }
Пример #2
0
        internal static void MatchingPollResults(GameClient client, Poll poll)
        {
            var room = client.GetHabbo().CurrentRoom;
            if (poll == null || poll.Type != PollType.Matching || room == null)
                return;

            var users = room.GetRoomUserManager().GetRoomUsers();

            for (var i = 0; i < 10; i++)
            {
                Thread.Sleep(1000);
                foreach (var roomUser in users)
                {
                    var user = Azure.GetHabboById(roomUser.UserId);
                    if (user.AnsweredPool)
                    {
                        var result =
                            new ServerMessage(LibraryParser.OutgoingRequest("MatchingPollResultMessageComposer"));
                        result.AppendInteger(poll.Id);
                        result.AppendInteger(2);
                        result.AppendString("0");
                        result.AppendInteger(poll.AnswersNegative);
                        result.AppendString("1");
                        result.AppendInteger(poll.AnswersPositive);
                        client.SendMessage(result);
                    }
                }
            }

            foreach (var roomUser in users)
                Azure.GetHabboById(roomUser.UserId).AnsweredPool = false;
        }
Пример #3
0
 /// <summary>
 /// Tries the get poll.
 /// </summary>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="poll">The poll.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 internal bool TryGetPoll(uint roomId, out Poll poll)
 {
     foreach (Poll current in Polls.Values.Where(current => current.RoomId == roomId))
     {
         poll = current;
         return true;
     }
     poll = null;
     return false;
 }
Пример #4
0
 internal static void MatchingPollAnswer(GameClient client, Poll poll)
 {
     if (poll == null || poll.Type != Poll.PollType.Matching)
         return;
     var message = new ServerMessage(LibraryParser.OutgoingRequest("MatchingPollMessageComposer"));
     message.AppendString("MATCHING_POLL");
     message.AppendInteger(poll.Id);
     message.AppendInteger(poll.Id);
     message.AppendInteger(15580);
     message.AppendInteger(poll.Id);
     message.AppendInteger(29);
     message.AppendInteger(5);
     message.AppendString(poll.PollName);
     client.GetHabbo().CurrentRoom.SendMessage(message);
 }