use num_traits::{One, Signed, Zero}; use parity_scale_codec::{Encode, Decode}; #[derive(Debug, Default)] pub struct Board { pub size: (usize, usize), } pub trait Position { fn get_position(&self) -> (i32, i32); } #[derive(Clone, Copy, Debug, Decode, Encode, Eq, PartialEq, Hash)] pub enum Direction { East, North, South, West, } impl Direction { pub fn to_position(&self) -> (T, T) { match self { Self::East => (T::one(), T::zero()), Self::North => (T::zero(), T::one().neg()), Self::South => (T::zero(), T::one()), Self::West => (T::one().neg(), T::zero()), } } } impl sp_runtime_interface::pass_by::PassBy for Direction { type PassBy = sp_runtime_interface::pass_by::Codec; }