aboutsummaryrefslogtreecommitdiff
path: root/server/protocol
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-10-11 22:25:31 +0200
committermetamuffin <metamuffin@disroot.org>2025-10-11 22:25:31 +0200
commit516546c3d20e1715370073acf2e6b8114351f8e9 (patch)
tree19ebabed6785372015d801adfe744be778c00a05 /server/protocol
parentcdaa8e800276e28c720f846c91e144af97227db7 (diff)
downloadhurrycurry-516546c3d20e1715370073acf2e6b8114351f8e9.tar
hurrycurry-516546c3d20e1715370073acf2e6b8114351f8e9.tar.bz2
hurrycurry-516546c3d20e1715370073acf2e6b8114351f8e9.tar.zst
Improve server logging and use central player id counter (close #450)
Diffstat (limited to 'server/protocol')
-rw-r--r--server/protocol/src/helpers.rs36
-rw-r--r--server/protocol/src/registry.rs17
2 files changed, 51 insertions, 2 deletions
diff --git a/server/protocol/src/helpers.rs b/server/protocol/src/helpers.rs
index 92668df4..098767b5 100644
--- a/server/protocol/src/helpers.rs
+++ b/server/protocol/src/helpers.rs
@@ -1,3 +1,20 @@
+/*
+ Hurry Curry! - a game about cooking
+ Copyright (C) 2025 Hurry Curry! Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, version 3 of the License only.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+*/
use crate::{Gamedata, Hand, ItemIndex, ItemLocation, PlayerID, Recipe, RecipeIndex, TileIndex};
use std::fmt::Display;
@@ -89,13 +106,28 @@ impl Display for ItemLocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ItemLocation::Tile(pos) => write!(f, "tile({pos})"),
- ItemLocation::Player(PlayerID(id), hand) => write!(f, "player({id}_{hand})"),
+ ItemLocation::Player(PlayerID(id), hand) => write!(f, "{id}-{hand}"),
}
}
}
impl Display for Hand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "h{}", self.0)
+ write!(f, "hand({})", self.0)
+ }
+}
+impl Display for PlayerID {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "player({})", self.0)
+ }
+}
+impl Display for TileIndex {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "tile({})", self.0)
+ }
+}
+impl Display for ItemIndex {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "item({})", self.0)
}
}
diff --git a/server/protocol/src/registry.rs b/server/protocol/src/registry.rs
index b5b83bd1..10f12320 100644
--- a/server/protocol/src/registry.rs
+++ b/server/protocol/src/registry.rs
@@ -1,3 +1,20 @@
+/*
+ Hurry Curry! - a game about cooking
+ Copyright (C) 2025 Hurry Curry! Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, version 3 of the License only.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+*/
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]