use std::fmt::Display;
use std::fmt::Formatter;
use tyme4rs::tyme::Culture;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenMethod {
Time,
Day,
Month,
Year,
}
impl Display for QimenMethod {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Time => "时家",
Self::Day => "日家",
Self::Month => "月家",
Self::Year => "年家",
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenChartType {
SanYuan,
SiZhu,
}
impl Display for QimenChartType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::SanYuan => "三元",
Self::SiZhu => "四柱",
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenYuan {
Upper,
Middle,
Lower,
}
impl Display for QimenYuan {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Upper => "上元",
Self::Middle => "中元",
Self::Lower => "下元",
})
}
}
impl Culture for QimenYuan {
fn get_name(&self) -> String { self.to_string() }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenStar {
TianPeng,
TianRui,
TianChong,
TianFu,
TianQin,
TianXin,
TianZhu,
TianRen,
TianYing,
QinRui,
}
impl Display for QimenStar {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::TianPeng => "天蓬",
Self::TianRui => "天芮",
Self::TianChong => "天冲",
Self::TianFu => "天辅",
Self::TianQin => "天禽",
Self::TianXin => "天心",
Self::TianZhu => "天柱",
Self::TianRen => "天任",
Self::TianYing => "天英",
Self::QinRui => "禽芮",
})
}
}
impl Culture for QimenStar {
fn get_name(&self) -> String { self.to_string() }
}
impl QimenStar {
pub const fn home_palace(self) -> u8 {
match self {
Self::TianPeng => 1,
Self::TianRui | Self::QinRui => 2,
Self::TianChong => 3,
Self::TianFu => 4,
Self::TianQin => 5,
Self::TianXin => 6,
Self::TianZhu => 7,
Self::TianRen => 8,
Self::TianYing => 9,
}
}
pub const fn from_palace(palace: u8) -> Option<Self> {
match palace {
1 => Some(Self::TianPeng),
2 => Some(Self::TianRui),
3 => Some(Self::TianChong),
4 => Some(Self::TianFu),
5 => Some(Self::TianQin),
6 => Some(Self::TianXin),
7 => Some(Self::TianZhu),
8 => Some(Self::TianRen),
9 => Some(Self::TianYing),
_ => None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenDoor {
Rest,
Life,
Hurt,
Block,
View,
Death,
Fear,
Open,
}
impl Display for QimenDoor {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Rest => "休门",
Self::Life => "生门",
Self::Hurt => "伤门",
Self::Block => "杜门",
Self::View => "景门",
Self::Death => "死门",
Self::Fear => "惊门",
Self::Open => "开门",
})
}
}
impl Culture for QimenDoor {
fn get_name(&self) -> String { self.to_string() }
}
impl QimenDoor {
pub const fn home_palace(self) -> u8 {
match self {
Self::Rest => 1,
Self::Death => 2,
Self::Hurt => 3,
Self::Block => 4,
Self::View => 9,
Self::Open => 6,
Self::Fear => 7,
Self::Life => 8,
}
}
pub const fn from_palace(palace: u8) -> Option<Self> {
match palace {
1 => Some(Self::Rest),
2 => Some(Self::Death),
3 => Some(Self::Hurt),
4 => Some(Self::Block),
6 => Some(Self::Open),
7 => Some(Self::Fear),
8 => Some(Self::Life),
9 => Some(Self::View),
_ => None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QimenGod {
ZhiFu,
TengShe,
TaiYin,
LiuHe,
BaiHu,
XuanWu,
JiuDi,
JiuTian,
}
impl Display for QimenGod {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::ZhiFu => "值符",
Self::TengShe => "腾蛇",
Self::TaiYin => "太阴",
Self::LiuHe => "六合",
Self::BaiHu => "白虎",
Self::XuanWu => "玄武",
Self::JiuDi => "九地",
Self::JiuTian => "九天",
})
}
}
impl Culture for QimenGod {
fn get_name(&self) -> String { self.to_string() }
}