use bevy_ecs::prelude::*;
use serde::Deserialize;
use serde::Serialize;
use std::cmp::Ordering;
use std::fmt::Debug;
#[derive(Default, Debug, Component)]
#[component(storage = "SparseSet")]
pub struct Scoring;
#[derive(
Debug, Default, Serialize, Deserialize, Clone, Copy, Component, PartialEq,
)]
pub enum Score {
#[default]
Fail,
Weight(f32),
Pass,
}
impl PartialOrd for Score {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let val = match (self, other) {
(Score::Fail, Score::Fail) => Ordering::Equal,
(Score::Fail, _) => Ordering::Less,
(_, Score::Fail) => Ordering::Greater,
(Score::Pass, Score::Pass) => Ordering::Equal,
(Score::Pass, _) => Ordering::Greater,
(_, Score::Pass) => Ordering::Less,
(Score::Weight(w1), Score::Weight(w2)) => w1.total_cmp(&w2),
};
Some(val)
}
}