From 41020708e45a2b810387cfb37aa2af83a5c30d4d Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Wed, 6 May 2026 18:51:45 +0200 Subject: [PATCH] Rename internal helpers and adjust related calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename `structure` to `s` in Structures and `unit` to `u` in Units, updating all call sites. Refactor `Structures::text` to match on the owner directly and push the owner line only for claimed owners. Change the “% )” token color in unit display from green to gray. --- .../structures/structures_enum.rs | 36 ++++++++++--------- .../skirmish_states/units/unit_trait.rs | 2 +- .../skirmish_states/units/units_enum.rs | 16 ++++----- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/app/states/skirmish_states/structures/structures_enum.rs b/src/app/states/skirmish_states/structures/structures_enum.rs index e7c72ec..de90e74 100644 --- a/src/app/states/skirmish_states/structures/structures_enum.rs +++ b/src/app/states/skirmish_states/structures/structures_enum.rs @@ -17,7 +17,7 @@ pub enum Structures { impl Structures { #[inline] - fn structure(&self) -> &dyn Structure { + fn s(&self) -> &dyn Structure { match self { Self::Base(b) => b, Self::Tunnel(t) => t, @@ -29,46 +29,50 @@ impl Structures { impl Structure for Structures { fn get_color(&self) -> Color { - self.structure().get_color() + self.s().get_color() } fn get_tag(&self) -> char { - self.structure().get_tag() + self.s().get_tag() } fn get_level(&self) -> char { - self.structure().get_level() + self.s().get_level() } fn get_name(&self) -> &'static str { - self.structure().get_name() + self.s().get_name() } fn get_durability(&self) -> u16 { - self.structure().get_durability() + self.s().get_durability() } fn get_max_durability(&self) -> u16 { - self.structure().get_max_durability() + self.s().get_max_durability() } fn get_stress(&self) -> u8 { - self.structure().get_stress() + self.s().get_stress() } fn get_owner(&self) -> Players { - self.structure().get_owner() + self.s().get_owner() } fn text(&self) -> Vec> { - let owner: Players = self.structure().get_owner(); - let mut lines: Vec> = self.structure().text(); + match self.s().get_owner() { + Players::Unclaimed => self.s().text(), + Players::Player | Players::Enemy => { + let mut lines: Vec> = self.s().text(); - match owner { - Players::Unclaimed => {} - _ => lines.push(Line::from_iter(["Owner: ".gray(), owner.get_span()])), + lines.push(Line::from_iter([ + "Owner: ".gray(), + self.s().get_owner().get_span(), + ])); + + lines + } } - - lines } } diff --git a/src/app/states/skirmish_states/units/unit_trait.rs b/src/app/states/skirmish_states/units/unit_trait.rs index 47169df..aeaa6c8 100644 --- a/src/app/states/skirmish_states/units/unit_trait.rs +++ b/src/app/states/skirmish_states/units/unit_trait.rs @@ -40,7 +40,7 @@ pub trait Unit { max_hp.green(), " ( ".gray(), hp_percent.green(), - "% )".green(), + "% )".gray(), ]), ]); diff --git a/src/app/states/skirmish_states/units/units_enum.rs b/src/app/states/skirmish_states/units/units_enum.rs index 799caf7..2cf15cc 100644 --- a/src/app/states/skirmish_states/units/units_enum.rs +++ b/src/app/states/skirmish_states/units/units_enum.rs @@ -9,7 +9,7 @@ pub enum Units { } impl Units { - fn unit(&self) -> &dyn Unit { + fn u(&self) -> &dyn Unit { match self { Self::Miner(m) => m, } @@ -18,31 +18,31 @@ impl Units { impl Unit for Units { fn get_tag(&self) -> char { - self.unit().get_tag() + self.u().get_tag() } fn get_name(&self) -> &'static str { - self.unit().get_name() + self.u().get_name() } fn get_owner(&self) -> Players { - self.unit().get_owner() + self.u().get_owner() } fn get_hp(&self) -> u16 { - self.unit().get_hp() + self.u().get_hp() } fn get_max_hp(&self) -> u16 { - self.unit().get_max_hp() + self.u().get_max_hp() } fn get_can_dig(&self) -> bool { - self.unit().get_can_dig() + self.u().get_can_dig() } fn get_digging_power(&self) -> f32 { - self.unit().get_digging_power() + self.u().get_digging_power() } }