ks_constants_rs 0.1.2

Constants for use in Kerrigan Survival projects
Documentation
use pyo3::prelude::*;

#[pyclass]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Team {
    Survivor,
    Kerrigan
}

impl Team {
    pub fn get_max_size(&self) -> usize {
        match self {
            Self::Survivor => 8,
            Self::Kerrigan => 2
        }
    }

    pub fn to_int(&self) -> usize {
        match self {
            Self::Survivor => 0,
            Self::Kerrigan => 1
        }
    }

    pub fn from_index(index: usize) -> Self {
        match index {
            0 => Self::Survivor,
            1 => Self::Kerrigan,
            _ => panic!("Not a valid index")
        }
    }
}

#[pyclass]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum RoleType {
    Builder,
    Support,
    Defender,
    Hunter,
}

impl RoleType {
    pub fn get_team(&self) -> Team {
        match self {
            Self::Builder => Team::Survivor,
            Self::Support => Team::Survivor,
            Self::Defender => Team::Kerrigan,
            Self::Hunter => Team::Kerrigan
        }
    }

    pub fn to_int(&self) -> usize {
        match self {
            Self::Builder => 0,
            Self::Support => 1,
            Self::Defender => 2,
            Self::Hunter => 3
        }
    }
}