From 3ba0cc9c55b0ee678e433c72b1365480e081fdb2 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 15 Feb 2023 00:49:49 -0700 Subject: [PATCH] initial room entities --- src/entity/mod.rs | 1 + src/entity/room.rs | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/entity/room.rs diff --git a/src/entity/mod.rs b/src/entity/mod.rs index ba0b6e4..8970e37 100644 --- a/src/entity/mod.rs +++ b/src/entity/mod.rs @@ -2,3 +2,4 @@ pub mod gateway; pub mod account; pub mod character; pub mod item; +pub mod room; diff --git a/src/entity/room.rs b/src/entity/room.rs new file mode 100644 index 0000000..9db194e --- /dev/null +++ b/src/entity/room.rs @@ -0,0 +1,87 @@ +use serde::{Serialize, Deserialize}; + + +use crate::entity::character::{CharacterEntityId, SectionID}; +use crate::ship::room::{Episode, Difficulty, RoomMode}; + + +#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub struct RoomEntityId(pub u32); + + +#[derive(Debug, Copy, Clone)] +pub enum RoomEntityMode { + Single, + Multi, + Challenge, + Battle, +} + + +#[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, +} + +impl NewRoomEntity { + fn new(name: String, section_id: SectionID, mode: RoomMode) -> NewRoomEntity { + NewRoomEntity { + name: name, + section_id: section_id, + mode: match mode { + RoomMode::Single {..} => RoomEntityMode::Single, + RoomMode::Multi {..} => RoomEntityMode::Multi, + RoomMode::Challenge {..} => RoomEntityMode::Challenge, + RoomMode::Battle {..} => RoomEntityMode::Battle, + }, + episode: match mode { + RoomMode::Single { episode, .. } => episode, + RoomMode::Multi { episode, ..} => episode , + RoomMode::Challenge { episode, ..} => episode, + RoomMode::Battle { episode, ..} => episode, + }, + difficulty: match mode { + RoomMode::Single { difficulty, .. } => difficulty, + RoomMode::Multi { difficulty, ..} => difficulty , + RoomMode::Challenge {..} => Difficulty::Normal, + RoomMode::Battle { difficulty, ..} => difficulty, + }, + } + } +} + + +#[derive(Debug, Copy, Clone)] +pub enum RoomNote { + Create { + character_id: CharacterEntityId, + }, + PlayerJoin { + character_id: CharacterEntityId, + }, + PlayerLeave { + character_id: CharacterEntityId, + }, + QuestStart { + // quest id + }, + QuestComplete { + // quest id + }, + +}