diff options
author | metamuffin <metamuffin@disroot.org> | 2024-12-25 19:37:20 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-12-25 20:01:43 +0100 |
commit | 4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf (patch) | |
tree | 5ec12de003c38f0891c215721593c7ea49ff2c16 /server/protocol | |
parent | 15be00667282a253fb438fec9d6347f5af89d9a0 (diff) | |
download | hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.bz2 hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.zst |
variable hand count
Diffstat (limited to 'server/protocol')
-rw-r--r-- | server/protocol/src/helpers.rs | 21 | ||||
-rw-r--r-- | server/protocol/src/lib.rs | 8 |
2 files changed, 4 insertions, 25 deletions
diff --git a/server/protocol/src/helpers.rs b/server/protocol/src/helpers.rs index 21835101..b85c2f84 100644 --- a/server/protocol/src/helpers.rs +++ b/server/protocol/src/helpers.rs @@ -106,26 +106,7 @@ impl Display for ItemLocation { impl Display for Hand { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(match self { - Hand::Left => "left", - Hand::Right => "right", - }) - } -} - -impl Hand { - pub fn index(&self) -> usize { - match self { - Hand::Left => 0, - Hand::Right => 1, - } - } - pub fn from_index(i: usize) -> Self { - match i { - 0 => Hand::Left, - 1 => Hand::Right, - _ => Hand::Left, - } + write!(f, "h{}", self.0) } } diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs index 5c7ddeb5..74d463a1 100644 --- a/server/protocol/src/lib.rs +++ b/server/protocol/src/lib.rs @@ -72,11 +72,8 @@ pub struct RecipeIndex(pub usize); pub struct DemandIndex(pub usize); #[derive(Debug, Clone, Copy, Serialize, Deserialize, Encode, Decode, PartialEq, Eq, Hash)] -#[serde(rename_all = "snake_case")] -pub enum Hand { - Left, - Right, -} +#[serde(transparent)] +pub struct Hand(pub usize); #[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)] pub struct MapMetadata { @@ -105,6 +102,7 @@ pub struct Gamedata { pub bot_algos: Vec<String>, pub recipes: Vec<Recipe>, pub demands: Vec<Demand>, + pub hand_count: usize, } #[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)] |