#![allow(missing_docs)]
use sc2_proto;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum Race {
Protoss,
Terran,
Zerg,
Random,
}
impl Race {
pub fn from_proto(race: sc2_proto::common::Race) -> Self {
use sc2_proto::common::Race;
match race {
Race::Protoss => Self::Protoss,
Race::Terran => Self::Terran,
Race::Zerg => Self::Zerg,
Race::Random => Self::Random,
Race::NoRace => panic!("NoRace not alloed"),
}
}
pub fn to_proto(&self) -> sc2_proto::common::Race {
use sc2_proto::common::Race;
match self {
Self::Protoss => Race::Protoss,
Self::Terran => Race::Terran,
Self::Zerg => Race::Zerg,
Self::Random => Race::Random,
}
}
}
impl Default for Race {
fn default() -> Self {
Race::Random
}
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum Difficulty {
VeryEasy,
Easy,
Medium,
MediumHard,
Hard,
Harder,
VeryHard,
CheatVision,
CheatMoney,
CheatInsane,
}
impl Difficulty {
pub fn to_proto(&self) -> sc2_proto::sc2api::Difficulty {
use sc2_proto::sc2api::Difficulty;
match self {
Self::VeryEasy => Difficulty::VeryEasy,
Self::Easy => Difficulty::Easy,
Self::Medium => Difficulty::Medium,
Self::MediumHard => Difficulty::MediumHard,
Self::Hard => Difficulty::Hard,
Self::Harder => Difficulty::Harder,
Self::VeryHard => Difficulty::VeryHard,
Self::CheatVision => Difficulty::CheatVision,
Self::CheatMoney => Difficulty::CheatMoney,
Self::CheatInsane => Difficulty::CheatInsane,
}
}
}
impl Default for Difficulty {
fn default() -> Self {
Difficulty::Hard
}
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
pub struct BuiltinAI {
pub race: Race,
pub difficulty: Difficulty,
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum PlayerResult {
Victory,
Defeat,
Tie,
}
impl PlayerResult {
pub fn from_proto(race: sc2_proto::sc2api::Result) -> Self {
use sc2_proto::sc2api::Result;
match race {
Result::Victory => Self::Victory,
Result::Defeat => Self::Defeat,
Result::Tie => Self::Tie,
Result::Undecided => panic!("Undecided result not alloed"),
}
}
pub fn to_proto(&self) -> sc2_proto::sc2api::Result {
use sc2_proto::sc2api::Result;
match self {
Self::Victory => Result::Victory,
Self::Defeat => Result::Defeat,
Self::Tie => Result::Tie,
}
}
}