Skip to content

Commit

Permalink
Added detecting for log uploader's account name
Browse files Browse the repository at this point in the history
Added base files for Healing stats plugin for arcpds
  • Loading branch information
Plenyx committed Feb 21, 2024
1 parent a0de944 commit 62dab77
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 50 deletions.
2 changes: 2 additions & 0 deletions DpsReport/DpsReportJsonExtraJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ internal Dictionary<Player, int> GetPlayerTargetDPS()
}
return dict;
}

internal string RecordedByAccountName => Players.FirstOrDefault(x => x.Name == RecordedBy)?.Account ?? RecordedBy;
}
}
6 changes: 6 additions & 0 deletions DpsReport/ExtraJSON/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ internal sealed class Player

[JsonProperty("defenses")]
internal Defenses[] Defenses { get; set; }

[JsonProperty("statsHealing")]
internal StatsHealing StatsHealing { get; set; }

[JsonProperty("statsBarrier")]
internal StatsBarrier StatsBarrier { get; set; }
}
}
10 changes: 10 additions & 0 deletions DpsReport/ExtraJSON/StatsBarrier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace PlenBotLogUploader.DpsReport.ExtraJson
{
internal class StatsBarrier
{
[JsonProperty("outgoingBarrier")]
internal StatsBarrierOutgoingBarrier OutgoingBarrier { get; set; }
}
}
13 changes: 13 additions & 0 deletions DpsReport/ExtraJSON/StatsBarrierOutgoingBarrier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Newtonsoft.Json;

namespace PlenBotLogUploader.DpsReport.ExtraJson
{
internal class StatsBarrierOutgoingBarrier
{
[JsonProperty("barrier")]
internal long Barrier { get; set; }

[JsonProperty("bps")]
internal long BarrierPerSecond { get; set; }
}
}
10 changes: 10 additions & 0 deletions DpsReport/ExtraJSON/StatsHealing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace PlenBotLogUploader.DpsReport.ExtraJson
{
internal class StatsHealing
{
[JsonProperty("outgoingHealing")]
internal StatsHealingOutgoingHealing[] OutgoingHealing;

Check warning on line 8 in DpsReport/ExtraJSON/StatsHealing.cs

View workflow job for this annotation

GitHub Actions / build

Field 'StatsHealing.OutgoingHealing' is never assigned to, and will always have its default value null

Check warning on line 8 in DpsReport/ExtraJSON/StatsHealing.cs

View workflow job for this annotation

GitHub Actions / build

Field 'StatsHealing.OutgoingHealing' is never assigned to, and will always have its default value null

Check warning on line 8 in DpsReport/ExtraJSON/StatsHealing.cs

View workflow job for this annotation

GitHub Actions / build

Field 'StatsHealing.OutgoingHealing' is never assigned to, and will always have its default value null
}
}
13 changes: 13 additions & 0 deletions DpsReport/ExtraJSON/StatsHealingOutgoingHealing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Newtonsoft.Json;

namespace PlenBotLogUploader.DpsReport.ExtraJson
{
internal class StatsHealingOutgoingHealing
{
[JsonProperty("healing")]
internal long Healing { get; set; }

[JsonProperty("hps")]
internal long HealingPerSecond { get; set; }
}
}
4 changes: 2 additions & 2 deletions Forms/FormDiscordWebhooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal async Task ExecuteAllActiveWebhooksAsync(DpsReportJson reportJSON, List
if (reportJSON.Encounter.BossId.Equals(1)) // WvW
{
var extraJSONFightName = (reportJSON.ExtraJson is null) ? reportJSON.Encounter.Boss : reportJSON.ExtraJson.FightName;
var extraJSON = (reportJSON.ExtraJson is null) ? "" : $"Recorded by: {reportJSON.ExtraJson.RecordedBy}\nDuration: {reportJSON.ExtraJson.Duration}\nElite Insights version: {reportJSON.ExtraJson.EliteInsightsVersion}";
var extraJSON = (reportJSON.ExtraJson is null) ? "" : $"Recorded by: {reportJSON.ExtraJson.RecordedByAccountName}\nDuration: {reportJSON.ExtraJson.Duration}\nElite Insights version: {reportJSON.ExtraJson.EliteInsightsVersion}";
var icon = "";
var bossData = Bosses.GetBossDataFromId(1);
if (bossData is not null)
Expand Down Expand Up @@ -295,7 +295,7 @@ internal async Task ExecuteAllActiveWebhooksAsync(DpsReportJson reportJSON, List
var bossName = $"{reportJSON.Encounter.Boss}{(reportJSON.ChallengeMode ? " CM" : "")}";
var successString = (reportJSON.Encounter.Success ?? false) ? ":white_check_mark:" : "";
var lastTarget = (reportJSON?.ExtraJson?.PossiblyLastTarget is not null) ? $"\n{reportJSON.ExtraJson.PossiblyLastTarget.Name} ({Math.Round(100 - reportJSON.ExtraJson.PossiblyLastTarget.HealthPercentBurned, 2)}%)" : "";
var extraJSON = (reportJSON.ExtraJson is null) ? "" : $"Recorded by: {reportJSON.ExtraJson.RecordedBy}\nDuration: {reportJSON.ExtraJson.Duration}{lastTarget}\nElite Insights version: {reportJSON.ExtraJson.EliteInsightsVersion}\n";
var extraJSON = (reportJSON.ExtraJson is null) ? "" : $"Recorded by: {reportJSON.ExtraJson.RecordedByAccountName}\nDuration: {reportJSON.ExtraJson.Duration}{lastTarget}\nElite Insights version: {reportJSON.ExtraJson.EliteInsightsVersion}\n";
var icon = "";
var bossData = Bosses.GetBossDataFromId(reportJSON.Encounter.BossId);
if (bossData is not null)
Expand Down
2 changes: 1 addition & 1 deletion Forms/FormLogSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void ButtonSessionStarter_Click(object sender, EventArgs e)
{
var success = (reportJSON.Encounter.Success ?? false) ? "true" : "false";
File.AppendAllText($"{ApplicationSettings.LocalDir}{fileName}.csv",
$"{reportJSON.ExtraJson?.FightName ?? reportJSON.Encounter.Boss};{reportJSON.Encounter.BossId};{success};{reportJSON.ExtraJson?.Duration ?? ""};{reportJSON.ExtraJson?.RecordedBy ?? ""};{reportJSON.ExtraJson?.EliteInsightsVersion ?? ""};{reportJSON.Evtc.Type}{reportJSON.Evtc.Version};{reportJSON.ConfigAwarePermalink};{reportJSON.UserToken}\n");
$"{reportJSON.ExtraJson?.FightName ?? reportJSON.Encounter.Boss};{reportJSON.Encounter.BossId};{success};{reportJSON.ExtraJson?.Duration ?? ""};{reportJSON.ExtraJson?.RecordedByAccountName ?? ""};{reportJSON.ExtraJson?.EliteInsightsVersion ?? ""};{reportJSON.Evtc.Type}{reportJSON.Evtc.Version};{reportJSON.ConfigAwarePermalink};{reportJSON.UserToken}\n");
}
_ = SendSessionWebhooks(logSessionSettings);
}
Expand Down
2 changes: 1 addition & 1 deletion Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
try
{
// log file
File.AppendAllText($"{ApplicationSettings.LocalDir}uploaded_logs.csv", $"{reportJson.ExtraJson?.FightName ?? reportJson.Encounter.Boss};{bossId};{success};{reportJson.ExtraJson?.Duration ?? ""};{reportJson.ExtraJson?.RecordedBy ?? ""};{reportJson.ExtraJson?.EliteInsightsVersion ?? ""};{reportJson.Evtc.Type}{reportJson.Evtc.Version};{reportJson.ConfigAwarePermalink};{reportJson.UserToken}\n");
File.AppendAllText($"{ApplicationSettings.LocalDir}uploaded_logs.csv", $"{reportJson.ExtraJson?.FightName ?? reportJson.Encounter.Boss};{bossId};{success};{reportJson.ExtraJson?.Duration ?? ""};{reportJson.ExtraJson?.RecordedByAccountName ?? ""};{reportJson.ExtraJson?.EliteInsightsVersion ?? ""};{reportJson.Evtc.Type}{reportJson.Evtc.Version};{reportJson.ConfigAwarePermalink};{reportJson.UserToken}\n");
}
catch (Exception e)
{
Expand Down
95 changes: 49 additions & 46 deletions Tools/SessionTextConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
.Where(x => Bosses.All
.Any(y => y.BossId.Equals(x.Evtc.BossId) && y.Type.Equals(BossType.Golem)))
.ToArray();
var wvWLogs = reportsJSON
var wvwLogs = reportsJSON
.Where(x => Bosses.All
.Any(y => y.BossId.Equals(x.Evtc.BossId) && y.Type.Equals(BossType.WvW)))
.ToArray();
Expand All @@ -79,9 +79,9 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
.ToArray();

var durationText = $"Session duration: **{logSessionSettings.ElapsedTime}**";
var builderSuccessFailure = ((wvWLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
var builderSuccess = ((wvWLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
var builderFailure = ((wvWLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
var builderSuccessFailure = ((wvwLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
var builderSuccess = ((wvwLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
var builderFailure = ((wvwLogs.Length > 0) && logSessionSettings.MakeWvWSummaryEmbed) ? new StringBuilder() : new StringBuilder($"{durationText}\n\n");
int messageSuccessFailureCount = 0, messageSuccessCount = 0, messageFailureCount = 0;

if (raidLogs.Length > 0)
Expand Down Expand Up @@ -401,18 +401,18 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
}
}
}
if (wvWLogs.Length > 0)
if (wvwLogs.Length > 0)
{
if (logSessionSettings.MakeWvWSummaryEmbed)
{
var totalEnemyKills = wvWLogs.Select(x =>
var totalEnemyKills = wvwLogs.Select(x =>
x.ExtraJson?.Players
.Where(y => !y.FriendlyNpc && !y.NotInSquad)
.Select(y => y.StatsTargets.Select(z => z[0].Killed).Sum())
.Sum()
?? 0)
.Sum();
var totalSquadDeaths = wvWLogs.Select(x =>
var totalSquadDeaths = wvwLogs.Select(x =>
x.ExtraJson?.Players
.Where(y => !y.FriendlyNpc && !y.NotInSquad)
.Select(y => y.Defenses[0].DeadCount)
Expand All @@ -422,54 +422,57 @@ internal static DiscordEmbeds ConstructSessionEmbeds(List<DpsReportJson> reports
discordEmbedSummary = MakeEmbedFromText($"{logSessionSettings.Name} - WvW Summary", $"{durationText}\n\n" +
$"Total kills: **{totalEnemyKills}**\nTotal kills per minute: **{Math.Round(totalEnemyKills / logSessionSettings.ElapsedTimeSpan.TotalMinutes, 3).ToString(CultureInfo.InvariantCulture.NumberFormat)}**\n\n" +
$"Total squad deaths: **{totalSquadDeaths}**\nTotal squad deaths per minute: **{Math.Round(totalSquadDeaths / logSessionSettings.ElapsedTimeSpan.TotalMinutes, 3).ToString(CultureInfo.InvariantCulture.NumberFormat)}**\n\n" +
$"Kill Death Ratio:: **{Math.Round((double)(totalEnemyKills / totalSquadDeaths), 2).ToString(CultureInfo.InvariantCulture.NumberFormat)}**");
$"Kill Death Ratio: **{Math.Round((double)(totalEnemyKills / totalSquadDeaths), 2).ToString(CultureInfo.InvariantCulture.NumberFormat)}**");
discordEmbedSummary.Thumbnail = defaultWvWSummaryThumbnail;
}
if (!builderSuccessFailure.ToString().EndsWith("***\n"))
{
builderSuccessFailure.Append("\n\n");
}
if (!builderSuccess.ToString().EndsWith("***\n"))
{
builderSuccess.Append("\n\n");
}
if (!builderFailure.ToString().EndsWith("***\n"))
if (logSessionSettings.EnableWvWLogList)
{
builderFailure.Append("\n\n");
}
builderSuccessFailure.Append("***WvW logs:***\n");
builderSuccess.Append("***WvW logs:***\n");
builderFailure.Append("***WvW logs:***\n");
foreach (var log in wvWLogs.AsSpan())
{
builderSuccessFailure.Append(log.ConfigAwarePermalink).Append('\n');
if (builderSuccessFailure.Length >= maxAllowedMessageSize)
if (!builderSuccessFailure.ToString().EndsWith("***\n"))
{
messageSuccessFailureCount++;
discordEmbedsSuccessFailure.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageSuccessFailureCount > 1) ? $" part {messageSuccessFailureCount}" : ""), builderSuccessFailure.ToString()));
builderSuccessFailure.Clear();
builderSuccessFailure.Append("***WvW logs:***\n");
builderSuccessFailure.Append("\n\n");
}
if (log.Encounter.Success ?? false)
if (!builderSuccess.ToString().EndsWith("***\n"))
{
builderSuccess.Append(log.ConfigAwarePermalink).Append('\n');
if (builderSuccess.Length >= maxAllowedMessageSize)
{
messageSuccessCount++;
discordEmbedsSuccess.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageSuccessCount > 1) ? $" part {messageSuccessCount}" : ""), builderSuccess.ToString()));
builderSuccess.Clear();
builderSuccess.Append("***WvW logs:***\n");
}
builderSuccess.Append("\n\n");
}
else
if (!builderFailure.ToString().EndsWith("***\n"))
{
builderFailure.Append(log.ConfigAwarePermalink).Append('\n');
if (builderFailure.Length >= maxAllowedMessageSize)
builderFailure.Append("\n\n");
}
builderSuccessFailure.Append("***WvW logs:***\n");
builderSuccess.Append("***WvW logs:***\n");
builderFailure.Append("***WvW logs:***\n");
foreach (var log in wvwLogs.AsSpan())
{
builderSuccessFailure.Append(log.ConfigAwarePermalink).Append('\n');
if (builderSuccessFailure.Length >= maxAllowedMessageSize)
{
messageFailureCount++;
discordEmbedsFailure.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageFailureCount > 1) ? $" part {messageFailureCount}" : ""), builderFailure.ToString()));
builderFailure.Clear();
builderFailure.Append("***WvW logs:***\n");
messageSuccessFailureCount++;
discordEmbedsSuccessFailure.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageSuccessFailureCount > 1) ? $" part {messageSuccessFailureCount}" : ""), builderSuccessFailure.ToString()));
builderSuccessFailure.Clear();
builderSuccessFailure.Append("***WvW logs:***\n");
}
if (log.Encounter.Success ?? false)
{
builderSuccess.Append(log.ConfigAwarePermalink).Append('\n');
if (builderSuccess.Length >= maxAllowedMessageSize)
{
messageSuccessCount++;
discordEmbedsSuccess.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageSuccessCount > 1) ? $" part {messageSuccessCount}" : ""), builderSuccess.ToString()));
builderSuccess.Clear();
builderSuccess.Append("***WvW logs:***\n");
}
}
else
{
builderFailure.Append(log.ConfigAwarePermalink).Append('\n');
if (builderFailure.Length >= maxAllowedMessageSize)
{
messageFailureCount++;
discordEmbedsFailure.Add(MakeEmbedFromText(logSessionSettings.Name + ((messageFailureCount > 1) ? $" part {messageFailureCount}" : ""), builderFailure.ToString()));
builderFailure.Clear();
builderFailure.Append("***WvW logs:***\n");
}
}
}
}
Expand Down

0 comments on commit 62dab77

Please sign in to comment.