-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
2 additions
and
38 deletions.
There are no files selected for viewing
40 changes: 2 additions & 38 deletions
40
rpg_tools_core/src/model/character/appearance/ear/shape.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,14 @@ | ||
use crate::ui::{UiVisitor, UI}; | ||
use macro_convert::Convert; | ||
use macro_ui::ui; | ||
use serde::{Deserialize, Serialize}; | ||
use std::fmt; | ||
use EarShape::*; | ||
|
||
/// How many ears does the character have? | ||
#[derive(ui, Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
#[derive(Convert, ui, Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum EarShape { | ||
/// Like an elf's ears. | ||
Pointed, | ||
Round, | ||
#[default] | ||
Square, | ||
} | ||
|
||
impl EarShape { | ||
pub fn get_all() -> Vec<EarShape> { | ||
vec![Pointed, Round, Square] | ||
} | ||
} | ||
|
||
impl fmt::Display for EarShape { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{:?}", self) | ||
} | ||
} | ||
|
||
impl From<&str> for EarShape { | ||
fn from(shape: &str) -> Self { | ||
match shape { | ||
"Pointed" => Pointed, | ||
"Round" => Round, | ||
_ => Square, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_conversion() { | ||
for shape in EarShape::get_all() { | ||
let string = shape.to_string(); | ||
assert_eq!(shape, EarShape::from(&*string)); | ||
} | ||
} | ||
} |