Esempio n. 1
0
        public static string ViewGames(GameManager gameManager, int page = 0, ArcadeUser user = null)
        {
            var result = new StringBuilder();

            bool allowTooltips = user?.Config?.Tooltips ?? true;

            if (allowTooltips)
            {
                result.AppendLine($"{Format.Tooltip("Type `game <game_id>` to learn more about a game.")}\n");
            }


            int pageCount = Paginate.GetPageCount(gameManager.Games.Count, 5);

            page = Paginate.ClampIndex(page, pageCount);

            string extra = pageCount > 1 ? $" ({Format.PageCount(page + 1, pageCount)})" : "";


            result.AppendLine($"> **Games**{extra}");

            foreach (GameBase game in Paginate.GroupAt(gameManager.Games.Values, page, 8))
            {
                string id = game.Details.Name.Equals(game.Id, StringComparison.OrdinalIgnoreCase) ? "" : $"`{game.Id}` ";
                result.AppendLine($"> {id}{Format.Title(game.Details.Name, game.Details.Icon)} ({(game.Details.RequiredPlayers == game.Details.PlayerLimit ? $"**{game.Details.RequiredPlayers}**" : $"**{game.Details.RequiredPlayers}** to **{game.Details.PlayerLimit}**")} players)");
            }
Esempio n. 2
0
        public static string WriteFor(ArcadeUser user, string query, int page = 0, int pageSize = 15)
        {
            VarGroup group = Var.GetGroupDefiner(query);

            if (group == null)
            {
                return(Format.Warning("Unable to find the specified stat group."));
            }

            var result = new StringBuilder();

            if (group.Writer != null)
            {
                result.AppendLine($"> **Stats: {group.Name}**");
                result.AppendLine(group.Writer.Invoke(user));
                return(result.ToString());
            }

            var stats     = GetGroupStats(user, group.Id).ToList();
            int pageCount = Paginate.GetPageCount(stats.Count, pageSize);

            page = Paginate.ClampIndex(page, pageCount);

            string counter = null;

            if (pageCount > 1)
            {
                counter = $" ({Format.PageCount(page + 1, pageCount)})";
            }

            result.AppendLine($"> **Stats: {group.Name}**{counter}");

            int i = 0;

            foreach ((string id, long value) in Paginate.GroupAt(stats, page, pageSize))
            {
                if (i >= pageSize)
                {
                    break;
                }

                result.AppendLine($"`{id}`: {value}");
                i++;
            }

            if (i == 0)
            {
                result.AppendLine("An invalid group was specified or an unknown error has occurred.");
            }

            return(result.ToString());
        }
Esempio n. 3
0
        public static string View(int page = 0)
        {
            var info = new StringBuilder();

            info.AppendLine("> 📚 **Guides**");
            info.AppendLine("> Learn more about the mechanics **Orikivo Arcade** uses.");

            if (!Assets.Guides.Any())
            {
                info.AppendLine("\nThere aren't any guides available yet. Stay tuned!");
            }
            else
            {
                foreach (Guide guide in Paginate.GroupAt(Assets.Guides, page, _pageSize))
                {
                    info.AppendLine($"\n> `{guide.Id}`\n> {guide.Icon} **{guide.Title}** (**{guide.Pages.Count}** {Format.TryPluralize("page", guide.Pages.Count)})");
                    info.AppendLine($"> {guide.Summary}");
                }
            }

            return(info.ToString());
        }