generated from GarandPLG/rust-flake-template
Refactor GameMode and Players into skirmish_states
Move the GameMode and Players enums from the top‑level states module into the skirmish_states submodule, add an Unclaimed variant to Players, and update all imports, trait implementations, and related logic accordingly. Adjust the durability percentage calculation to use u32 for safety.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
use crate::app::states::skirmish_states::BoardState;
|
||||
use clap::ValueEnum;
|
||||
use ratatui::{
|
||||
style::{Color, Stylize},
|
||||
text::Span,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SkirmishState {
|
||||
@@ -12,38 +7,3 @@ pub struct SkirmishState {
|
||||
pub board: BoardState,
|
||||
pub side_panel: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum GameMode {
|
||||
LastManStanding,
|
||||
FrontLines,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Players {
|
||||
Player,
|
||||
Enemy,
|
||||
}
|
||||
|
||||
impl Players {
|
||||
pub fn get_text(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Player => "Player",
|
||||
Self::Enemy => "Enemy",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_color(&self) -> Color {
|
||||
match self {
|
||||
Self::Player => Color::LightBlue,
|
||||
Self::Enemy => Color::LightRed,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_span(&self) -> Span<'static> {
|
||||
match self {
|
||||
Self::Player => self.get_text().fg(self.get_color()),
|
||||
Self::Enemy => self.get_text().fg(self.get_color()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user