team04_server/unit/
mod.rs

1//! Definition of units and fight-related things used by those units.
2
3use rand::seq::IndexedRandom;
4use serde::{Deserialize, Serialize};
5use std::hash::Hash;
6use strum::VariantArray;
7
8/// The Unit type enum from the spec
9#[derive(
10    Deserialize, Serialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, VariantArray,
11)]
12#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
13pub enum UnitType {
14    Wookie,
15    Droid,
16    Gamorrean,
17    Rodian,
18    Stormtrooper,
19    Ewok,
20    Rebel,
21    Hutt,
22    Jedi,
23    Sith,
24}
25
26/// The lightsaber type enum from the spec
27#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Hash, Clone, Copy, VariantArray)]
28#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
29pub enum LightsaberType {
30    Red,
31    Green,
32    Blue,
33}
34
35impl LightsaberType {
36    pub fn random() -> Self {
37        *Self::VARIANTS.choose(&mut rand::rng()).unwrap()
38    }
39}