Esempio n. 1
0
    public async Task SendGangInfo([Remainder] string gang)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        LeaderboardUtils.GangInfo gInfo = await LeaderboardUtils.GetGangInfo(HttpUtility.UrlEncode(gang));

        Console.WriteLine(gInfo.gangOwner);

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText($"Called by {Context.Message.Author.Username}");
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"{gInfo.gangName}");
        eb.AddField("Owner", $"{gInfo.gangOwner}");
        eb.AddField("Member Count", $"{gInfo.memberCount}");
        eb.AddField("Cash", $"{gInfo.gangCash}");
        eb.AddField("Loot", $"{gInfo.gangLoot}");
        if (gInfo.gangIcon.Contains("imgur"))
        {
            eb.WithThumbnailUrl(gInfo.gangIcon);
        }
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);

        await ReplyAsync("", false, eb.Build());

        await Utilities.StatusMessage("ganginfo", Context);
    }
Esempio n. 2
0
        public static async Task <WinCheckResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage entityRequest, HttpRequest httpRequest,
            ILogger log)
        {
            // Extract the context from the incoming request
            var context = await FunctionContext <PlayFabIdRequest> .Create(entityRequest);

            string playFabId = context.FunctionArgument.PlayFabId;

            Settings.TrySetSecretKey(context.ApiSettings);
            Settings.TrySetCloudName(context.ApiSettings);

            // Grab the current player's game state
            var state = await GameStateUtil.GetCurrentGameState(playFabId, context.ApiSettings, context.AuthenticationContext);

            var winCheckResult = WinCheckUtil.Check(state);

            if (winCheckResult.Winner != GameWinnerType.NONE)
            {
                // Update the leaderboard accordingly
                await LeaderboardUtils.UpdateLeaderboard(playFabId, winCheckResult.Winner);

                // Store the game history
                await GameStateUtil.AddGameStateHistory(state, playFabId, context.ApiSettings, context.AuthenticationContext);

                // Clear the current game state
                await GameStateUtil.UpdateCurrentGameState(new TicTacToeState(), playFabId, context.ApiSettings, context.AuthenticationContext);
            }



            return(winCheckResult);
        }
Esempio n. 3
0
    public async Task SendLeaderboards(string board, string category = null, string player = null)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        var msg = await ReplyAsync("Obtaining data");

        try
        {
            List <LeaderboardUtils.BoardInfo> bList = LeaderboardUtils.GetList(await LeaderboardUtils.GetBoard(board, player, category), player);

            string bName = board;

            foreach (LeaderboardUtils.Boards b in LeaderboardUtils.boards)
            {
                foreach (string alias in b.aliases)
                {
                    if (alias == board)
                    {
                        bName = b.name;
                    }
                }
            }

            EmbedBuilder       eb = new EmbedBuilder();
            EmbedFooterBuilder fb = new EmbedFooterBuilder();


            fb.WithText($"Called by {Context.Message.Author.Username}");
            fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

            eb.WithTitle($"{bName}");
            eb.WithColor(Color.Blue);
            eb.WithFooter(fb);

            foreach (LeaderboardUtils.BoardInfo b in bList)
            {
                eb.AddField($"{b.position}. {b.name}", $"{b.stat}");
            }

            await ReplyAsync("", false, eb.Build());

            await msg.DeleteAsync();

            await Utilities.StatusMessage("leaderboards", Context);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            await ReplyAsync("Either this board doesn't exist or this player doesn't meet the requirements.");

            await msg.DeleteAsync();

            await Utilities.StatusMessage("leaderboards", Context);

            return;
        }
    }