Exemplo n.º 1
0
        private static bool AddToTradeQueue(SocketCommandContext context, T pk, int code, string trainerName, RequestSignificance sig, PokeRoutineType type, PokeTradeType t, SocketUser trader, out string msg, int catchID = 0)
        {
            var user   = trader;
            var userID = user.Id;
            var name   = user.Username;

            var trainer  = new PokeTradeTrainerInfo(trainerName, userID);
            var notifier = new DiscordTradeNotifier <T>(pk, trainer, code, user);
            var detail   = new PokeTradeDetail <T>(pk, trainer, notifier, t, code, sig == RequestSignificance.Favored);
            var trade    = new TradeEntry <T>(detail, userID, type, name);

            var hub   = SysCord <T> .Runner.Hub;
            var Info  = hub.Queues.Info;
            var added = Info.AddToTradeQueue(trade, userID, sig == RequestSignificance.Owner);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            if (detail.Type == PokeTradeType.TradeCord)
            {
                TradeCordHelper <T> .TradeCordTrades.Add(trader.Id, catchID);
            }

            var position = Info.CheckPosition(userID, type);

            var ticketID = "";

            if (TradeStartModule <T> .IsStartChannel(context.Channel.Id))
            {
                ticketID = $", unique ID: {detail.ID}";
            }

            var pokeName = "";

            if ((t == PokeTradeType.Specific || t == PokeTradeType.TradeCord || t == PokeTradeType.SupportTrade || t == PokeTradeType.Giveaway) && pk.Species != 0)
            {
                pokeName = $" Receiving: {(t == PokeTradeType.SupportTrade && pk.Species != (int)Species.Ditto && pk.HeldItem != 0 ? $"{(Species)pk.Species} ({ShowdownParsing.GetShowdownText(pk).Split('@','\n')[1].Trim()})" : $"{(Species)pk.Species}")}.";
            }
            msg = $"{user.Mention} - Added to the {type} queue{ticketID}. Current Position: {position.Position}.{pokeName}";

            var botct = Info.Hub.Bots.Count;

            if (position.Position > botct)
            {
                var eta = Info.Hub.Config.Queues.EstimateDelay(position.Position, botct);
                msg += $" Estimated: {eta:F1} minutes.";
            }
            return(true);
        }
Exemplo n.º 2
0
        private static bool AddToTradeQueue(this SocketCommandContext Context, PK8 pk8, int code, string trainerName, bool sudo, PokeRoutineType type, PokeTradeType t, out string msg)
        {
            var user   = Context.User;
            var userID = user.Id;
            var name   = user.Username;

            var trainer  = new PokeTradeTrainerInfo(trainerName);
            var notifier = new DiscordTradeNotifier <PK8>(pk8, trainer, code, Context);
            var detail   = new PokeTradeDetail <PK8>(pk8, trainer, notifier, t, code: code);
            var trade    = new TradeEntry <PK8>(detail, userID, type, name);

            var hub   = SysCordInstance.Self.Hub;
            var Info  = hub.Queues.Info;
            var added = Info.AddToTradeQueue(trade, userID, sudo);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            var position = Info.CheckPosition(userID, type);

            var ticketID = "";

            if (TradeStartModule.IsStartChannel(Context.Channel.Id))
            {
                ticketID = $", unique ID: {detail.ID}";
            }

            var pokeName = "";

            if (t == PokeTradeType.Specific || t == PokeTradeType.EggRoll && pk8.Species != 0)
            {
                pokeName = $" Receiving: {(t == PokeTradeType.EggRoll ? "Mysterious egg" : hub.Config.Trade.ItemMuleSpecies == (Species)pk8.Species && pk8.HeldItem != 0 ? $"{(Species)pk8.Species + " (" + ShowdownSet.GetShowdownText(pk8).Split('@','\n')[1].Trim() + ")"}" : $"{(Species)pk8.Species}")}.";
            }
            msg = $"{user.Mention} - Added to the {type} queue{ticketID}. Current Position: {position.Position}.{pokeName}";

            var botct = Info.Hub.Bots.Count;

            if (position.Position > botct)
            {
                var eta = Info.Hub.Config.Queues.EstimateDelay(position.Position, botct);
                msg += $" Estimated: {eta:F1} minutes.";
            }
            return(true);
        }
Exemplo n.º 3
0
        private static bool AddToTradeQueue(this SocketCommandContext Context, PK8 pk8, int code, string trainerName, RequestSignificance sig, PokeRoutineType type, PokeTradeType t, SocketUser trader, out string msg)
        {
            var user   = trader;
            var userID = user.Id;
            var name   = user.Username;

            var trainer  = new PokeTradeTrainerInfo(trainerName);
            var notifier = new DiscordTradeNotifier <PK8>(pk8, trainer, code, user);
            var detail   = new PokeTradeDetail <PK8>(pk8, trainer, notifier, t, code: code, sig == RequestSignificance.Favored);
            var trade    = new TradeEntry <PK8>(detail, userID, type, name);

            var hub   = SysCordInstance.Self.Hub;
            var Info  = hub.Queues.Info;
            var added = Info.AddToTradeQueue(trade, userID, sig == RequestSignificance.Sudo);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            var position = Info.CheckPosition(userID, type);

            var ticketID = "";

            if (TradeStartModule.IsStartChannel(Context.Channel.Id))
            {
                ticketID = $", unique ID: {detail.ID}";
            }

            var pokeName = "";

            if (t == PokeTradeType.Specific && pk8.Species != 0)
            {
                pokeName = $" Receiving: {(Species)pk8.Species}.";
            }
            msg = $"{user.Mention} - Added to the {type} queue{ticketID}. Current Position: {position.Position}.{pokeName}";

            var botct = Info.Hub.Bots.Count;

            if (position.Position > botct)
            {
                var eta = Info.Hub.Config.Queues.EstimateDelay(position.Position, botct);
                msg += $" Estimated: {eta:F1} minutes.";
            }
            return(true);
        }
Exemplo n.º 4
0
        private static bool AddToTradeQueue(this SocketCommandContext Context, PK8 pk8, int code, string trainerName, bool sudo, PokeRoutineType type, PokeTradeType t, out string msg)
        {
            var user     = Context.User;
            var userID   = user.Id;
            var name     = user.Username;
            var priority = user.EvaluatePriority();

            var trainer  = new PokeTradeTrainerInfo(trainerName);
            var notifier = new DiscordTradeNotifier <PK8>(pk8, trainer, code, Context);
            var detail   = new PokeTradeDetail <PK8>(pk8, trainer, notifier, t, code: code);
            var trade    = new TradeEntry <PK8>(detail, userID, type, name);

            var hub   = SysCordInstance.Self.Hub;
            var Info  = hub.Queues.Info;
            var added = Info.AddToTradeQueue(trade, userID, priority, sudo);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            user.Timestamp();
            var position = Info.CheckPosition(userID, type);

            var ticketID = "";

            if (TradeStartModule.IsStartChannel(Context.Channel.Id))
            {
                ticketID = $", unique ID: {detail.ID}";
            }

            msg = $"{user.Mention} - Added to the {type} queue{ticketID}. Current Position: {position.Position}";

            var botct = Info.Hub.Bots.Count;

            if (position.Position > botct)
            {
                var eta = Info.Hub.Config.Queues.EstimateDelay(position.Position, botct);
                msg += $". Estimated: {eta:F1} minutes.";
            }
            return(true);
        }
Exemplo n.º 5
0
        private bool AddToTradeQueue(PK8 pk8, int code, string trainerName, bool sudo, PokeRoutineType type, out string msg)
        {
            var user   = Context.User;
            var userID = user.Id;
            var name   = user.Username;

            var trainer  = new PokeTradeTrainerInfo(trainerName);
            var notifier = new DiscordTradeNotifier <PK8>(pk8, trainer, code, Context);
            var detail   = new PokeTradeDetail <PK8>(pk8, trainer, notifier, PokeTradeType.Dudu, code: code);
            var trade    = new TradeEntry <PK8>(detail, userID, type, name);

            var added = Info.AddToTradeQueue(trade, userID, sudo);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            msg = $"Added {user.Mention} to the queue for trade type: {type}. Your current position is: {Info.CheckPosition(userID, type).Position}";
            return(true);
        }
Exemplo n.º 6
0
        private static bool AddToTradeQueue(this SocketCommandContext Context, PK8 pk8, int code, string trainerName, RequestSignificance sig, PokeRoutineType type, PokeTradeType t, SocketUser trader, out string msg, string requestedIgn = "")
        {
            var user   = trader;
            var userID = user.Id;
            var name   = user.Username;

            var trainer  = new PokeTradeTrainerInfo(trainerName);
            var notifier = new DiscordTradeNotifier <PK8>(pk8, trainer, code, Context, user);
            var detail   = new PokeTradeDetail <PK8>(pk8, trainer, notifier, t, code, userID, sig == RequestSignificance.Favored, requestedIgn);
            var trade    = new TradeEntry <PK8>(detail, userID, type, name);

            var hub   = SysCordInstance.Self.Hub;
            var Info  = hub.Queues.Info;
            var added = Info.AddToTradeQueue(trade, userID, sig == RequestSignificance.Favored);

            if (added == QueueResultAdd.AlreadyInQueue)
            {
                msg = "Sorry, you are already in the queue.";
                return(false);
            }

            var position = Info.CheckPosition(userID, type);
            var ticketID = "";

            if (TradeStartModule.IsStartChannel(Context.Channel.Id))
            {
                ticketID = $", unique ID: {detail.ID}";
            }

            var pokeName = "";

            if (t == PokeTradeType.LanTrade || t == PokeTradeType.Specific || t == PokeTradeType.EggRoll && Info.Hub.Config.Discord.DisplayPokeName && pk8.Species != 0)
            {
                pokeName = $" Receiving: {(t == PokeTradeType.EggRoll ? "Mysterious Egg" : hub.Config.Trade.ItemMuleSpecies == (Species)pk8.Species && pk8.HeldItem != 0 ? $"{(Species)pk8.Species + " (" + ShowdownSet.GetShowdownText(pk8).Split('@', '\n')[1].Trim() + ")"}" : $"{(Species)pk8.Species}")}{(pk8.IsEgg && t != PokeTradeType.EggRoll ? " (Egg)" : "")}.";
            }

            if (t == PokeTradeType.LanRoll && Info.Hub.Config.Discord.DisplayPokeName && pk8.Species != 0)
            {
                pokeName = $" Receiving: An Illegal Egg.";
            }

            string overallPosition = "";

            if (Info.Hub.Config.Discord.PostOverallQueueCount)
            {
                if (position.QueueCount != position.OverallQueueCount)
                {
                    if (type == PokeRoutineType.SeedCheck && hub.Config.Queues.FlexMode == FlexYieldMode.LessCheatyFirst)
                    {
                        overallPosition = $" | __Overall: {position.Position}/{position.OverallQueueCount}__";
                    }
                    else
                    {
                        overallPosition = $" | __Overall: {position.OverallPosition}/{position.OverallQueueCount}__";
                    }
                }
                else
                {
                    overallPosition = $"";
                }
            }

            var ignName = "";

            if (t == PokeTradeType.LanTrade || t == PokeTradeType.LanRoll)
            {
                if (requestedIgn != string.Empty)
                {
                    ignName = $" Looking for {requestedIgn}.";
                }
            }

            msg = $"{user.Mention} - Added to the **{type}** queue{ticketID}. Current Position: __{type}: {position.Position}/{position.QueueCount}__{overallPosition}.{pokeName}{ignName}";

            var botct = Info.Hub.Bots.Count;

            if (position.Position > botct)
            {
                var eta = Info.Hub.Config.Queues.EstimateDelay(position.Position, botct);
                msg += $" Estimated: {eta:F1} minutes.";
            }
            return(true);
        }