use serde::{Serialize, Deserialize}; use crate::entity::character::{CharacterEntityId, SectionID}; use crate::ship::room::{Episode, Difficulty}; #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub struct RoomEntityId(pub u32); #[derive(Debug, Copy, Clone)] pub enum RoomEntityMode { Multi, Single, Challenge, Battle, } impl From for RoomEntityMode { fn from(other: u8) -> RoomEntityMode { match other { 0 => RoomEntityMode::Multi, 1 => RoomEntityMode::Single, 2 => RoomEntityMode::Challenge, 3 => RoomEntityMode::Battle, _ => unreachable!() } } } impl From for u8 { fn from(other: RoomEntityMode) -> u8 { match other { RoomEntityMode::Multi => 0, RoomEntityMode::Single => 1, RoomEntityMode::Challenge => 2, RoomEntityMode::Battle => 3, } } } #[derive(Debug, Clone)] pub struct RoomEntity { pub id: RoomEntityId, pub name: String, pub section_id: SectionID, pub mode: RoomEntityMode, pub episode: Episode, pub difficulty: Difficulty, } #[derive(Debug, Clone)] pub struct NewRoomEntity { pub name: String, pub section_id: SectionID, pub mode: RoomEntityMode, pub episode: Episode, pub difficulty: Difficulty, } #[derive(Debug, Copy, Clone, Serialize)] pub enum RoomNote { Create { character_id: CharacterEntityId, }, PlayerJoin { character_id: CharacterEntityId, }, PlayerLeave { character_id: CharacterEntityId, }, QuestStart { // quest id }, QuestComplete { // quest id }, }