From a0a0c38d66452d3f0068c5e2dae5f4d25523e1e0 Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 20 Feb 2020 23:02:25 -0800 Subject: [PATCH] RoomMode helper functions --- src/ship/room.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ship/room.rs b/src/ship/room.rs index d945ec8..a4fba17 100644 --- a/src/ship/room.rs +++ b/src/ship/room.rs @@ -91,6 +91,27 @@ pub enum RoomMode { } +impl RoomMode { + fn difficulty(&self) -> Difficulty { + match self { + RoomMode::Single {difficulty, ..} => *difficulty, + RoomMode::Multi {difficulty, ..} => *difficulty, + RoomMode::Battle {difficulty, ..} => *difficulty, + RoomMode::Challenge {..} => Difficulty::Normal, + } + } + + fn episode(&self) -> Episode { + match self { + RoomMode::Single {episode, ..} => *episode, + RoomMode::Multi {episode, ..} => *episode, + RoomMode::Battle {episode, ..} => *episode, + RoomMode::Challenge {episode, ..} => *episode, + } + } +} + + #[derive(Debug)] pub struct RoomState { mode: RoomMode,