Skip to content
Browse files

Added Healing and Threat to ability count model

  • Loading branch information...
1 parent cb24baa commit 5a6f6ea6b4ef740d3558c35ff1e1f6e69bbd8217 @trayburn committed Apr 10, 2012
View
111 src/SWTOR.Parser.Tests/CombatParserTests.cs
@@ -151,6 +151,90 @@ public void SetUp()
}
[TestMethod]
+ public void Given_One_Combat_When_Parse_Then_Threat_In_AbilityCounts()
+ {
+ // Arrange
+ h.EnterCombat(player).Tick()
+ .Heal(player, player, "SmallHeal", 250).Tick()
+ .Heal(player, player, "BigHeal", 2000).Tick()
+ .Heal(player, player, "SmallHeal", 750)
+ .ExitCombat(player);
+
+ // Act
+ var res = target.Parse(log);
+
+ // Assert
+ Assert.AreEqual(2, res.AbilityMetrics[0].Count);
+ Assert.AreEqual("SmallHeal", res.AbilityMetrics[0].Name);
+ Assert.AreEqual(500.0, res.AbilityMetrics[0].AverageThreat);
+ Assert.AreEqual(250, res.AbilityMetrics[0].MinimumThreat);
+ Assert.AreEqual(750, res.AbilityMetrics[0].MaximumThreat);
+
+ Assert.AreEqual(1, res.AbilityMetrics[1].Count);
+ Assert.AreEqual("BigHeal", res.AbilityMetrics[1].Name);
+ Assert.AreEqual(2000.00, res.AbilityMetrics[1].AverageThreat);
+ Assert.AreEqual(2000, res.AbilityMetrics[1].MinimumThreat);
+ Assert.AreEqual(2000, res.AbilityMetrics[1].MaximumThreat);
+ }
+ [TestMethod]
+ public void Given_One_Combat_When_Parse_Then_Healing_In_AbilityCounts()
+ {
+ // Arrange
+ h.EnterCombat(player).Tick()
+ .Heal(player, player, "SmallHeal", 250).Tick()
+ .Heal(player, player, "BigHeal", 2000).Tick()
+ .Heal(player, player, "SmallHeal", 750)
+ .ExitCombat(player);
+
+ // Act
+ var res = target.Parse(log);
+
+ // Assert
+ Assert.AreEqual(2, res.AbilityMetrics[0].Count);
+ Assert.AreEqual("SmallHeal", res.AbilityMetrics[0].Name);
+ Assert.AreEqual(500.0, res.AbilityMetrics[0].AverageHealing);
+ Assert.AreEqual(250, res.AbilityMetrics[0].MinimumHealing);
+ Assert.AreEqual(750, res.AbilityMetrics[0].MaximumHealing);
+
+ Assert.AreEqual(1, res.AbilityMetrics[1].Count);
+ Assert.AreEqual("BigHeal", res.AbilityMetrics[1].Name);
+ Assert.AreEqual(2000.00, res.AbilityMetrics[1].AverageHealing);
+ Assert.AreEqual(2000, res.AbilityMetrics[1].MinimumHealing);
+ Assert.AreEqual(2000, res.AbilityMetrics[1].MaximumHealing);
+ }
+
+ [TestMethod]
+ public void Bug_Counting_Healing_As_Damage_In_AbilityCounts()
+ {
+ // Arrange
+ h.EnterCombat(player).Tick()
+ .Heal(mob,mob,"Headbutt",1002).Tick()
+ .Damage(mob, player, "Headbutt", 150, "energy").Tick()
+ .Damage(player, mob, "Junkpunch", 1000, "physical")
+ .Damage(mob, player, "Headbutt", 450, "energy", true).Tick()
+ .ExitCombat(player);
+
+
+ // Act
+ var res = target.Parse(log);
+
+ // Assert
+ Assert.AreEqual(3, res.AbilityMetrics[0].Count);
+ Assert.AreEqual("Headbutt", res.AbilityMetrics[0].Name);
+ Assert.AreEqual(300.0, res.AbilityMetrics[0].AverageDamage);
+ Assert.AreEqual(150, res.AbilityMetrics[0].MinimumDamage);
+ Assert.AreEqual(450, res.AbilityMetrics[0].MaximumDamage);
+ Assert.AreEqual(1, res.AbilityMetrics[0].CountOfCriticals);
+
+ Assert.AreEqual(1, res.AbilityMetrics[1].Count);
+ Assert.AreEqual("Junkpunch", res.AbilityMetrics[1].Name);
+ Assert.AreEqual(1000.00, res.AbilityMetrics[1].AverageDamage);
+ Assert.AreEqual(1000, res.AbilityMetrics[1].MinimumDamage);
+ Assert.AreEqual(1000, res.AbilityMetrics[1].MaximumDamage);
+ Assert.AreEqual(0, res.AbilityMetrics[1].CountOfCriticals);
+ }
+
+ [TestMethod]
public void Given_One_Combat_When_Parse_Then_AbilityCounts_Populated()
{
// Arrange
@@ -165,19 +249,19 @@ public void Given_One_Combat_When_Parse_Then_AbilityCounts_Populated()
var res = target.Parse(log);
// Assert
- Assert.AreEqual(2, res.AbilityCounts[0].Count);
- Assert.AreEqual("Headbutt", res.AbilityCounts[0].Name);
- Assert.AreEqual(300.0, res.AbilityCounts[0].AverageDamage);
- Assert.AreEqual(150, res.AbilityCounts[0].MinimumDamage);
- Assert.AreEqual(450, res.AbilityCounts[0].MaximumDamage);
- Assert.AreEqual(1, res.AbilityCounts[0].CountOfCriticals);
+ Assert.AreEqual(2, res.AbilityMetrics[0].Count);
+ Assert.AreEqual("Headbutt", res.AbilityMetrics[0].Name);
+ Assert.AreEqual(300.0, res.AbilityMetrics[0].AverageDamage);
+ Assert.AreEqual(150, res.AbilityMetrics[0].MinimumDamage);
+ Assert.AreEqual(450, res.AbilityMetrics[0].MaximumDamage);
+ Assert.AreEqual(1, res.AbilityMetrics[0].CountOfCriticals);
- Assert.AreEqual(1, res.AbilityCounts[1].Count);
- Assert.AreEqual("Junkpunch", res.AbilityCounts[1].Name);
- Assert.AreEqual(1000.00, res.AbilityCounts[1].AverageDamage);
- Assert.AreEqual(1000, res.AbilityCounts[1].MinimumDamage);
- Assert.AreEqual(1000, res.AbilityCounts[1].MaximumDamage);
- Assert.AreEqual(0, res.AbilityCounts[1].CountOfCriticals);
+ Assert.AreEqual(1, res.AbilityMetrics[1].Count);
+ Assert.AreEqual("Junkpunch", res.AbilityMetrics[1].Name);
+ Assert.AreEqual(1000.00, res.AbilityMetrics[1].AverageDamage);
+ Assert.AreEqual(1000, res.AbilityMetrics[1].MinimumDamage);
+ Assert.AreEqual(1000, res.AbilityMetrics[1].MaximumDamage);
+ Assert.AreEqual(0, res.AbilityMetrics[1].CountOfCriticals);
}
[TestMethod]
@@ -458,7 +542,8 @@ public LogHelper Heal(Actor source, Actor target, string abilityName, int amount
{
number = 836045448940874,
amount = amount
- }
+ },
+ threat = amount
});
return this;
View
2 src/SWTOR.Parser/Abstractions/ILogMetrics.cs
@@ -6,7 +6,7 @@ namespace SWTOR.Parser.Domain
{
public interface ILogMetrics
{
- List<AbilityMetrics> AbilityCounts { get; set; }
+ List<AbilityMetrics> AbilityMetrics { get; set; }
int TotalDamage { get; set; }
int TotalHealing { get; set; }
int TotalThreat { get; set; }
View
36 src/SWTOR.Parser/CombatParser.cs
@@ -82,18 +82,34 @@ private static void AbilityAnalyzer(ILogMetrics data, IEnumerable<LogEntry> log)
var abilityNames = log.Where(m => m.ability.name != "").Select(m => m.ability.name).Distinct();
foreach (var name in abilityNames)
{
- var count = new AbilityMetrics();
+ var metrics = new AbilityMetrics();
var abilityLog = log.Where(m => m.ability.name == name);
- data.AbilityCounts.Add(count);
- count.Name = name;
- count.Number = abilityLog.First().ability.number;
- count.Count = abilityLog.Count();
- count.MaximumDamage = abilityLog.Max(m => m.result.amount);
- count.MinimumDamage = abilityLog.Min(m => m.result.amount);
- count.AverageDamage = abilityLog.Average(m => m.result.amount);
- count.CountOfCriticals = abilityLog.Where(m => m.result.isCritical).Count();
+
+ var damageLog = abilityLog.DamageEffects();
+ var healingLog = abilityLog.HealingEffects();
+ var threatLog = abilityLog.ThreatEffects();
+
+ data.AbilityMetrics.Add(metrics);
+
+ metrics.Name = name;
+ metrics.Number = abilityLog.First().ability.number;
+ metrics.Count = abilityLog.Count();
+
+ metrics.MaximumDamage = damageLog.IfEmpty(0, l => l.Max(m => m.result.amount));
+ metrics.MinimumDamage = damageLog.IfEmpty(0, l => l.Min(m => m.result.amount));
+ metrics.AverageDamage = damageLog.IfEmpty(0, l => l.Average(m => m.result.amount));
+
+ metrics.MaximumHealing = healingLog.IfEmpty(0, l => l.Max(m => m.result.amount));
+ metrics.MinimumHealing = healingLog.IfEmpty(0, l => l.Min(m => m.result.amount));
+ metrics.AverageHealing = healingLog.IfEmpty(0, l => l.Average(m => m.result.amount));
+
+ metrics.MaximumThreat = threatLog.IfEmpty(0, l => l.Max(m => m.result.amount));
+ metrics.MinimumThreat = threatLog.IfEmpty(0, l => l.Min(m => m.result.amount));
+ metrics.AverageThreat = threatLog.IfEmpty(0, l => l.Average(m => m.result.amount));
+
+ metrics.CountOfCriticals = abilityLog.Where(m => m.result.isCritical).Count();
}
- data.AbilityCounts = data.AbilityCounts.OrderByDescending(m => m.Count).ThenBy(m => m.Name).ToList();
+ data.AbilityMetrics = data.AbilityMetrics.OrderByDescending(m => m.Count).ThenBy(m => m.Name).ToList();
}
private CombatLog ParseCombatLog(List<LogEntry> log)
View
6 src/SWTOR.Parser/Domain/AbilityCount.cs → src/SWTOR.Parser/Domain/AbilityMetrics.cs
@@ -12,6 +12,12 @@ public class AbilityMetrics
public double AverageDamage { get; set; }
public int MaximumDamage { get; set; }
public int MinimumDamage { get; set; }
+ public double AverageHealing { get; set; }
+ public int MaximumHealing { get; set; }
+ public int MinimumHealing { get; set; }
+ public double AverageThreat { get; set; }
+ public int MaximumThreat { get; set; }
+ public int MinimumThreat { get; set; }
public int CountOfCriticals { get; set; }
}
}
View
4 src/SWTOR.Parser/Domain/CombatLog.cs
@@ -9,7 +9,7 @@ public class CombatLog : ILogMetrics
public CombatLog()
{
Combats = new List<CombatData>();
- AbilityCounts = new List<AbilityMetrics>();
+ AbilityMetrics = new List<AbilityMetrics>();
}
public string Id { get; set; }
@@ -20,6 +20,6 @@ public CombatLog()
public int TotalThreat { get; set; }
public int CountOfParry { get; set; }
public int CountOfDeflect { get; set; }
- public List<AbilityMetrics> AbilityCounts { get; set; }
+ public List<AbilityMetrics> AbilityMetrics { get; set; }
}
}
View
4 src/SWTOR.Parser/Domain/CombatMetrics.cs
@@ -9,7 +9,7 @@ public class CombatMetrics : ICombatMetrics
public CombatMetrics()
{
Log = new List<LogEntry>();
- AbilityCounts = new List<AbilityMetrics>();
+ AbilityMetrics = new List<AbilityMetrics>();
}
public List<LogEntry> Log { get; private set; }
@@ -19,7 +19,7 @@ public CombatMetrics()
public int TotalThreat { get; set; }
public int CountOfParry { get; set; }
public int CountOfDeflect { get; set; }
- public List<AbilityMetrics> AbilityCounts { get; set; }
+ public List<AbilityMetrics> AbilityMetrics { get; set; }
public int Interval { get; set; }
public double AverageDamagePerSecond { get; set; }
View
7 src/SWTOR.Parser/LogQueryExtensions.cs
@@ -7,6 +7,13 @@ namespace SWTOR.Parser
{
public static class LogQueryExtensions
{
+ public static U IfEmpty<T,U>(this IEnumerable<T> query, U defaultValue, Func<IEnumerable<T>,U> calculation)
+ {
+ if (query.Count() == 0)
+ return defaultValue;
+ else return calculation.Invoke(query);
+ }
+
public static IEnumerable<string> DistinctSources(this IEnumerable<LogEntry> log)
{
return log.Where(m => m.source.name != "").Select(m => m.source.name).Distinct();
View
2 src/SWTOR.Parser/SWTOR.Parser.csproj
@@ -57,7 +57,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Analyzer.cs" />
- <Compile Include="Domain\AbilityCount.cs" />
+ <Compile Include="Domain\AbilityMetrics.cs" />
<Compile Include="Domain\CharacterData.cs" />
<Compile Include="Domain\CombatData.cs" />
<Compile Include="Domain\CombatLog.cs" />

0 comments on commit 5a6f6ea

Please sign in to comment.
Something went wrong with that request. Please try again.