diff --git a/src/entity/character.rs b/src/entity/character.rs index c10bffd..5e24ff3 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -264,6 +264,35 @@ pub struct CharacterMaterials { pub tp: u32, } +#[derive(Debug)] +pub enum PlayerTraps { + FireTrap, + FreezeTrap, + SlowTrap, + ConfuseTrap, +} + +impl PlayerTraps { + fn from(id: u16) -> PlayerTraps { + match id { + 0 => PlayerTraps::FireTrap, + 1 => PlayerTraps::FreezeTrap, + 2 => PlayerTraps::SlowTrap, + 3 => PlayerTraps::ConfuseTrap, + _ => panic!(), + } + } + + fn into(self) -> u16 { + match self { + PlayerTraps::FireTrap => 0, + PlayerTraps::FreezeTrap => 1, + PlayerTraps::SlowTrap => 2, + PlayerTraps::ConfuseTrap => 3, + } + } +} + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub struct CharacterEntityId(pub u32); diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 0ce969a..5c1ff07 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -8,6 +8,7 @@ use crate::ship::ship::{SendShipPacket, ShipError, Rooms, Clients, ItemDropLocat use crate::ship::location::{ClientLocation, ClientLocationError}; use crate::ship::items::{ItemManager, ClientItemId, InventoryItem}; use crate::ship::packet::builder; +use crate::entity::character::{PlayerTraps}; pub async fn request_exp(id: ClientId, request_exp: &RequestExp, @@ -364,3 +365,28 @@ where item_manager.player_sorts_items(entity_gateway, &client.character, pkt.item_ids).await?; Ok(Box::new(None.into_iter())) // Do clients care about the order of other clients items? } + +/* +// 0 - dt +// 1 - ft +// 3 - ct +// TODO: 2 - st? (requires bmode?) +// TODO: do we need to do anything with this packet other than log it and fwd it? +// TODO: do we need to track trap counts in EG? + +pub fn player_trap_set(id: ClientId, + pkt: &PlayerTrapSet, + clients: &Clients) + -> Result + Send>, anyhow::Error> +{ + let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?; + match PlayerTraps::from(pkt.trap_type) { + PlayerTraps::FireTrap => {}, + PlayerTraps::FreezeTrap => {}, + PlayerTraps::SlowTrap => {}, + PlayerTraps::ConfuseTrap {}, + _ => {}, // uhoh + } + +} +*/ \ No newline at end of file