예제 #1
0
 public Player(string ID, string username, string discrim, bool won, byte ranking, int cardsPlayed = 0, string team = "")
 {
     this.ID              = ID;
     this.name            = username + "#" + discrim;
     this.won             = won;
     this.ranking         = ranking;
     this.noOfCardsPlayed = cardsPlayed;
     if (team == "")
     {
         team = GuildCache.GetTeam(GuildCache.GetUserByID(UInt64.Parse(ID))) ?? "?";
     }
     else
     {
         this.team = team;
     }
 }
예제 #2
0
        public Embed GetEmbed(bool includeBadges = false)
        {
            EmbedBuilder emb = new EmbedBuilder();

            GetPlacements();
            if (stats.ContainsKey("LIT-TEAM"))
            {
                if (stats["LIT-TEAM"] == TEAM_ONE_ID.ToString())
                {
                    emb.WithColor(255, 179, 186);
                }
                else if (stats["LIT-TEAM"] == TEAM_TWO_ID.ToString())
                {
                    emb.WithColor(8, 255, 0);
                }
                else if (stats["LIT-TEAM"] == WILD_ID.ToString())
                {
                    emb.WithColor(0, 0, 0);
                }
                else
                {
                    var team = GuildCache.GetTeam(USER_ID);
                    if (team == TEAM_ONE_ID.ToString())
                    {
                        emb.WithColor(255, 179, 186);
                    }
                    else if (team == TEAM_TWO_ID.ToString())
                    {
                        emb.WithColor(8, 255, 0);
                    }
                    else if (team == WILD_ID.ToString())
                    {
                        emb.WithColor(0, 0, 0);
                    }
                    else
                    {
                        emb.WithColor(178, 178, 178);
                    }
                }
            }

            if (stats.ContainsKey("LIT-CUSTOMCOLOR"))
            {
                var hexColor = stats["LIT-CUSTOMCOLOR"];
                if (hexColor != "-" && Int32.TryParse(hexColor, System.Globalization.NumberStyles.HexNumber, null, out int ignore))
                {
                    if (Int32.Parse(hexColor, System.Globalization.NumberStyles.HexNumber) < 0xFFFFFF)
                    {
                        emb.WithColor(Byte.Parse(hexColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber),
                                      Byte.Parse(hexColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber), Byte.Parse(hexColor.Substring(4, 2),
                                                                                                                                    System.Globalization.NumberStyles.HexNumber));
                    }
                }
            }

            var url = GuildCache.GetUserByID(USER_ID)?.GetAvatarUrl();

            emb.WithThumbnailUrl(url);
            StringBuilder toBeEarned = new StringBuilder();

            foreach (var stat in stats)
            {
                if (!stat.Key.StartsWith("LIT"))
                {
                    if (placement.ContainsKey(stat.Key))
                    {
                        if (stat.Value == "0")
                        {
                            string add = RemoveEmojis(desiredFields[stat.Key]);
                            toBeEarned.Append(", " + add);
                            continue;
                        }
                        //emb.AddField(desiredFields[stat.Key], stat.Value + "(" + (placement[stat.Key] + 1) + "th)",true);
                        emb.AddField(desiredFields[stat.Key], stat.Value, true);
                    }
                    else
                    {
                        if (stat.Value == "0")
                        {
                            string add = RemoveEmojis(desiredFields[stat.Key]);
                            toBeEarned.Append(", " + add);
                            continue;
                        }
                        emb.AddField(desiredFields[stat.Key], stat.Value, true);
                    }
                }
            }

            string tBE = toBeEarned.ToString();

            if (tBE.Length > 1)
            {
                emb.WithFooter("Still to be earned: " + tBE.Substring(1));
            }

            return(emb.Build());
        }