internal static LocalisedEmbedBuilder StatsBuilder(SocketSelfUser me, int clanLevel, int?avgMS = null, int?tpCQ = null, int[] attackers = null) { attackers = (attackers?.Count() ?? 0) == 0 ? new int[] { 20, 30, 40, 50 } : attackers; var averageMS = avgMS ?? 4000; var tapsPerCq = tpCQ ?? 600; var absLevel = Math.Abs(clanLevel); var currentBonus = Calculator.ClanBonus(absLevel); var nextBonus = Calculator.ClanBonus(absLevel + 1); var nextTitanLordHp = Calculator.TitanLordHp(absLevel); var advanceStart = Calculator.AdvanceStart(absLevel); var builder = new LocalisedEmbedBuilder { Footer = new EmbedFooterBuilder { IconUrl = me.GetAvatarUrl(), Text = me.Username + "#" + me.Discriminator }, Color = System.Drawing.Color.DarkOrange.ToDiscord(), Timestamp = DateTime.Now }; builder.WithTitle(ClanStatsText.TITLE, clanLevel) .AddInlineField(f => f.WithName(ClanStatsText.FIELD_CQ).WithValue(absLevel)) .AddInlineField(f => f.WithName(ClanStatsText.FIELD_BONUS_CURRENT).WithValue(BonusType.ClanDamage.ToLocalisable(currentBonus))) .AddInlineField(f => f.WithName(ClanStatsText.FIELD_BONUS_NEXT).WithValue(BonusType.ClanDamage.ToLocalisable(nextBonus))) .AddInlineField(f => f.WithName(ClanStatsText.FIELD_HP).WithValue(nextTitanLordHp)) .AddInlineField(f => f.WithName(ClanStatsText.FIELD_ADVSTART).WithValue(advanceStart)); LocalisedString[] rows = attackers.Select(num => { var dmgpp = nextTitanLordHp / num; var attacks = Calculator.AttacksNeeded(absLevel, num, averageMS, tapsPerCq); var dia = Calculator.TotalAttackCost(attacks); return(new LocalisedString(ClanStatsText.FIELD_ATTACKERS_ROW, num, dmgpp, attacks, dia)); }).ToArray(); builder.AddField(f => f.WithName(ClanStatsText.FIELD_ATTACKERS, averageMS, tapsPerCq) .WithValues("\n", rows)); return(builder); }
protected async Task ListSettingsAsync(string settingGroup = null) { var builder = new LocalisedEmbedBuilder { Color = new Color(135, 206, 235), //System.Drawing.Color.SkyBlue.ToDiscord(), Timestamp = DateTime.Now, Footer = new LocalisedFooterBuilder().WithRawIconUrl(BotUser.GetAvatarUrl()) .WithText(SettingText.FOOTERTEXT, BotUser.Username) }; if (Settings.Count == 1) { settingGroup = Settings.First().Name; } if (settingGroup == null) { builder.WithTitle(SettingText.TITLE_NOGROUP); var desc = string.Join("\n", Settings.Select(g => g.Name)); if (string.IsNullOrWhiteSpace(desc)) { builder.WithDescription(SettingText.DESCRIPTION_NOSETTINGS); } else { builder.WithRawDescription(desc); } await ReplyAsync(builder); return; } var groups = Settings.Where(g => g.Name.ToLower() == settingGroup.ToLower()).ToList(); if (groups.Count() == 0) { await ReplyAsync(SettingText.INVALIDGROUP, ReplyType.Error, settingGroup); return; } builder.WithTitle(SettingText.TITLE_GROUP, groups.First().Name); foreach (var setting in groups.SelectMany(s => s)) { var value = setting.Display(Context, SettingContext); if (value == null) { builder.AddInlineField(f => f.WithRawName(setting.Name).WithValue(SettingText.NOTSET)); } else { builder.AddInlineField(f => f.WithRawName(setting.Name).WithValue(value)); } } var descriptions = LocalisedString.JoinEnumerable("\n", groups.Where(g => g.Description != null).Select(g => g.Description)); var notes = LocalisedString.JoinEnumerable("\n", groups.Where(g => g.Notes != null).Select(g => g.Notes)); if (groups.Exists(g => g.Description != null)) { builder.WithDescription(descriptions); } if (groups.Exists(g => g.Notes != null)) { builder.AddField(f => f.WithName(TBLocalisation.NOTES).WithValue(notes)); } await ReplyAsync(builder); }