From e28f74b3546b8cdca97b9043c796125bcc14717b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 27 Apr 2025 21:45:28 -0400 Subject: [PATCH] Refactor DataTables and cleanup redundant code Refactored `WeaponTable` grid to use a typed parameter and improve readability. Removed outdated or unnecessary sample comments, consolidated duplicate code, and reorganized theme-related components in `PageLayout`. Simplified initialization logic and improved formatting consistency. --- IGP/PageLayout.razor | 6 +- IGP/Pages/DataTables/DataTablesPage.razor | 5 +- IGP/Pages/DataTables/Parts/UnitTable.razor | 2 +- IGP/Pages/DataTables/Parts/WeaponTable.razor | 57 +++----------- IGP/Program.cs | 13 ---- Model/Entity/Data/DATA.cs | 5 +- Model/Entity/EntityModel.cs | 15 ++-- Model/Entity/Parts/EntityWeaponModel.cs | 78 +++++++++----------- 8 files changed, 59 insertions(+), 122 deletions(-) diff --git a/IGP/PageLayout.razor b/IGP/PageLayout.razor index f90e0d8..36bd159 100644 --- a/IGP/PageLayout.razor +++ b/IGP/PageLayout.razor @@ -6,7 +6,8 @@ @using Services.Website @implements IDisposable - + + @@ -75,9 +76,6 @@ - - - @code { diff --git a/IGP/Pages/DataTables/DataTablesPage.razor b/IGP/Pages/DataTables/DataTablesPage.razor index e5ee1b8..6097c3c 100644 --- a/IGP/Pages/DataTables/DataTablesPage.razor +++ b/IGP/Pages/DataTables/DataTablesPage.razor @@ -1,5 +1,4 @@ @layout PageLayout - @using IGP.Pages.DataTables.Parts @inherits BasePage @@ -7,7 +6,7 @@ Data Tables - + @@ -28,7 +27,7 @@ @code { diff --git a/IGP/Pages/DataTables/Parts/UnitTable.razor b/IGP/Pages/DataTables/Parts/UnitTable.razor index 9845f85..d4a1c63 100644 --- a/IGP/Pages/DataTables/Parts/UnitTable.razor +++ b/IGP/Pages/DataTables/Parts/UnitTable.razor @@ -1,5 +1,5 @@ 

UnitTable

@code { - + } \ No newline at end of file diff --git a/IGP/Pages/DataTables/Parts/WeaponTable.razor b/IGP/Pages/DataTables/Parts/WeaponTable.razor index 2e70548..b546c0a 100644 --- a/IGP/Pages/DataTables/Parts/WeaponTable.razor +++ b/IGP/Pages/DataTables/Parts/WeaponTable.razor @@ -1,7 +1,10 @@ 

WeaponTable

- + @@ -10,60 +13,18 @@ - - - - - -@{ - /** - - - - Periodic Elements - - - - - - - - - - - - - + - -
- Sort Name Column By Length -
- */ -} - - - @code { - List _entityWeapons; - - protected override void OnInitialized() - { - base.OnInitialized(); - - _entityWeapons = DATA.Get() - .SelectMany(e => e.Value.EntityParts) - .OfType() - .ToList(); - } - + IEnumerable _entityWeapons = DATA.Get() + .SelectMany(e => e.Value.EntityParts) + .OfType() + .ToList(); } \ No newline at end of file diff --git a/IGP/Program.cs b/IGP/Program.cs index 58dd27e..fdc3376 100644 --- a/IGP/Program.cs +++ b/IGP/Program.cs @@ -1,7 +1,6 @@ using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; -using Blazor.Analytics; using Blazored.LocalStorage; using IGP; using Microsoft.AspNetCore.Components.Web; @@ -39,12 +38,6 @@ builder.Services.AddBlazoredLocalStorageAsSingleton(config => config.JsonSerializerOptions.WriteIndented = false; }); -#if DEBUG -builder.Services.AddGoogleAnalytics("G-S96LW7TVFY"); -#else -builder.Services.AddGoogleAnalytics(builder.Configuration["GATag"]); -#endif - builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -79,12 +72,6 @@ builder.Services.AddScoped(sp => new HttpClient builder.Services.AddMudServices(); -#if NO_SQL - -#else -//builder.Services.AddDbContext(options => { options.UseSqlite("Data Source=./Database.db"); }); -#endif - await builder.Build().RunAsync(); diff --git a/Model/Entity/Data/DATA.cs b/Model/Entity/Data/DATA.cs index b838d0a..7c33de7 100644 --- a/Model/Entity/Data/DATA.cs +++ b/Model/Entity/Data/DATA.cs @@ -1376,7 +1376,8 @@ public class DATA .AddPart(new EntityMovementModel { Speed = 532, Movement = MovementType.Air }) .AddPart(new EntityWeaponModel { - Damage = 100, 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 }) @@ -3656,7 +3657,7 @@ public class DATA Description = "Passively harvest pyre.", Notes = "" }) - }, + } }; } } \ No newline at end of file diff --git a/Model/Entity/EntityModel.cs b/Model/Entity/EntityModel.cs index 20b371d..effb04d 100644 --- a/Model/Entity/EntityModel.cs +++ b/Model/Entity/EntityModel.cs @@ -38,22 +38,25 @@ public class EntityModel public bool IsSpeculative { get; set; } public string Descriptive { get; set; } = DescriptiveType.None; - + public string GetName() { var entityInfo = EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityInfoModel)) as EntityInfoModel; return entityInfo == null ? string.Empty : entityInfo.Name; } - + public string GetFaction() { - var entityInfo = EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityFactionModel)) as EntityFactionModel; + var entityInfo = + EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityFactionModel)) as EntityFactionModel; return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.Faction].GetName(); } - + public string GetImmortal() { - var entityInfo = EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityVanguardAddedModel)) as EntityVanguardAddedModel; + var entityInfo = + EntityParts.FirstOrDefault(a => + a.GetType() == typeof(EntityVanguardAddedModel)) as EntityVanguardAddedModel; return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.ImmortalId].GetName(); } @@ -82,7 +85,7 @@ public class EntityModel public EntityModel AddPart(IEntityPartInterface unitPart) { unitPart.Parent = this; - + EntityParts.Add(unitPart); return this; } diff --git a/Model/Entity/Parts/EntityWeaponModel.cs b/Model/Entity/Parts/EntityWeaponModel.cs index 5de1618..1ca9877 100644 --- a/Model/Entity/Parts/EntityWeaponModel.cs +++ b/Model/Entity/Parts/EntityWeaponModel.cs @@ -12,69 +12,57 @@ public class EntityWeaponModel : IEntityPartInterface public float AttacksPerSecond { get; set; } = 0; public float SecondsBetweenAttacks { get; set; } = 0; + public float Cooldown { get; set; } = 0; + public float Charges { get; set; } = 0; + + public int Damage { get; set; } = 0; + + public string ComplexDamage { get; set; } = "deals 126 over 6 seconds"; + + + public bool HasSplash { get; set; } + + public int LightDamage { get; set; } = 0; + public int MediumDamage { get; set; } = 0; + public int HeavyDamage { get; set; } = 0; + + + public int StructureDamageBonus { get; set; } = 0; + public int EthericDamageBonus { get; set; } = 0; + public string Targets { get; set; } = TargetType.All; + public string Attack { get; set; } = AttackType.DPS; + public float DamagePerSecond() { - if (SecondsBetweenAttacks == 0) - { - return Damage * AttacksPerSecond; - } - + if (SecondsBetweenAttacks == 0) return Damage * AttacksPerSecond; + return Damage / SecondsBetweenAttacks; } - + public float DamagePerSecondLight() { var damage = LightDamage != 0 ? LightDamage : Damage; - - if (SecondsBetweenAttacks == 0) - { - return damage * AttacksPerSecond; - } - + + if (SecondsBetweenAttacks == 0) return damage * AttacksPerSecond; + return damage / SecondsBetweenAttacks; } public float DamagePerSecondMedium() { var damage = MediumDamage != 0 ? MediumDamage : Damage; - - if (SecondsBetweenAttacks == 0) - { - return damage * AttacksPerSecond; - } - + + 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; - - public int Damage { get; set; } = 0; - - public string ComplexDamage { get; set; } = "deals 126 over 6 seconds"; - - - public bool HasSplash { get; set; } - - public int LightDamage { get; set; } = 0; - public int MediumDamage { get; set; } = 0; - public int HeavyDamage { get; set; } = 0; + if (SecondsBetweenAttacks == 0) return damage * AttacksPerSecond; - public int StructureDamageBonus { get; set; } = 0; - public int EthericDamageBonus { get; set; } = 0; - public string Targets { get; set; } = TargetType.All; - public string Attack { get; set; } = AttackType.DPS; + return damage / SecondsBetweenAttacks; + } } \ No newline at end of file