generated from GarandPLG/rust-flake-template
Update formatting to use 4‑space indentation
- Adjust rustfmt.toml to set tab_spaces = 4. - Reformat imports, struct definitions, function bodies, and match arms across the project to match the new style (aligned fields, added spacing, etc.). - Ensure all code complies with the updated rustfmt settings.
This commit is contained in:
1 parent
a981663152
commit
73f544d5d6
66 files changed
+5378
-5373
No files matched your search
@@ -1,100 +1,100 @@
|
||||
use crate::app::states::skirmish_states::{Players, structures::Structure};
|
||||
use ratatui::{
|
||||
style::{Color, Stylize},
|
||||
text::Line,
|
||||
style::{Color, Stylize},
|
||||
text::Line,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Ore {
|
||||
owner: Players,
|
||||
ore_amount: u16,
|
||||
durability: u16,
|
||||
stress: u8,
|
||||
level: u8,
|
||||
owner: Players,
|
||||
ore_amount: u16,
|
||||
durability: u16,
|
||||
stress: u8,
|
||||
level: u8,
|
||||
}
|
||||
|
||||
impl Ore {
|
||||
pub fn new(owner: Players, level: u8) -> Self {
|
||||
Self {
|
||||
owner,
|
||||
ore_amount: 5000,
|
||||
durability: 1000,
|
||||
stress: 0,
|
||||
level,
|
||||
pub fn new(owner: Players, level: u8) -> Self {
|
||||
Self {
|
||||
owner,
|
||||
ore_amount: 5000,
|
||||
durability: 1000,
|
||||
stress: 0,
|
||||
level,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ore_amount(&self) -> u16 {
|
||||
self.ore_amount
|
||||
}
|
||||
pub fn get_ore_amount(&self) -> u16 {
|
||||
self.ore_amount
|
||||
}
|
||||
|
||||
pub fn get_max_ore_amount(&self) -> u16 {
|
||||
5000
|
||||
}
|
||||
pub fn get_max_ore_amount(&self) -> u16 {
|
||||
5000
|
||||
}
|
||||
|
||||
pub fn extract(&mut self, amount: u16) -> u16 {
|
||||
let extracted: u16 = amount.min(self.ore_amount);
|
||||
self.ore_amount -= extracted;
|
||||
extracted
|
||||
}
|
||||
pub fn extract(&mut self, amount: u16) -> u16 {
|
||||
let extracted: u16 = amount.min(self.ore_amount);
|
||||
self.ore_amount -= extracted;
|
||||
extracted
|
||||
}
|
||||
|
||||
pub fn set_owner(&mut self, new_owner: Players) -> &mut Self {
|
||||
self.owner = new_owner;
|
||||
self
|
||||
}
|
||||
pub fn set_owner(&mut self, new_owner: Players) -> &mut Self {
|
||||
self.owner = new_owner;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Structure for Ore {
|
||||
fn get_tag(&self) -> char {
|
||||
'O'
|
||||
}
|
||||
|
||||
fn get_color(&self) -> Color {
|
||||
match self.owner {
|
||||
Players::Player => self.owner.get_color(),
|
||||
Players::Enemy => self.owner.get_color(),
|
||||
Players::Unclaimed => Color::Indexed(217),
|
||||
fn get_tag(&self) -> char {
|
||||
'O'
|
||||
}
|
||||
}
|
||||
|
||||
fn get_durability(&self) -> u16 {
|
||||
self.durability
|
||||
}
|
||||
|
||||
fn get_level(&self) -> char {
|
||||
if self.level != 0 {
|
||||
(self.level + b'0') as char
|
||||
} else {
|
||||
' '
|
||||
fn get_color(&self) -> Color {
|
||||
match self.owner {
|
||||
Players::Player => self.owner.get_color(),
|
||||
Players::Enemy => self.owner.get_color(),
|
||||
Players::Unclaimed => Color::Indexed(217),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_max_durability(&self) -> u16 {
|
||||
1000
|
||||
}
|
||||
fn get_durability(&self) -> u16 {
|
||||
self.durability
|
||||
}
|
||||
|
||||
fn get_name(&self) -> &'static str {
|
||||
"Ore"
|
||||
}
|
||||
fn get_level(&self) -> char {
|
||||
if self.level != 0 {
|
||||
(self.level + b'0') as char
|
||||
} else {
|
||||
' '
|
||||
}
|
||||
}
|
||||
|
||||
fn get_owner(&self) -> Players {
|
||||
self.owner
|
||||
}
|
||||
fn get_max_durability(&self) -> u16 {
|
||||
1000
|
||||
}
|
||||
|
||||
fn get_stress(&self) -> u8 {
|
||||
self.stress
|
||||
}
|
||||
fn get_name(&self) -> &'static str {
|
||||
"Ore"
|
||||
}
|
||||
|
||||
fn text(&self) -> Vec<Line<'_>> {
|
||||
let mut lines: Vec<Line<'_>> = Structure::base_text(self);
|
||||
fn get_owner(&self) -> Players {
|
||||
self.owner
|
||||
}
|
||||
|
||||
lines.push(Line::from_iter([
|
||||
"Ore: ".gray(),
|
||||
self.get_ore_amount().to_string().cyan(),
|
||||
"/".gray(),
|
||||
self.get_max_ore_amount().to_string().cyan(),
|
||||
]));
|
||||
fn get_stress(&self) -> u8 {
|
||||
self.stress
|
||||
}
|
||||
|
||||
lines
|
||||
}
|
||||
fn text(&self) -> Vec<Line<'_>> {
|
||||
let mut lines: Vec<Line<'_>> = Structure::base_text(self);
|
||||
|
||||
lines.push(Line::from_iter([
|
||||
"Ore: ".gray(),
|
||||
self.get_ore_amount().to_string().cyan(),
|
||||
"/".gray(),
|
||||
self.get_max_ore_amount().to_string().cyan(),
|
||||
]));
|
||||
|
||||
lines
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user