use crate::reply::rail::{Card, Rail};
use crate::ui::theme;
pub(super) fn markers(rail: Option<&Rail>, entry: &str) -> Vec<String> {
let Some(rail) = rail else {
return Vec::new();
};
rail.cards
.iter()
.filter(|card| card.procedure.is_some())
.filter(|card| {
usize::try_from(card.notch)
.ok()
.and_then(|at| rail.notches.get(at))
.and_then(|notch| notch.seat.as_ref())
.is_some_and(|seat| seat.row == entry)
})
.map(line)
.collect()
}
pub fn line(card: &Card) -> String {
let role = card.role.as_deref().unwrap_or(&card.name);
let binding = card.procedure.as_deref().unwrap_or_default();
let outcome = match (&card.landed, &card.tail) {
(Some(file), Some(said)) => format!("landed {file}: \u{201c}{said}\u{201d}"),
(Some(file), None) => format!("landed {file}"),
(None, _) => card.state.label().clone(),
};
format!(
"{role} \u{b7} {binding} \u{b7} {outcome} \u{b7} {}",
crate::render::counted(card.tokens, "token")
)
}
pub(super) fn paint(ui: &mut egui::Ui, lines: &[String]) {
for said in lines {
ui.add_space(theme::space::S);
ui.colored_label(theme::INK_WEAK, said);
}
}
#[cfg(test)]
mod tests;