use serde::Serialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Intent {
Natal,
Fortune,
Event,
Election,
Synastry,
Mundane,
Locative,
Onomancy,
}
impl Intent {
#[must_use]
pub fn id(self) -> &'static str {
match self {
Self::Natal => "natal",
Self::Fortune => "fortune",
Self::Event => "event",
Self::Election => "election",
Self::Synastry => "synastry",
Self::Mundane => "mundane",
Self::Locative => "locative",
Self::Onomancy => "onomancy",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
pub enum IntentStatus {
Live,
Pending,
}
impl IntentStatus {
#[must_use]
pub fn label(self) -> &'static str {
match self {
Self::Live => "已上线",
Self::Pending => "待承接",
}
}
}
#[derive(Debug, Clone, Copy, Serialize)]
pub struct IntentSpec {
pub id: Intent,
pub name_zh: &'static str,
pub atoms: &'static [&'static str],
pub output_shape: &'static str,
pub status: IntentStatus,
pub note: &'static str,
}
const fn i(
id: Intent,
name_zh: &'static str,
atoms: &'static [&'static str],
output_shape: &'static str,
status: IntentStatus,
note: &'static str,
) -> IntentSpec {
IntentSpec { id, name_zh, atoms, output_shape, status, note }
}
#[must_use]
pub fn intents() -> &'static [IntentSpec] {
use IntentStatus::Live;
const { &[
i(
Intent::Natal, "命(本命盘)",
&["instant", "geo", "sex", "text(name)"],
"盘(静态切片,全树并行 fan-out)", Live,
"一个时刻的静态切片。全部时刻叶都答这一类,故它也是一片叶不作声明时的缺省",
),
i(
Intent::Fortune, "运(运势/流年/大运)",
&["instant(birth)", "instant(target)", "sex"],
"势(时间序列,playhead 切片)", Live,
"本命固定、目标时刻在动:同一张底盘上取某一刻的切片,并沿时间轴铺成序列",
),
i(
Intent::Event, "事(占事)",
&["instant(ask)", "seed(draw)", "text(question)"],
"断(成败/吉凶/宜忌)", Live,
"问事此刻加一次取机;取机的种子入盘,故同一次占问可复现",
),
i(
Intent::Election, "择(择吉)",
&["window(start, end, grain)", "category(婚/葬/动土/行/开业…)"],
"期/序(候选日按吉凶排名)", Live,
"在一段时窗上逐日取要素并分档。事类宜忌各家出入大,不合成总分;\
各家分档的粒度与判据也不同,故这一类目前由单叶作答,合成总排名等于替读者选边",
),
i(
Intent::Synastry, "合(合盘)",
&["instant(a)", "instant(b)", "sex(a,b)"],
"配(契合度/互补结构)", Live,
"两张本命之间的互供关系,两个方向分别成立,不对称是常态",
),
i(
Intent::Mundane, "群/国(国运)",
&["instant(polity)", "geo"],
"势(国运势卜/年度盘)", Live,
"以政体奠基时刻为起点的周期结构,沿年份展开;描述的是周期位置,不是对现实的断言",
),
i(
Intent::Locative, "寻(寻方位)",
&["instant(ask)", "seed(draw)", "category(寻人/物/向)"],
"位(方位/卦象)", Live,
"于问事此刻起课,从盘上抽方位候选(奇门取值符 / 值使 / 三吉门 / 三奇落宫 → 后天八卦方位,六壬取三传或四课上神 → 十二支方位);取用之法各家不同,不合成排名",
),
i(
Intent::Onomancy, "号(字/词)",
&["text(name)", "strokes(姓笔画, 名笔画)"],
"号(数字学生命灵数/姓名值/五格)", Live,
"唯一不吃时刻的一类:入参是字与笔画,故走 WordEngine 而非 CastingEngine;\
数字学同时吃出生日期,因此它两边都在",
),
] }
}