public async Task QueueDebug(CommandContext ctx, int amount = 4) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (!ctx.Member.Id.ToString().Contains("107967155928088576") && !ctx.Member.Id.ToString().Contains("66318815247466496")) { await ctx.RespondAsync("You are not authorized to use this"); return; } if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.Idle) { await ctx.RespondAsync("There is no existing queue to join. Use `>startqueue` to start your own queue."); return; } ulong[] ids = { 277360174371438592, 66318815247466496, 337684398294040577, 107967155928088576, 219353394115117056 }; for (int i = 0; i < MathF.Min(ids.Length, amount); i++) { await MatchmakingModule.JoinQueue(ctx, ctx.Guild.Members[ids[i]]); } }
public async Task Spectate(CommandContext ctx) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (MatchmakingModule.CurrentGameState != MatchmakingModule.MatchmakingState.Queueing && MatchmakingModule.CurrentGameState != MatchmakingModule.MatchmakingState.GameSetup) { await ctx.RespondAsync("You cannot join spectators when a game has already started"); return; } if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.Idle) { await ctx.RespondAsync("There is no queue to spectate."); return; } if (!(await MatchmakingModule.DoesPlayerHaveSteamIDRegistered(ctx, ctx.Member))) { await ctx.RespondAsync("You must have your Steam ID registered to spectate! Use `>register [id]` to add your Steam ID. (NEEDS to be a SteamID64. Find your Steam ID here: https://steamidfinder.com/)"); return; } MatchmakingModule.CurrentSpectatorDiscordIds.Add(ctx.Member.Id.ToString()); MatchmakingModule.CurrentSpectatorIds.Add(ctx.Member.Id.ToString()); MatchmakingModule.CurrentSpectatorNames.Add(ctx.Member.DisplayName); await ctx.RespondAsync("You have been added to the list of spectators when the game starts"); }
public async Task LeaveQueue(CommandContext ctx) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (MatchmakingModule.CurrentGameState != MatchmakingModule.MatchmakingState.Queueing) { if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.Idle) { await ctx.RespondAsync("There is no existing queue to leave."); return; } else { await ctx.RespondAsync("A match is already ongoing, it cannot be left or joined."); return; } } await MatchmakingModule.LeaveQueue(ctx, ctx.Member); }
// LOGIC public void Initialize() { // Initialize providers m_ServiceProvider = new ServiceProvider(); m_ServiceProvider.Initialize(); // Initialize modules m_Modules = new List <GameServicesModule>(); // User Info module UserInfoModule userInfoModule = new UserInfoModule(); userInfoModule.Initialize(); m_Modules.Add(userInfoModule); // Friends module FriendsModule friendsModule = new FriendsModule(); friendsModule.Initialize(); m_Modules.Add(friendsModule); // Matchmaking module MatchmakingModule matchmakingModule = new MatchmakingModule(); matchmakingModule.Initialize(); m_Modules.Add(matchmakingModule); // Achievements module AchievementsModule achievementsModule = new AchievementsModule(); achievementsModule.Initialize(); m_Modules.Add(achievementsModule); // Stats module StatsModule statsModule = new StatsModule(); statsModule.Initialize(); m_Modules.Add(statsModule); m_Initialized = true; }
public async Task Recalculate(CommandContext ctx, int startFrom = 1) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (!ctx.Member.Id.ToString().Contains("107967155928088576") && !ctx.Member.Id.ToString().Contains("66318815247466496")) { await ctx.RespondAsync("You are not authorized to use this"); return; } await ctx.RespondAsync("Starting recalculation"); Dictionary <string, string> steamIdToPlayerId = new Dictionary <string, string>(); //Reset all player ELO first List <string> ids = await DatabaseModule.GetPlayerMatchmakingStatsIds(); for (int i = 0; i < ids.Count; i++) { PlayerData player = await DatabaseModule.GetPlayerMatchmakingStats(ids[i]); player = new PlayerData() { ID = player.ID, Name = player.Name, CurrentElo = 1000 }; steamIdToPlayerId.Add(await DatabaseModule.GetPlayerSteamIDFromDiscordID(player.ID), player.ID); await DatabaseModule.DeletePlayerStats(ids[i]); await DatabaseModule.AddPlayerMatchmakingStat(player); await ctx.RespondAsync("Reset player " + player.Name + "'s stats"); } List <string> squidCoinIds = await DatabaseModule.GetPlayerSquidIds(); for (int i = 0; i < squidCoinIds.Count; i++) { await DatabaseModule.DeleteSquidCoinPlayer(squidCoinIds[i]); } //Go through all the matches and recalculate their ELO await MatchmakingModule.RecalculateAllElo(ctx, steamIdToPlayerId, startFrom); }
public async Task Play(CommandContext ctx, string extra = "") { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (!(await MatchmakingModule.DoesPlayerHaveSteamIDRegistered(ctx, ctx.Member))) { await ctx.RespondAsync("You must have your Steam ID registered to play! Use `>register id` to add your Steam ID. (NEEDS to be a SteamID64. Find your Steam ID here: https://steamidfinder.com/)"); return; } if (MatchmakingModule.CurrentGameState != MatchmakingModule.MatchmakingState.Idle) { if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.GameInProgress || MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.GameSetup) { await ctx.RespondAsync("A match is currently being played, please wait until the match concludes."); } else if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.Queueing) { await ctx.RespondAsync("A queue already exists. Use `>queue` to join the game."); } else if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.DisplayingResults) { await ctx.RespondAsync("The results for the previous game are being calculated. Please wait for it to finish before starting a new queue."); } return; } MatchmakingModule.CurrentGameState = MatchmakingModule.MatchmakingState.Queueing; MatchmakingModule.PlayersInQueue.Clear(); MatchmakingModule.CaptainPick = extra.ToLower() == "pick"; await MatchmakingModule.ChangeNameIfRelevant(ctx.Member); await MatchmakingModule.JoinQueue(ctx, ctx.Member); new Task(async() => { await MatchmakingModule.TimeOut(ctx); }).Start(); }
public async Task UpdateName(CommandContext ctx) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } bool success = await MatchmakingModule.ChangeNameIfRelevant(ctx.Member); if (success) { await ctx.RespondAsync("Your name was updated to " + ctx.Member.DisplayName); } else { await ctx.RespondAsync("Your name was unable to be updated (You may not be in the system yet. Try playing at least one game.)"); } }
public async Task StopQueue(CommandContext ctx) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } bool isHost = MatchmakingModule.IsPlayerHost(ctx.Member); if (isHost) { await MatchmakingModule.Reset(); await ctx.RespondAsync("CS:GO session queue cancelled"); } else { await ctx.RespondAsync("You are not the host of this session. Only the host can stop their queue."); } }
public async Task Queue(CommandContext ctx) { if (ctx.Guild.Id != 572662006692315136) { await ctx.RespondAsync("Command is not usable within this guild"); return; } if (!(await MatchmakingModule.DoesPlayerHaveSteamIDRegistered(ctx, ctx.Member))) { await ctx.RespondAsync("You must have your Steam ID registered to play! Use `>register [id]` to add your Steam ID. (NEEDS to be a SteamID64. Find your Steam ID here: https://steamidfinder.com/)"); return; } if (MatchmakingModule.CurrentGameState == MatchmakingModule.MatchmakingState.Idle) { await ctx.RespondAsync("There is no existing queue to join. Use `>startqueue` to start your own queue."); return; } else if (MatchmakingModule.CurrentGameState != MatchmakingModule.MatchmakingState.Queueing) { await ctx.RespondAsync("A game is already being played, you cannot join this queue."); return; } if (MatchmakingModule.Bets.ContainsKey(ctx.Member.Id.ToString())) { await ctx.RespondAsync("Your bet of " + MatchmakingModule.Bets[ctx.Member.Id.ToString()] + " SquidCoin has been removed."); MatchmakingModule.Bets.Remove(ctx.Member.Id.ToString()); } await MatchmakingModule.ChangeNameIfRelevant(ctx.Member); await MatchmakingModule.JoinQueue(ctx, ctx.Member); }