Skip to content

Commit

Permalink
Added support for legendary CM recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
Plenyx committed Mar 24, 2024
1 parent b2d277c commit e73c02f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
17 changes: 16 additions & 1 deletion DpsReport/BossData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using PlenBotLogUploader.Tools;
using System;
using System.Collections.Generic;
using System.Text;

namespace PlenBotLogUploader.DpsReport
{
Expand Down Expand Up @@ -70,6 +71,20 @@ internal sealed class BossData : IListViewItemInfo<BossData>

List<ListViewItemCustom<BossData>> IListViewItemInfo<BossData>.ConnectedItems => _connectedItems;

internal string FightName(DpsReportJson reportJSON)
{
var builder = new StringBuilder(Name);
if (reportJSON.ChallengeMode)
{
if (reportJSON?.ExtraJson?.IsLegendaryCm ?? false)
{
builder.Append("Legendary ");
}
builder.Append("CM");
}
return builder.ToString();
}

/// <summary>
/// Formats Twitch message based on the DPSReport's JSON response.
/// </summary>
Expand All @@ -78,7 +93,7 @@ internal sealed class BossData : IListViewItemInfo<BossData>
internal string TwitchMessageFormat(DpsReportJson reportJSON, int pullCounter)
{
var format = (reportJSON.Encounter.Success ?? false) ? SuccessMsg : FailMsg;
format = format.Replace("<boss>", reportJSON.ChallengeMode ? $"{Name} CM" : Name);
format = format.Replace("<boss>", FightName(reportJSON));
format = format.Replace("<log>", reportJSON.ConfigAwarePermalink);
format = format.Replace("<pulls>", pullCounter.ToString());
format = (reportJSON.ExtraJson?.PossiblyLastTarget is not null)
Expand Down
32 changes: 31 additions & 1 deletion DpsReport/DpsReportJsonExtraJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,37 @@ internal sealed class DpsReportJsonExtraJson
[JsonProperty("players")]
internal Player[] Players { get; set; }

internal Target PossiblyLastTarget => Targets.OrderByDescending(x => x.TotalHealth).FirstOrDefault(x => x.HealthPercentBurned <= 98.6);
internal Target PossiblyLastTarget
{
get
{
if (TriggerId == (int)BossIds.Cerus)
{
return TargetsByTotalHealth.FirstOrDefault();
}
return TargetsByTotalHealth.FirstOrDefault(x => x.HealthPercentBurned <= 98.6);
}
}

private Target[] TargetsByTotalHealth => Targets.OrderByDescending(x => x.TotalHealth).ToArray();


internal bool IsLegendaryCm
{
get
{
if (TriggerId != (int)BossIds.Cerus)
{
return false;
}
var cerus = TargetsByTotalHealth.FirstOrDefault();
if (cerus is null)
{
return false;
}
return cerus.TotalHealth >= 120_000_000;
}
}

internal Dictionary<Player, int> GetPlayerTargetDPS()
{
Expand Down
2 changes: 1 addition & 1 deletion DpsReport/ExtraJSON/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal sealed class Target
internal Defenses[] Defenses { get; set; }

[JsonProperty("totalHealth")]
internal int TotalHealth { get; set; }
internal long TotalHealth { get; set; }

[JsonProperty("healthPercentBurned")]
internal double HealthPercentBurned { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Forms/FormDiscordWebhooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ internal async Task ExecuteAllActiveWebhooksAsync(DpsReportJson reportJSON, List
var bossData = Bosses.GetBossDataFromId(reportJSON.Encounter.BossId);
if (bossData is not null)
{
bossName = bossData.Name + (reportJSON.ChallengeMode ? " CM" : "");
bossName = bossData.FightName(reportJSON);
icon = bossData.Icon;
}
var colour = (reportJSON.Encounter.Success ?? false) ? 32768 : 16711680;
Expand Down
8 changes: 4 additions & 4 deletions Tools/SessionTextConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
var bossData = Bosses.GetBossDataFromId(data.LogData.Encounter.BossId);
if (bossData is not null)
{
bossName = bossData.Name + (data.LogData.ChallengeMode ? " CM" : "");
bossName = bossData.FightName(data.LogData);
}
var duration = (data.LogData.ExtraJson is null) ? "" : $" {data.LogData.ExtraJson.Duration}";
string successText = "";
Expand Down Expand Up @@ -159,7 +159,7 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
var bossData = Bosses.GetBossDataFromId(data.LogData.Encounter.BossId);
if (bossData is not null)
{
bossName = bossData.Name + (data.LogData.ChallengeMode ? " CM" : "");
bossName = bossData.FightName(data.LogData);
}
var duration = (data.LogData.ExtraJson is null) ? "" : $" {data.LogData.ExtraJson.Duration}";
string successText = "";
Expand Down Expand Up @@ -231,7 +231,7 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
var bossData = Bosses.GetBossDataFromId(log.Encounter.BossId);
if (bossData is not null)
{
bossName = bossData.Name + (log.ChallengeMode ? " CM" : "");
bossName = bossData.FightName(log);
}
var duration = (log.ExtraJson is not null) ? $" {log.ExtraJson.Duration}" : "";
string successText = "";
Expand Down Expand Up @@ -302,7 +302,7 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
var bossData = Bosses.GetBossDataFromId(log.Encounter.BossId);
if (bossData is not null)
{
bossName = bossData.Name + (log.ChallengeMode ? " CM" : "");
bossName = bossData.FightName(log);
}
var duration = (log.ExtraJson is not null) ? $" {log.ExtraJson.Duration}" : "";
string successText = "";
Expand Down

0 comments on commit e73c02f

Please sign in to comment.