You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.7 KiB

1 year ago
  1. use serde::{Serialize, Deserialize};
  2. use crate::entity::character::{CharacterEntityId, SectionID};
  3. use crate::ship::room::{Episode, Difficulty};
  4. #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)]
  5. pub struct RoomEntityId(pub u32);
  6. #[derive(Debug, Copy, Clone)]
  7. pub enum RoomEntityMode {
  8. Multi,
  9. Single,
  10. Challenge,
  11. Battle,
  12. }
  13. impl From<u8> for RoomEntityMode {
  14. fn from(other: u8) -> RoomEntityMode {
  15. match other {
  16. 0 => RoomEntityMode::Multi,
  17. 1 => RoomEntityMode::Single,
  18. 2 => RoomEntityMode::Challenge,
  19. 3 => RoomEntityMode::Battle,
  20. _ => unreachable!()
  21. }
  22. }
  23. }
  24. impl From<RoomEntityMode> for u8 {
  25. fn from(other: RoomEntityMode) -> u8 {
  26. match other {
  27. RoomEntityMode::Multi => 0,
  28. RoomEntityMode::Single => 1,
  29. RoomEntityMode::Challenge => 2,
  30. RoomEntityMode::Battle => 3,
  31. }
  32. }
  33. }
  34. #[derive(Debug, Clone)]
  35. pub struct RoomEntity {
  36. pub id: RoomEntityId,
  37. pub name: String,
  38. pub section_id: SectionID,
  39. pub mode: RoomEntityMode,
  40. pub episode: Episode,
  41. pub difficulty: Difficulty,
  42. }
  43. #[derive(Debug, Clone)]
  44. pub struct NewRoomEntity {
  45. pub name: String,
  46. pub section_id: SectionID,
  47. pub mode: RoomEntityMode,
  48. pub episode: Episode,
  49. pub difficulty: Difficulty,
  50. }
  51. #[derive(Debug, Copy, Clone, Serialize)]
  52. pub enum RoomNote {
  53. Create {
  54. character_id: CharacterEntityId,
  55. },
  56. PlayerJoin {
  57. character_id: CharacterEntityId,
  58. },
  59. PlayerLeave {
  60. character_id: CharacterEntityId,
  61. },
  62. QuestStart {
  63. // quest id
  64. },
  65. QuestComplete {
  66. // quest id
  67. },
  68. }