an http based roguelike rpg about jelqing
| 1 | use axum::http::StatusCode; |
| 2 | |
| 3 | use crate::problem::Problem; |
| 4 | |
| 5 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 6 | #[repr(u8)] |
| 7 | pub enum Floor { |
| 8 | Bedroom = 1, |
| 9 | Bathroom = 2, |
| 10 | ChangingRoom = 3, |
| 11 | Nans = 4, |
| 12 | Hotel = 5, |
| 13 | Forum = 6, |
| 14 | Clinic = 7, |
| 15 | } |
| 16 | |
| 17 | impl Floor { |
| 18 | pub fn number(self) -> u8 { |
| 19 | self as u8 |
| 20 | } |
| 21 | |
| 22 | pub fn next(self) -> Option<Self> { |
| 23 | match self { |
| 24 | Self::Bedroom => Some(Self::Bathroom), |
| 25 | Self::Bathroom => Some(Self::ChangingRoom), |
| 26 | Self::ChangingRoom => Some(Self::Nans), |
| 27 | Self::Nans => Some(Self::Hotel), |
| 28 | Self::Hotel => Some(Self::Forum), |
| 29 | Self::Forum => Some(Self::Clinic), |
| 30 | Self::Clinic => None, |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | pub fn name(self) -> &'static str { |
| 35 | match self { |
| 36 | Self::Bedroom => "the bedroom", |
| 37 | Self::Bathroom => "the shared bathroom", |
| 38 | Self::ChangingRoom => "the gym changing room", |
| 39 | Self::Nans => "Nan's house at Christmas", |
| 40 | Self::Hotel => "a business trip hotel", |
| 41 | Self::Forum => "the forum", |
| 42 | Self::Clinic => "the urologist's office", |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | pub fn note(self) -> &'static str { |
| 47 | match self { |
| 48 | Self::Bedroom => "The door does not lock. The cat is present.", |
| 49 | Self::Bathroom => "The water is hot. Your brother showers at eight.", |
| 50 | Self::ChangingRoom => { |
| 51 | "It is cold. Discretion is advised. Everyone here is lying. Pump-Bro is by the lockers." |
| 52 | } |
| 53 | Self::Nans => { |
| 54 | "The walls are thin. Mum is here, and she has been reading about Digest authentication." |
| 55 | } |
| 56 | Self::Hotel => { |
| 57 | "The wifi requires agreement. Housekeeping does not knock. Pump-Bro is in the lobby." |
| 58 | } |
| 59 | Self::Forum => "Nothing physical happens here. The Elder has a spreadsheet.", |
| 60 | Self::Clinic => "The urologist will see you now. He is bored.", |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | pub fn observer(self) -> Option<Observer> { |
| 65 | match self { |
| 66 | Self::Bedroom => Some(Observer::Cat), |
| 67 | Self::ChangingRoom => Some(Observer::Greg), |
| 68 | Self::Nans => Some(Observer::Nan), |
| 69 | _ => None, |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | pub fn has_mum(self) -> bool { |
| 74 | matches!(self, Self::Bedroom | Self::Nans) |
| 75 | } |
| 76 | |
| 77 | pub fn has_window(self) -> bool { |
| 78 | matches!(self, Self::Bedroom | Self::Nans | Self::Hotel) |
| 79 | } |
| 80 | |
| 81 | pub fn shop_open(self) -> bool { |
| 82 | matches!(self, Self::ChangingRoom | Self::Hotel) |
| 83 | } |
| 84 | |
| 85 | pub fn timed(self) -> bool { |
| 86 | !matches!(self, Self::Forum | Self::Clinic) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 91 | pub enum Observer { |
| 92 | Cat, |
| 93 | Greg, |
| 94 | Nan, |
| 95 | } |
| 96 | |
| 97 | impl Observer { |
| 98 | pub fn name(self) -> &'static str { |
| 99 | match self { |
| 100 | Self::Cat => "cat", |
| 101 | Self::Greg => "greg", |
| 102 | Self::Nan => "nan", |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 108 | pub enum Grip { |
| 109 | Overhand, |
| 110 | Underhand, |
| 111 | } |
| 112 | |
| 113 | impl Grip { |
| 114 | pub fn name(self) -> &'static str { |
| 115 | match self { |
| 116 | Self::Overhand => "overhand", |
| 117 | Self::Underhand => "underhand", |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | pub fn parse(protocol: &str) -> Option<Self> { |
| 122 | match protocol.to_ascii_lowercase().as_str() { |
| 123 | "overhand" => Some(Self::Overhand), |
| 124 | "underhand" => Some(Self::Underhand), |
| 125 | _ => None, |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /// State that belongs to the current floor and resets when you leave it. |
| 131 | #[derive(Default)] |
| 132 | pub struct FloorState { |
| 133 | pub turns: u32, |
| 134 | pub drawer_searches: u8, |
| 135 | pub edges: u8, |
| 136 | pub temp_length: f64, |
| 137 | pub teapot: bool, |
| 138 | pub towel_stolen: bool, |
| 139 | pub brother_told: bool, |
| 140 | pub shopping: bool, |
| 141 | pub wifi_accepted: bool, |
| 142 | } |
| 143 | |
| 144 | #[derive(Default)] |
| 145 | pub struct Conditions { |
| 146 | pub peyronie: bool, |
| 147 | pub pulled_muscle: bool, |
| 148 | pub priapism_turns: u8, |
| 149 | } |
| 150 | |
| 151 | pub struct MumVisit { |
| 152 | pub errand: &'static str, |
| 153 | pub nonce: String, |
| 154 | pub strikes: u8, |
| 155 | pub knocked: bool, |
| 156 | } |
| 157 | |
| 158 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 159 | pub enum Elder { |
| 160 | Unverified { strikes: u8 }, |
| 161 | Verified, |
| 162 | Beaten, |
| 163 | } |
| 164 | |
| 165 | #[derive(Default)] |
| 166 | pub struct Clinic { |
| 167 | pub intake_attempts: usize, |
| 168 | pub measured: bool, |
| 169 | pub cured: bool, |
| 170 | } |
| 171 | |
| 172 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 173 | pub enum Story { |
| 174 | Unopened, |
| 175 | Pending, |
| 176 | ReadForum, |
| 177 | ClosedTab, |
| 178 | } |
| 179 | |
| 180 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 181 | pub enum Cause { |
| 182 | Ruptured { ice_unused: bool }, |
| 183 | Caught, |
| 184 | Opened, |
| 185 | Banned, |
| 186 | Degloved, |
| 187 | Zip, |
| 188 | Abandoned, |
| 189 | } |
| 190 | |
| 191 | impl Cause { |
| 192 | pub fn slug(self) -> &'static str { |
| 193 | match self { |
| 194 | Self::Ruptured { .. } => "vascular-event", |
| 195 | Self::Caught => "caught", |
| 196 | Self::Opened => "opened", |
| 197 | Self::Banned => "banned", |
| 198 | Self::Degloved => "degloved", |
| 199 | Self::Zip => "zip", |
| 200 | Self::Abandoned => "abandoned", |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | pub fn detail(self) -> &'static str { |
| 205 | match self { |
| 206 | Self::Ruptured { ice_unused: true } => { |
| 207 | "A vessel has exceeded its rated pressure. The run has ended. An ice pack was available and was not used." |
| 208 | } |
| 209 | Self::Ruptured { ice_unused: false } => { |
| 210 | "A vessel has exceeded its rated pressure. The run has ended." |
| 211 | } |
| 212 | Self::Caught => { |
| 213 | "Mum has seen enough. The run has ended. Nobody will mention it at dinner." |
| 214 | } |
| 215 | Self::Opened => { |
| 216 | "Mum has stopped knocking and opened the door. The run has ended. Nobody will mention it at dinner." |
| 217 | } |
| 218 | Self::Banned => "Your account has been banned. The forum can tell. The run has ended.", |
| 219 | Self::Degloved => { |
| 220 | "The outer layer has been removed in one piece. It will not be returning. The run has ended." |
| 221 | } |
| 222 | Self::Zip => { |
| 223 | "The request conflicts with the current state of the zip. The run has ended." |
| 224 | } |
| 225 | Self::Abandoned => "The run was abandoned.", |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | fn status(self) -> StatusCode { |
| 230 | match self { |
| 231 | Self::Ruptured { .. } => StatusCode::INTERNAL_SERVER_ERROR, |
| 232 | Self::Caught | Self::Opened | Self::Degloved | Self::Abandoned => StatusCode::GONE, |
| 233 | Self::Banned => StatusCode::FORBIDDEN, |
| 234 | Self::Zip => StatusCode::CONFLICT, |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | pub fn problem(self) -> Problem { |
| 239 | Problem::new(self.status(), self.slug(), self.detail()) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | pub struct Ending { |
| 244 | pub cause: Cause, |
| 245 | pub turn: u32, |
| 246 | } |
| 247 | |
| 248 | pub struct Pending { |
| 249 | pub due: u32, |
| 250 | pub length: f64, |
| 251 | pub girth: f64, |
| 252 | } |