diff options
Diffstat (limited to 'server/client-lib/src/lib.rs')
-rw-r--r-- | server/client-lib/src/lib.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/server/client-lib/src/lib.rs b/server/client-lib/src/lib.rs index d949ac6e..b04f46f7 100644 --- a/server/client-lib/src/lib.rs +++ b/server/client-lib/src/lib.rs @@ -20,8 +20,8 @@ pub mod network; pub mod spatial_index; use hurrycurry_protocol::{ - glam::IVec2, movement::MovementBase, ClientGamedata, ItemIndex, ItemLocation, Message, PacketC, - PlayerID, Score, TileIndex, + glam::IVec2, movement::MovementBase, Gamedata, ItemIndex, ItemLocation, Message, PacketC, + PlayerID, RecipeIndex, Score, TileIndex, }; use spatial_index::SpatialIndex; use std::{ @@ -31,9 +31,17 @@ use std::{ }; #[derive(Debug, PartialEq)] +pub struct Involvement { + pub progress: f32, + pub recipe: RecipeIndex, + pub working: usize, + pub warn: bool, +} + +#[derive(Debug, PartialEq)] pub struct Item { pub kind: ItemIndex, - pub progress: Option<(f32, bool)>, + pub active: Option<Involvement>, } pub struct Tile { @@ -52,7 +60,7 @@ pub struct Player { } pub struct Game { - pub data: Arc<ClientGamedata>, + pub data: Arc<Gamedata>, pub tiles: HashMap<IVec2, Tile>, pub walkable: HashSet<IVec2>, pub players: HashMap<PlayerID, Player>, @@ -125,17 +133,20 @@ impl Game { *self.get_item(to) = self.get_item(from).take(); } PacketC::SetItem { location, item } => { - *self.get_item(location) = item.map(|kind| Item { - kind, - progress: None, - }); + *self.get_item(location) = item.map(|kind| Item { kind, active: None }); } PacketC::SetProgress { item, progress, warn, } => { - self.get_item(item).as_mut().unwrap().progress = progress.map(|s| (s, warn)); + self.get_item(item).as_mut().unwrap().active = + progress.map(|progress| Involvement { + working: 1, + warn, + progress, + recipe: RecipeIndex(0), + }); } PacketC::UpdateMap { tile, @@ -204,3 +215,9 @@ impl Game { } } } + +impl From<TileIndex> for Tile { + fn from(kind: TileIndex) -> Self { + Self { kind, item: None } + } +} |