use ratatui::{prelude::*, widgets::Paragraph};
fn big_text<'a, S: AsRef<str>>(text: Vec<S>, color_1: Color, color_2: Color) -> Paragraph<'a> {
let lines = text
.iter()
.map(|line| {
let spans = line
.as_ref()
.chars()
.map(|c| {
if c == '█' {
Span::styled("█", color_1)
} else {
Span::styled(c.to_string(), color_2)
}
})
.collect::<Vec<Span>>();
Line::from(spans)
})
.collect::<Vec<Line>>();
Paragraph::new(lines).centered()
}
pub fn dots(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![" ", "██╗", "╚═╝", "██╗", "╚═╝", " "],
color_1,
color_2,
)
}
const DIGITS: [[&str; 6]; 10] = [
[
" ██████╗ ",
"██╔═████╗",
"██║██╔██║",
"████╔╝██║",
"╚██████╔╝",
" ╚═════╝ ",
],
[" ██╗", "███║", "╚██║", " ██║", " ██║", " ╚═╝"],
[
"██████╗ ",
"╚════██╗",
" █████╔╝",
"██╔═══╝ ",
"███████╗",
"╚══════╝",
],
[
"██████╗ ",
"╚════██╗",
" █████╔╝",
" ╚═══██╗",
"██████╔╝",
"╚═════╝ ",
],
[
"██╗ ██╗",
"██║ ██║",
"███████║",
"╚════██║",
" ██║",
" ╚═╝",
],
[
"███████╗",
"██╔════╝",
"███████╗",
"╚════██║",
"███████║",
"╚══════╝",
],
[
" ██████╗ ",
"██╔════╝ ",
"███████╗ ",
"██╔═══██╗",
"╚██████╔╝",
" ╚═════╝ ",
],
[
"███████╗",
"╚════██║",
" ██╔╝",
" ██╔╝ ",
" ██║ ",
" ╚═╝ ",
],
[
" █████╗ ",
"██╔══██╗",
"╚█████╔╝",
"██╔══██╗",
"╚█████╔╝",
" ╚════╝ ",
],
[
" █████╗ ",
"██╔══██╗",
"╚██████║",
" ╚═══██║",
" █████╔╝",
" ╚════╝ ",
],
];
pub trait BigNumberFont {
fn big_font_styled(&self, color_1: Color, color_2: Color) -> Paragraph<'static>;
}
impl BigNumberFont for u8 {
fn big_font_styled(&self, color_1: Color, color_2: Color) -> Paragraph<'static> {
let n = *self as usize;
if n < 10 {
big_text(DIGITS[n].to_vec(), color_1, color_2)
} else if n < 100 {
let tens = DIGITS[n / 10];
let units = DIGITS[n % 10];
let lines = (0..6)
.map(|i| tens[i].to_string() + units[i])
.collect::<Vec<_>>();
big_text(lines, color_1, color_2)
} else {
dots(color_1, color_2)
}
}
}
pub fn red_scored(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ███████╗██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ██╗",
"██╔══██╗██╔════╝██╔══██╗ ██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗██║",
"██████╔╝█████╗ ██║ ██║ ███████╗██║ ██║ ██║██████╔╝█████╗ ██║ ██║██║",
"██╔══██╗██╔══╝ ██║ ██║ ╚════██║██║ ██║ ██║██╔══██╗██╔══╝ ██║ ██║╚═╝",
"██║ ██║███████╗██████╔╝ ███████║╚██████╗╚██████╔╝██║ ██║███████╗██████╔╝██╗",
"╚═╝ ╚═╝╚══════╝╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝",
],
color_1,
color_2,
)
}
pub fn blue_scored(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ██╗ ██╗ ██╗███████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ██╗",
"██╔══██╗██║ ██║ ██║██╔════╝ ██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗██║",
"██████╔╝██║ ██║ ██║█████╗ ███████╗██║ ██║ ██║██████╔╝█████╗ ██║ ██║██║",
"██╔══██╗██║ ██║ ██║██╔══╝ ╚════██║██║ ██║ ██║██╔══██╗██╔══╝ ██║ ██║╚═╝",
"██████╔╝███████╗╚██████╔╝███████╗ ███████║╚██████╗╚██████╔╝██║ ██║███████╗██████╔╝██╗",
"╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝",
],
color_1,
color_2,
)
}
pub fn red_won(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ███████╗██████╗ ██╗ ██╗ ██████╗ ███╗ ██╗██╗",
"██╔══██╗██╔════╝██╔══██╗ ██║ ██║██╔═══██╗████╗ ██║██║",
"██████╔╝█████╗ ██║ ██║ ██║ █╗ ██║██║ ██║██╔██╗ ██║██║",
"██╔══██╗██╔══╝ ██║ ██║ ██║███╗██║██║ ██║██║╚██╗██║╚═╝",
"██║ ██║███████╗██████╔╝ ╚███╔███╔╝╚██████╔╝██║ ╚████║██╗",
"╚═╝ ╚═╝╚══════╝╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝",
],
color_1,
color_2,
)
}
pub fn blue_won(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ██╗ ██╗ ██╗███████╗ ██╗ ██╗ ██████╗ ███╗ ██╗██╗",
"██╔══██╗██║ ██║ ██║██╔════╝ ██║ ██║██╔═══██╗████╗ ██║██║",
"██████╔╝██║ ██║ ██║█████╗ ██║ █╗ ██║██║ ██║██╔██╗ ██║██║",
"██╔══██╗██║ ██║ ██║██╔══╝ ██║███╗██║██║ ██║██║╚██╗██║╚═╝",
"██████╔╝███████╗╚██████╔╝███████╗ ╚███╔███╔╝╚██████╔╝██║ ╚████║██╗",
"╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝",
],
color_1,
color_2,
)
}
pub fn disconnection(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ██╗███████╗ ██████╗ ██████╗ ███╗ ██╗███╗ ██╗███████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗",
"██╔══██╗██║██╔════╝██╔════╝██╔═══██╗████╗ ██║████╗ ██║██╔════╝██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║",
"██║ ██║██║███████╗██║ ██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ██║ ██║ ██║██║ ██║██╔██╗ ██║",
"██║ ██║██║╚════██║██║ ██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██║ ██║ ██║██║ ██║██║╚██╗██║",
"██████╔╝██║███████║╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║",
"╚═════╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝",
],
color_1,
color_2,
)
}
pub fn draw(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ██████╗ █████╗ ██╗ ██╗██╗",
"██╔══██╗██╔══██╗██╔══██╗██║ ██║██║",
"██║ ██║██████╔╝███████║██║ █╗ ██║██║",
"██║ ██║██╔══██╗██╔══██║██║███╗██║╚═╝",
"██████╔╝██║ ██║██║ ██║╚███╔███╔╝██╗",
"╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝",
],
color_1,
color_2,
)
}
pub fn practice(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"██████╗ ██████╗ █████╗ ██████╗████████╗██╗ ██████╗███████╗",
"██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝██║██╔════╝██╔════╝",
"██████╔╝██████╔╝███████║██║ ██║ ██║██║ █████╗ ",
"██╔═══╝ ██╔══██╗██╔══██║██║ ██║ ██║██║ ██╔══╝ ",
"██║ ██║ ██║██║ ██║╚██████╗ ██║ ██║╚██████╗███████╗",
"╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝",
],
color_1,
color_2,
)
.left_aligned()
}
pub fn sshattrick(color_1: Color, color_2: Color) -> Paragraph<'static> {
big_text(
vec![
"███████╗███████╗██╗ ██╗ █████╗ ████████╗████████╗██████╗ ██╗ ██████╗██╗ ██╗",
"██╔════╝██╔════╝██║ ██║██╔══██╗╚══██╔══╝╚══██╔══╝██╔══██╗██║██╔════╝██║ ██╔╝",
"███████╗███████╗███████║███████║ ██║ ██║ ██████╔╝██║██║ █████╔╝ ",
"╚════██║╚════██║██╔══██║██╔══██║ ██║ ██║ ██╔══██╗██║██║ ██╔═██╗ ",
"███████║███████║██║ ██║██║ ██║ ██║ ██║ ██║ ██║██║╚██████╗██║ ██╗",
"╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝",
],
color_1,
color_2,
)
}