diff options
Diffstat (limited to 'server/protocol/src/helpers.rs')
| -rw-r--r-- | server/protocol/src/helpers.rs | 36 |
1 files changed, 34 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) } } |