public async Task FightAsync(CommandContext ctx, [Description("desc-member")] DiscordMember member) { if (ctx.Services.GetRequiredService <ChannelEventService>().IsEventRunningInChannel(ctx.Channel.Id, out ChickenWar _)) { throw new CommandFailedException(ctx, "cmd-err-chicken-war"); } if (member == ctx.User) { throw new CommandFailedException(ctx, "cmd-err-chicken-self"); } Chicken?c1 = await this.Service.GetCompleteAsync(ctx.Guild.Id, ctx.User.Id); if (c1 is null) { throw new CommandFailedException(ctx, "cmd-err-chicken-none"); } c1.Owner = ctx.User; if (c1.Stats.TotalVitality < Chicken.MinVitalityToFight) { throw new CommandFailedException(ctx, "cmd-err-chicken-weak", ctx.User.Mention); } Chicken?c2 = await this.Service.GetCompleteAsync(ctx.Guild.Id, member.Id); if (c2 is null) { throw new CommandFailedException(ctx, "cmd-err-chicken-404", member.Mention); } c2.Owner = member; if (c1.IsTooStrongFor(c2)) { throw new CommandFailedException(ctx, "cmd-err-chicken-strdiff", Chicken.MaxFightStrDiff); } var res = ChickenFightResult.Fight(c1, c2); await this.Service.UpdateAsync(res); await ctx.Services.GetRequiredService <BankAccountService>().IncreaseBankAccountAsync(ctx.Guild.Id, res.Winner.UserId, res.Reward); await ctx.RespondWithLocalizedEmbedAsync(emb => { emb.WithColor(this.ModuleColor); var desc = new StringBuilder(); desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-h", Emojis.Chicken, c1.Name, c1.Stats.ToShortString(), Emojis.DuelSwords, c2.Name, c2.Stats.ToShortString(), Emojis.Chicken )).AppendLine(); desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-w", Emojis.Trophy, res.Winner.Name)).AppendLine(); desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-gain", res.Winner.Name, res.StrGain)); if (res.IsLoserDead) { desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-d", res.Loser.Name)); } else { desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-loss", res.Loser.Name, ChickenFightResult.VitLoss)); } desc.AppendLine(); string currency = ctx.Services.GetRequiredService <GuildConfigService>().GetCachedConfig(ctx.Guild.Id).Currency; desc.AppendLine(this.Localization.GetString(ctx.Guild.Id, "fmt-chicken-fight-rew", res.Winner.Owner?.Mention, res.Reward, currency)); emb.WithDescription(desc); }); }