From 764192891c22a98ef8a72e9a71ff2d3f869fd989 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 27 Apr 2025 20:57:01 -0400 Subject: [PATCH] Add DPS calculations and columns to WeaponTable Introduced new methods in `EntityWeaponModel` to calculate DPS for normal, light, medium, and heavy damage types. Updated `WeaponTable.razor` to display these new DPS values as additional columns for better weapon performance insights. Also fixed missing initialization of the base `Damage` property in test data. --- IGP/Pages/DataTables/Parts/WeaponTable.razor | 6 +++ Model/Entity/Data/DATA.cs | 2 +- Model/Entity/Parts/EntityWeaponModel.cs | 46 ++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/IGP/Pages/DataTables/Parts/WeaponTable.razor b/IGP/Pages/DataTables/Parts/WeaponTable.razor index e316081..2e70548 100644 --- a/IGP/Pages/DataTables/Parts/WeaponTable.razor +++ b/IGP/Pages/DataTables/Parts/WeaponTable.razor @@ -6,6 +6,12 @@ + + + + + + diff --git a/Model/Entity/Data/DATA.cs b/Model/Entity/Data/DATA.cs index e9f1201..b838d0a 100644 --- a/Model/Entity/Data/DATA.cs +++ b/Model/Entity/Data/DATA.cs @@ -1376,7 +1376,7 @@ public class DATA .AddPart(new EntityMovementModel { Speed = 532, Movement = MovementType.Air }) .AddPart(new EntityWeaponModel { - LightDamage = 100, MediumDamage = 130, HeavyDamage = 160, Range = 20, AttacksPerSecond = 1, + Damage = 100, LightDamage = 100, MediumDamage = 130, HeavyDamage = 160, Range = 20, AttacksPerSecond = 1, Targets = TargetType.Air }) diff --git a/Model/Entity/Parts/EntityWeaponModel.cs b/Model/Entity/Parts/EntityWeaponModel.cs index cf214b1..5de1618 100644 --- a/Model/Entity/Parts/EntityWeaponModel.cs +++ b/Model/Entity/Parts/EntityWeaponModel.cs @@ -12,6 +12,52 @@ public class EntityWeaponModel : IEntityPartInterface public float AttacksPerSecond { get; set; } = 0; public float SecondsBetweenAttacks { get; set; } = 0; + public float DamagePerSecond() + { + if (SecondsBetweenAttacks == 0) + { + return Damage * AttacksPerSecond; + } + + return Damage / SecondsBetweenAttacks; + } + + public float DamagePerSecondLight() + { + var damage = LightDamage != 0 ? LightDamage : Damage; + + if (SecondsBetweenAttacks == 0) + { + return damage * AttacksPerSecond; + } + + return damage / SecondsBetweenAttacks; + } + + public float DamagePerSecondMedium() + { + var damage = MediumDamage != 0 ? MediumDamage : Damage; + + if (SecondsBetweenAttacks == 0) + { + return damage * AttacksPerSecond; + } + + return damage / SecondsBetweenAttacks; + } + + public float DamagePerSecondHeavy() + { + var damage = HeavyDamage != 0 ? HeavyDamage : Damage; + + if (SecondsBetweenAttacks == 0) + { + return damage * AttacksPerSecond; + } + + return damage / SecondsBetweenAttacks; + } + public float Cooldown { get; set; } = 0; public float Charges { get; set; } = 0;