use core::any::Any;
use crate::{edge::Edge, triad::Triad};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(enum_display::EnumDisplay)]
pub enum Fault
{
#[display("Positive/\"everything is fine\"")]
Positive,
#[display("Competent/\"I take responsibility\"")]
Competent,
#[display("Reactive/\"it's their fault\"")]
Reactive
}
impl Fault
{
pub const fn all() -> [Self; 3]
{
[Self::Positive, Self::Competent, Self::Reactive]
}
}
impl Triad for Fault
{
fn as_any(&self) -> &dyn Any
{
self
}
fn equals(&self, other: &dyn Triad) -> bool
{
other.as_any().downcast_ref().is_some_and(|other| self == other)
}
fn edges(&self) -> &'static [Edge; 3]
{
match self
{
Fault::Positive => &[Edge::Disorganization, Edge::Rest, Edge::Association], Fault::Competent => &[Edge::Recovery, Edge::Repression, Edge::Catatonia], Fault::Reactive => &[Edge::Rejection, Edge::Paranoia, Edge::Action], }
}
fn expression(&self) -> &'static str
{
match self
{
Fault::Positive => "everything is fine",
Fault::Competent => "I take responsibility",
Fault::Reactive => "it's their fault",
}
}
fn reflection(&self) -> &'static str
{
match self
{
Fault::Positive => "you tell yourself that everything is fine",
Fault::Competent => "you hold yourself responsible",
Fault::Reactive => "you blame others"
}
}
}