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