initial room entities
This commit is contained in:
parent
580bed3cb0
commit
3ba0cc9c55
@ -2,3 +2,4 @@ pub mod gateway;
|
|||||||
pub mod account;
|
pub mod account;
|
||||||
pub mod character;
|
pub mod character;
|
||||||
pub mod item;
|
pub mod item;
|
||||||
|
pub mod room;
|
||||||
|
87
src/entity/room.rs
Normal file
87
src/entity/room.rs
Normal file
@ -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
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user