示例#1
0
        private void Callbacks_PlayerChat(object sender, Communication.EventArguments.Callbacks.PlayerChatEventArgs e)
        {
            if (e.IsServerMessage)
            {
                return;
            }

            RunCatchLog(() =>
            {
                string text = e.Text.ToLower(CultureInfo.InvariantCulture);

                ServerCommand command = ServerCommand.Parse(e.Text);
                if (ProRestartCommands.Contains(text) || command.Is(Command.ProRestart))
                {
                    if (ConsiderLogin(e.Login, true))
                    {
                        SendFormattedMessageToLogin(e.Login, "{[#ServerStyle]}>{[#MessageStyle]} Your vote for track restart was considered.");
                        SendStatisticsToLogin(e.Login);
                    }

                    return;
                }

                if ((ConRestartCommands.Contains(text) || command.Is(Command.ConRestart)) && ConsiderLogin(e.Login, false))
                {
                    SendFormattedMessageToLogin(e.Login, "{[#ServerStyle]}>{[#MessageStyle]} Your vote against track restart was considered.");
                    SendStatisticsToLogin(e.Login);
                }
            }, "Error in PlayerChat Callback.", true);
        }
示例#2
0
        private void Callbacks_PlayerChat(object sender, Communication.EventArguments.Callbacks.PlayerChatEventArgs e)
        {
            if (e.IsServerMessage || e.Text.IsNullOrTimmedEmpty() || e.IsRegisteredCommand)
            {
                return;
            }

            string message = e.Text.Trim();
            ushort?voteValue;

            Dictionary <string, ushort?> voteValues = new Dictionary <string, ushort?> {
                { "++", 8 }, { "--", 0 }, { "+-", 4 }, { "-+", 4 },
                { "+1", 1 }, { "+2", 2 }, { "+3", 3 }, { "+4", 4 },
                { "+5", 5 }, { "+6", 6 }, { "+7", 7 }, { "+8", 8 }
            };

            voteValues.TryGetValue(message, out voteValue);

            if (voteValue.HasValue)
            {
                Pair <double?, int> voteInfo = HostPlugin.RatingAdapter.Vote(e.Login, HostPlugin.CurrentChallengeID, voteValue.Value);
                double?averageVote           = voteInfo.Value1;

                if (averageVote.HasValue)
                {
                    OnPlayerVoted(e.Login, voteValue.Value, averageVote.Value, voteInfo.Value2);
                }
            }
        }
示例#3
0
        private void Callbacks_PlayerChat(object sender, Communication.EventArguments.Callbacks.PlayerChatEventArgs e)
        {
            RunCatchLog(() =>
            {
                ServerCommand command = ServerCommand.Parse(e.Text);

                if (!command.Is(Command.Donate) || command.PartsWithoutMainCommand.Count == 0)
                {
                    return;
                }

                int coppers;

                if (!int.TryParse(command.PartsWithoutMainCommand[0], NumberStyles.None, CultureInfo.InvariantCulture, out coppers) || coppers <= 0)
                {
                    return;
                }

                if (coppers < Settings.MinDonationValue)
                {
                    SendFormattedMessageToLogin(e.Login, Settings.DonationToSmallMessage, "Coppers", Settings.MinDonationValue.ToString(CultureInfo.InvariantCulture));
                    return;
                }

                PlayerSettings playerSettings = GetPlayerSettings(e.Login);

                bool isUnitedAccount = playerSettings.IsUnitedAccount;

                if (!playerSettings.DetailMode.HasDetailedPlayerInfo())
                {
                    DetailedPlayerInfo playerInfo = GetDetailedPlayerInfo(e.Login);

                    if (playerInfo != null)
                    {
                        isUnitedAccount = playerInfo.IsUnitedAccount;
                    }
                }

                if (!isUnitedAccount)
                {
                    SendFormattedMessageToLogin(e.Login, Settings.PlayerHasNoUnitedAccountMessage);
                    return;
                }

                GenericResponse <int> billResponse = Context.RPCClient.Methods.SendBill(e.Login, coppers, Settings.DonationHint, Settings.DonationTargetLogin);

                if (billResponse.Erroneous)
                {
                    Logger.Warn(string.Format("Error while calling method SendBill: {0}({1})", billResponse.Fault.FaultMessage, billResponse.Fault.FaultCode));
                    SendFormattedMessageToLogin(e.Login, Settings.DonationErrorMessage, "ErrorMessage", billResponse.Fault.FaultMessage);
                    return;
                }

                BillDictionary[billResponse.Value] = new DonationInfo {
                    Login = e.Login, Coppers = coppers
                };
            }, "Error in Callbacks_PlayerChat Method.", true);
        }
示例#4
0
        private void Callbacks_PlayerChat(object sender, Communication.EventArguments.Callbacks.PlayerChatEventArgs e)
        {
            RunCatchLog(() =>
            {
                ServerCommand command = ServerCommand.Parse(e.Text);

                if (command != null)
                {
                    HandleCommand(e.Login, command);
                }
            }, "Errror in Callbacks_PlayerChat", true);
        }