use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
pub enum CardEdgeType {
Blocks,
RelatesTo,
#[default]
Spawns,
}
impl CardEdgeType {
pub fn requires_dag(&self) -> bool {
matches!(self, CardEdgeType::Blocks | CardEdgeType::Spawns)
}
pub fn allows_cycles(&self) -> bool {
!self.requires_dag()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_blocks_requires_dag() {
assert!(CardEdgeType::Blocks.requires_dag());
assert!(!CardEdgeType::Blocks.allows_cycles());
}
#[test]
fn test_relates_to_allows_cycles() {
assert!(!CardEdgeType::RelatesTo.requires_dag());
assert!(CardEdgeType::RelatesTo.allows_cycles());
}
#[test]
fn test_spawns_requires_dag() {
assert!(CardEdgeType::Spawns.requires_dag());
assert!(!CardEdgeType::Spawns.allows_cycles());
}
}