public PokeTradeDetail(TPoke pkm, PokeTradeTrainerInfo info, IPokeTradeNotifier <TPoke> notifier, PokeTradeType type, int code) { Code = code; TradeData = pkm; Trainer = info; Notifier = notifier; Type = type; }
private int GetCountBias(PokeTradeType type) { return(type switch { PokeTradeType.Dudu => YieldMultCountDudu, PokeTradeType.Clone => YieldMultCountClone, PokeTradeType.Dump => YieldMultCountDump, _ => YieldMultCountTrade });
private int GetCountBias(PokeTradeType type) { return(type switch { PokeTradeType.Seed => YieldMultCountSeedCheck, PokeTradeType.Clone => YieldMultCountClone, PokeTradeType.FixOT => YieldMultCountFixOT, PokeTradeType.Dump => YieldMultCountDump, _ => YieldMultCountTrade });
public PokeTradeDetail(TPoke pkm, PokeTradeTrainerInfo info, IPokeTradeNotifier <TPoke> notifier, PokeTradeType type, int code) { Code = code; TradeData = pkm; Trainer = info; Notifier = notifier; Type = type; Time = DateTime.Now; ID = Interlocked.Increment(ref CreatedCount) % 3000; }
public PokeTradeDetail(TPoke pkm, PokeTradeTrainerInfo info, GiveawayPoolEntry poolEntry, IPokeTradeNotifier <TPoke> notifier, PokeTradeType type, int code, bool favored = false) { Code = code; TradeData = pkm; PoolEntry = poolEntry; Trainer = info; Notifier = notifier; Type = type; Time = DateTime.Now; IsFavored = favored; ID = Interlocked.Increment(ref CreatedCount) % 3000; }
private int GetCountBias(PokeTradeType type) { return(type switch { PokeTradeType.Seed => YieldMultCountSettings.YieldMultCountSeedCheck, PokeTradeType.Clone => YieldMultCountSettings.YieldMultCountClone, PokeTradeType.FixOT => YieldMultCountSettings.YieldMultCountFixOT, PokeTradeType.PowerUp => YieldMultCountSettings.YieldMultCountPowerUp, PokeTradeType.EggRoll => YieldMultCountSettings.YieldMultCountEggRoll, PokeTradeType.Dump => YieldMultCountSettings.YieldMultCountDump, PokeTradeType.LanTrade => YieldMultCountSettings.YieldMultCountLanTrade, PokeTradeType.LanRoll => YieldMultCountSettings.YieldMultCountLanRoll, _ => YieldMultCountSettings.YieldMultCountTrade });
public PokeTradeDetail(TPoke pkm, PokeTradeTrainerInfo info, IPokeTradeNotifier <TPoke> notifier, PokeTradeType type, int code, ulong disUserId, bool favored = false, string reqIgn = "") { Code = code; TradeData = pkm; Trainer = info; Notifier = notifier; Type = type; Time = DateTime.Now; IsFavored = favored; DiscordUserId = disUserId; RequestedIgn = reqIgn; ID = Interlocked.Increment(ref CreatedCount) % 3000; }
public static async Task AddToQueueAsync(this SocketCommandContext Context, int code, string trainer, bool sudo, PK8 trade, PokeRoutineType routine, PokeTradeType type) { if ((uint)code > MaxTradeCode) { await Context.Channel.SendMessageAsync("Trade code should be 00000000-99999999!").ConfigureAwait(false); return; } IUserMessage test; try { const string helper = "I've added you to the queue! I'll message you here when your trade is starting."; test = await Context.User.SendMessageAsync(helper).ConfigureAwait(false); } catch (HttpException ex) { await Context.Channel.SendMessageAsync($"{ex.HttpCode}: {ex.Reason}!").ConfigureAwait(false); await Context.Channel.SendMessageAsync("You must enable private messages in order to be queued!").ConfigureAwait(false); return; } // Try adding var result = Context.AddToTradeQueue(trade, code, trainer, sudo, routine, type, out var msg); // Notify in channel await Context.Channel.SendMessageAsync(msg).ConfigureAwait(false); // Notify in PM to mirror what is said in the channel. await Context.User.SendMessageAsync(msg).ConfigureAwait(false); // Clean Up if (result) { // Delete the user's join message for privacy if (!Context.IsPrivate) { await Context.Message.DeleteAsync(RequestOptions.Default).ConfigureAwait(false); } } else { // Delete our "I'm adding you!", and send the same message that we sent to the general channel. await test.DeleteAsync().ConfigureAwait(false); } }
public PokeTradeQueue(PokeTradeType type) => Type = type;
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); }
public static async Task AddToQueueAsync(SocketCommandContext context, int code, string trainer, RequestSignificance sig, T trade, PokeRoutineType routine, PokeTradeType type, int catchID = 0) { await AddToQueueAsync(context, code, trainer, sig, trade, routine, type, context.User, catchID).ConfigureAwait(false); }
public static async Task AddToQueueAsync(SocketCommandContext context, int code, string trainer, RequestSignificance sig, T trade, PokeRoutineType routine, PokeTradeType type, SocketUser trader, int catchID = 0) { if ((uint)code > MaxTradeCode) { await context.Channel.SendMessageAsync("Trade code should be 00000000-99999999!").ConfigureAwait(false); return; } try { const string helper = "I've added you to the queue! I'll message you here when your trade is starting."; IUserMessage test = await trader.SendMessageAsync(helper).ConfigureAwait(false); // Try adding var result = AddToTradeQueue(context, trade, code, trainer, sig, routine, type, trader, out var msg, catchID); // Notify in channel await context.Channel.SendMessageAsync(msg).ConfigureAwait(false); // Notify in PM to mirror what is said in the channel. await trader.SendMessageAsync($"{msg}\nYour trade code will be **{code:0000 0000}**.").ConfigureAwait(false); // Clean Up if (result) { // Delete the user's join message for privacy if (!context.IsPrivate) { await context.Message.DeleteAsync(RequestOptions.Default).ConfigureAwait(false); } } else { // Delete our "I'm adding you!", and send the same message that we sent to the general channel. await test.DeleteAsync().ConfigureAwait(false); } } catch (HttpException ex) { await HandleDiscordExceptionAsync(context, trader, ex).ConfigureAwait(false); } }
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); }
public static async Task AddToQueueAsync(this SocketCommandContext Context, int code, string trainer, RequestSignificance sig, PK8 trade, PokeRoutineType routine, PokeTradeType type) { await AddToQueueAsync(Context, code, trainer, sig, trade, routine, type, Context.User).ConfigureAwait(false); }
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); }
public ExternalPokeTradeDetail(TPoke pkm, PokeTradeTrainerInfo info, IPokeTradeNotifier <TPoke> notifier, PokeTradeType type, int code, TradeFile paths) : base(pkm, info, notifier, type, code) { SourcePath = paths.SourcePath; DestinationPath = paths.DestinationPath; }
public static async Task AddToQueueAsync(SocketCommandContext context, int code, string trainer, RequestSignificance sig, T trade, PokeRoutineType routine, PokeTradeType type, SocketUser trader) { if ((uint)code > MaxTradeCode) { await context.Channel.SendMessageAsync("Trade code should be 00000000-99999999!").ConfigureAwait(false); return; } IUserMessage test; try { const string helper = "I've added you to the queue! I'll message you here when your trade is starting."; test = await trader.SendMessageAsync(helper).ConfigureAwait(false); } catch (HttpException ex) { await context.Channel.SendMessageAsync($"{ex.HttpCode}: {ex.Reason}!").ConfigureAwait(false); var noAccessMsg = context.User == trader ? "You must enable private messages in order to be queued!" : "The mentioned user must enable private messages in order for them to be queued!"; await context.Channel.SendMessageAsync(noAccessMsg).ConfigureAwait(false); return; } // Try adding var result = AddToTradeQueue(context, trade, code, trainer, sig, routine, type, trader, out var msg); // Notify in channel await context.Channel.SendMessageAsync(msg).ConfigureAwait(false); // Notify in PM to mirror what is said in the channel. await trader.SendMessageAsync($"{msg}\nYour trade code will be **{code:0000 0000}**.").ConfigureAwait(false); try { // Clean Up if (result) { // Delete the user's join message for privacy if (!context.IsPrivate) { await context.Message.DeleteAsync(RequestOptions.Default).ConfigureAwait(false); } } else { // Delete our "I'm adding you!", and send the same message that we sent to the general channel. await test.DeleteAsync().ConfigureAwait(false); } } catch (HttpException ex) { string message; // Check if the exception was raised due to missing "Manage Messages" permissions. Ping the bot host if so. var permissions = context.Guild.CurrentUser.GetPermissions(context.Channel as IGuildChannel); if (!permissions.ManageMessages) { var app = await context.Client.GetApplicationInfoAsync().ConfigureAwait(false); var owner = app.Owner.Id; message = $"<@{owner}> You must grant me \"Manage Messages\" permissions!"; } else { // Send a generic error message if we're not missing "Manage Messages" permissions. message = $"{ex.HttpCode}: {ex.Reason}!"; } await context.Channel.SendMessageAsync(message).ConfigureAwait(false); } }
private int GetCountBias(PokeTradeType type) => type switch {
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); }
private async Task <bool> EnterUnionRoomWithCode(PokeTradeType tradeType, int tradeCode, CancellationToken token) { // Open y-comm and select global room await Click(Y, 1_000 + Hub.Config.Timings.ExtraTimeOpenYMenu, token).ConfigureAwait(false); await Click(DRIGHT, 0_400, token).ConfigureAwait(false); // French has one less menu if (GameLang is not LanguageID.French) { await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_000, 0, token).ConfigureAwait(false); } await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_500, 0, token).ConfigureAwait(false); // Japanese has one extra menu if (GameLang is LanguageID.Japanese) { await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_000, 0, token).ConfigureAwait(false); } await Click(A, 1_000, token).ConfigureAwait(false); // Would you like to enter? Screen Log("Selecting Link Code room."); // Link code selection index await Click(DDOWN, 0_200, token).ConfigureAwait(false); await Click(DDOWN, 0_200, token).ConfigureAwait(false); Log("Connecting to internet."); await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 2_000, 0, token).ConfigureAwait(false); // Extra menus. if (GameLang is LanguageID.German or LanguageID.Italian or LanguageID.Korean) { await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 0_750, 0, token).ConfigureAwait(false); } await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_000, 0, token).ConfigureAwait(false); await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_500, 0, token).ConfigureAwait(false); await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 1_500, 0, token).ConfigureAwait(false); // Would you like to save your adventure so far? await Click(A, 0_500, token).ConfigureAwait(false); await Click(A, 0_500, token).ConfigureAwait(false); Log("Saving the game."); // Agree and save the game. await Click(A, 0_050, token).ConfigureAwait(false); await PressAndHold(A, 6_500, 0, token).ConfigureAwait(false); if (tradeType != PokeTradeType.Random) { Hub.Config.Stream.StartEnterCode(this); } Log($"Entering Link Trade code: {tradeCode:0000 0000}..."); await EnterLinkCode(tradeCode, Hub.Config, token).ConfigureAwait(false); // Wait for Barrier to trigger all bots simultaneously. WaitAtBarrierIfApplicable(token); await Click(PLUS, 0_600, token).ConfigureAwait(false); Hub.Config.Stream.EndEnterCode(this); Log("Entering the Union Room."); // Wait until we're past the communication message. int tries = 100; while (!await IsUnionWork(UnionGamingOffset, token).ConfigureAwait(false)) { await Click(A, 0_300, token).ConfigureAwait(false); if (--tries < 1) { return(false); } } await Task.Delay(1_300 + Hub.Config.Timings.ExtraTimeJoinUnionRoom, token).ConfigureAwait(false); // Y-button trades always put us in a place where we can open the call menu without having to move. Log("Attempting to open the Y menu."); await Click(Y, 1_000, token).ConfigureAwait(false); await Click(A, 0_400, token).ConfigureAwait(false); await Click(DDOWN, 0_400, token).ConfigureAwait(false); await Click(A, 0_100, token).ConfigureAwait(false); return(true); // we are now searching }
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); }