an http based roguelike rpg about jelqing
Blame: src/game/floors.rs
782069860236 | atagen | 2026-10-10 12:44 UTC | 1 | use axum::http::{StatusCode, header}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 2 | use serde_json::{Value, json}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 3 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 4 | use super::{ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 5 | Cause, Elder, Floor, FloorState, Item, Outcome, Run, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 6 | balance::{ |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 7 | DRAWER_JAMS, EQ_BAND, FLOOR_ALLOWANCE, FLOOR_TURNS, FRICTION_FLOOR, GREGS_LOCKER, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 8 | KEY_IN_DRAWER, LOCKER_ROOM_BAR, LOCKER_ROOM_SHAME, RULER_IN_DRAWER, STARTING_EQ, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 9 | SUSPICION_LIMIT, ZIP, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 10 | }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 11 | round2, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 12 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 13 | use crate::problem::Problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 14 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 15 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 16 | pub(super) fn next_floor(&mut self, paid: bool) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 17 | let Some(next) = self.floor.next() else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 18 | return; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | }; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 20 | let warm = EQ_BAND.contains(&self.eq); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 21 | self.floor = next; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 22 | self.here = FloorState { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 23 | warm_arrival: warm, |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 24 | ..FloorState::default() |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 25 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 26 | self.warmed_up = false; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 27 | self.reset_eq(STARTING_EQ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 28 | self.suspicion = 0; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 29 | self.shed(FRICTION_FLOOR); |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 30 | self.mum = None; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 31 | if self.floor == Floor::ChangingRoom && !self.holds_own_in_the_locker_room() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 32 | self.shame += LOCKER_ROOM_SHAME; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 33 | self.notices |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 34 | .push("Kev is 8 inches, he says. Nobody asked you, which is worse."); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 35 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 36 | if paid { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 37 | self.cash += FLOOR_ALLOWANCE; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 38 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 39 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 40 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 41 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 42 | pub fn advance(&mut self) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 43 | match self.floor { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | Floor::Clinic => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 45 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 46 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 47 | "no-further-floor", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | "There is no further floor. There is only the diagnosis.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 50 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 51 | Floor::Forum if self.elder != Elder::Beaten => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 52 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | "elder-unaddressed", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | "The Elder has not been addressed.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | .with("elder", self.path("/elder"))); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | floor if floor.timed() && self.here.turns < FLOOR_TURNS => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 60 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 61 | StatusCode::TOO_EARLY, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 62 | "floor-not-over", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 63 | format!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 64 | "The floor is not over. {} turns remain.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 65 | FLOOR_TURNS - self.here.turns |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 69 | _ => {} |
782069860236 | atagen | 2026-10-10 12:44 UTC | 70 | } |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 71 | if self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 72 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 73 | "zip", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 74 | "As the floor ends and you put yourself away, does the zip catch?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 75 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 76 | ZIP, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 77 | ) { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 78 | return Err(self.end(Cause::Zip)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 79 | } |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 80 | let left = self.floor.name(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 81 | let reverted = self.here.temp_length; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 82 | self.next_floor(true); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 83 | let warm = if self.here.warm_arrival { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 84 | ", and the warmth came with you" |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 85 | } else { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 86 | "" |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 87 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 88 | let mut body = json!({ |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 89 | "detail": format!("You leave {left}. You have arrived at {}{warm}.", self.floor.name()), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 90 | "note": self.floor.note(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 91 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 92 | if reverted > 0.0 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 93 | body["reverted"] = json!(round2(reverted)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 94 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 95 | Ok( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 96 | Outcome::json(StatusCode::SEE_OTHER, body) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 97 | .header(header::LOCATION, self.path("/floor")), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 98 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 99 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 100 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 101 | pub fn floor_view(&self) -> Value { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 102 | let mut view = json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 103 | "name": self.floor.name(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 104 | "note": self.floor.note(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 105 | "turns": self.here.turns, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 106 | "turns_required": self.floor.timed().then_some(FLOOR_TURNS), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 107 | "exit": { "href": self.path("/floor"), "method": "POST" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 108 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 109 | match self.floor { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 110 | Floor::ChangingRoom => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 111 | view["others"] = json!([ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 112 | { "name": "Greg", "self_reported_length": 9.5 }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 113 | { "name": "Dmitri", "self_reported_length": 8.75 }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 114 | { "name": "a man in a towel", "self_reported_length": 11.0 }, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 115 | { "name": "Kev", "self_reported_length": LOCKER_ROOM_BAR }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 116 | ]); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 117 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 118 | Floor::Hotel => view["portal"] = json!(self.path("/portal")), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 119 | Floor::Forum => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 120 | view["thread"] = json!(super::FORUM_THREAD); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 121 | view["elder"] = json!(self.path("/elder")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 122 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 123 | Floor::Clinic => view["diagnosis"] = json!(self.path("/diagnosis")), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 124 | _ => {} |
782069860236 | atagen | 2026-10-10 12:44 UTC | 125 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 126 | if self.floor.shop_open() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 127 | view["shop"] = json!(self.path("/shop")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 128 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 129 | view |
782069860236 | atagen | 2026-10-10 12:44 UTC | 130 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 131 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 132 | fn found(&self, item: Item, detail: &str) -> Outcome { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 133 | Outcome::json(StatusCode::FOUND, json!({ "detail": detail })).header( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 134 | header::LOCATION, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 135 | self.path(&format!("/inventory/{}", item.slug())), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 136 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 137 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 138 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 139 | pub fn search_drawer(&mut self) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 140 | self.touch(); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 141 | self.end_kitchen_visit(); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 142 | if self.items.cage { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 143 | return Ok(self.rummage_for_key()); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 144 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 145 | let first = !self.here.drawer_searched; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 146 | self.here.drawer_searched = true; |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 147 | let ruler_here = self.floor == Floor::Bedroom |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 148 | && self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 149 | self.decision("ruler", "Is there a ruler hiding in the drawer?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 150 | RULER_IN_DRAWER, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 151 | ); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 152 | let vaseline_here = self.floor == Floor::Bathroom |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 153 | && first |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 154 | && self.chance( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 155 | self.decision( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 156 | "bathroom-vaseline", |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 157 | "Is it the vaseline behind the door lock, rather than the lotion?", |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 158 | ), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 159 | 2, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 160 | ); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 161 | let locker_open = self.floor == Floor::ChangingRoom |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 162 | && first |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 163 | && self.chance( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 164 | self.decision("gregs-locker", "Has Greg left his locker open?"), |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 165 | GREGS_LOCKER, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 166 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 167 | match self.floor { |
ad00e0e051a1 | atagen | 2026-10-10 14:00 UTC | 168 | Floor::Bedroom if first && !self.items.ruler && ruler_here => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 169 | self.items.grant(Item::Ruler); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 170 | self.shame += 10; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 171 | Ok(self.found( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 172 | Item::Ruler, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 173 | "You now know. This is the first honest measurement of the run.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 174 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 175 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 176 | Floor::Bathroom if first => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 177 | self.items.grant(Item::DoorLock); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 178 | let detail = if vaseline_here { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 179 | self.items.grant(Item::Vaseline); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 180 | "A door lock, which works once, and a tub of vaseline behind it." |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 181 | } else { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 182 | self.items.grant(Item::Lotion); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 183 | "A door lock, which works once, and a bottle of lotion behind it." |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 184 | }; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 185 | Ok(self.found(Item::DoorLock, detail)) |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 186 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 187 | Floor::ChangingRoom if locker_open => { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 188 | self.items.grant(Item::BabyOil); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 189 | Ok(self.found( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 190 | Item::BabyOil, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 191 | "Greg has left his locker open. The baby oil is yours now, legally speaking.", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 192 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 193 | } |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 194 | Floor::ChangingRoom => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 195 | self.shame += 3; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 196 | Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 197 | StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 198 | "not-your-locker", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 199 | "That locker belongs to Greg. The server cannot serve this request for legal reasons.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 200 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 201 | } |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 202 | Floor::Nans if first => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 203 | self.items.grant(Item::Cage); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 204 | self.shame += 5; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 205 | Ok(self.found( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 206 | Item::Cage, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 207 | "A small box. Inside was a cage. It is now on. The key is not in the box.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 208 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 209 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 210 | Floor::Hotel if first => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 211 | self.items.grant(Item::DndSign); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 212 | self.items.grant(Item::IcePack); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 213 | self.items.grant(Item::IcePack); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 214 | self.items.grant(Item::Lotion); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 215 | Ok(self.found( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 216 | Item::DndSign, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 217 | "A Do Not Disturb sign, two ice packs from the machine down the hall, and a complimentary lotion.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 218 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 219 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 220 | Floor::Forum if first => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 221 | self.items.grant(Item::Spreadsheet); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 222 | Ok(self.found( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 223 | Item::Spreadsheet, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 224 | "Your own spreadsheet. Every line is flat.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 225 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 226 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 227 | Floor::Clinic => Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 228 | StatusCode::FORBIDDEN, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 229 | "doctors-drawer", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 230 | "That is the doctor's drawer.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 231 | )), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 232 | _ => Ok(Outcome::empty(StatusCode::NO_CONTENT)), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 233 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 234 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 235 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 236 | pub fn accept_terms(&mut self) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 237 | if self.floor != Floor::Hotel { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 238 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 239 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 240 | "no-portal", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 241 | "There is no captive portal here. There is only the regular kind of captivity.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 242 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 243 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 244 | self.here.wifi_accepted = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 245 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 246 | Ok(Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 247 | StatusCode::SEE_OTHER, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 248 | json!({ "detail": "Connected. The hotel does not want to know." }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 249 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 250 | .header(header::LOCATION, self.path(""))) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 251 | } |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 252 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 253 | /// Searching while caged is noisy, costs the floor turn, and the key only turns up some of |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 254 | /// the time. A jammed drawer takes a whole turn to work loose. |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 255 | fn rummage_for_key(&mut self) -> Outcome { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 256 | self.turn += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 257 | self.here.turns += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 258 | self.realise(); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 259 | let was_below = self.suspicion < SUSPICION_LIMIT; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 260 | self.suspicion = (self.suspicion + 1).min(SUSPICION_LIMIT); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 261 | self.maybe_summon_mum(was_below); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 262 | if self.here.drawer_jammed { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 263 | self.here.drawer_jammed = false; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 264 | self.notices |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 265 | .push("The drawer comes loose. That took a while."); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 266 | return Outcome::empty(StatusCode::NO_CONTENT); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 267 | } |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 268 | if !self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 269 | self.decision("key", "Does the drawer finally give up the cage key?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 270 | KEY_IN_DRAWER, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 271 | ) { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 272 | if self.chance( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 273 | self.decision("drawer-jams", "Has the drawer jammed on its runners?"), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 274 | DRAWER_JAMS, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 275 | ) { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 276 | self.here.drawer_jammed = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 277 | self.notices.push("The drawer has jammed."); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 278 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 279 | return Outcome::empty(StatusCode::NO_CONTENT); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 280 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 281 | self.items.grant(Item::CageKey); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 282 | Outcome::json( |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 283 | StatusCode::OK, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 284 | json!({ "detail": "The key was in the drawer. The cage is off." }), |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 285 | ) |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 286 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 287 | |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 288 | /// Whether searching the drawer on this floor would turn anything up. |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 289 | pub fn drawer_worth_searching(&self) -> bool { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 290 | !self.here.drawer_searched || self.items.cage |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 291 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 292 | } |