an http based roguelike rpg about jelqing
Blame: src/game/turn.rs
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1 | use std::{fmt::Write as _, ops::ControlFlow}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 2 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 3 | use axum::http::{StatusCode, header}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 4 | use serde_json::json; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 5 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 6 | use super::{ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 7 | Floor, Grip, LUBRICANTS, Lube, Outcome, Payload, Run, Story, Technique, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 8 | balance::{ |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 9 | ARRIVAL_BONUS, BAND_BONUS, BRANCH_TURN, CAT_TAKES_TOWEL, CHANGING_ROOM_CHILL, DANGER_EQ, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 10 | EQ_BAND, EQ_WOBBLE, EXTENDER_GAIN, FORESKIN_GLIDE, FRICTION_BURN, FRICTION_BURN_AT, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 11 | FRICTION_DRY, FRICTION_GRIP, FRICTION_HOLD, FRICTION_MAX, FRICTION_MEDITATE, FRICTION_SPIT, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 12 | GIRTH_THICK, GREED_HOT, GREED_WARM, HOLD_EQ, HOT_EQ, MEDITATION_EQ, OBSERVED, PRIAPISM_EQ, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 13 | PRIAPISM_TURNS, PULLED_MUSCLE, PULLED_MUSCLE_INTENSITY, REFLECTION, RING_PRIAPISM, |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 14 | RING_RUPTURE_LINE, RING_TIGHT_PRIAPISM, RUPTURE_HOLD, RUPTURE_LINE, STORAGE_BULK, |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 15 | SUSPICION_LIMIT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 16 | }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 17 | not_extended, round3, |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 18 | state::{MumVisit, Observer, Pending}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | techniques::{LubeRule, Profile, Training, Utility}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 20 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 21 | use crate::{headers::SERVER_TIMING, problem::Problem}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 22 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 23 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 24 | pub fn jelq( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 25 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 26 | techniques: &[Technique], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 27 | intensity: i32, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 28 | lube: Option<Lube>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 29 | ) -> Result<Outcome, Problem> { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 30 | self.check_exhausted()?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 31 | if self.story == Story::Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 32 | return Ok(self.branch_offer()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 33 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 34 | if self.floor == Floor::Forum { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 35 | return Ok(Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 36 | StatusCode::SEE_OTHER, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 37 | json!({ "detail": "Refer to the forum." }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 38 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 39 | .header(header::LOCATION, super::FORUM_THREAD)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 40 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 41 | if self.items.cage { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 42 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 43 | StatusCode::LOCKED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | "caged", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 45 | "The cage is locked. The key is not in the box.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 46 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 47 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | match *techniques { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 49 | [Technique::Utility(utility)] => self.utility(utility, lube), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 50 | [Technique::Training(training)] => self.single(training, intensity, lube), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 51 | [Technique::Training(a), Technique::Training(b)] => self.combo(a, b, intensity, lube), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 52 | [_, _] => Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | StatusCode::BAD_REQUEST, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | "combo-invalid", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | "Only training techniques can be combined.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | )), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | _ => Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | StatusCode::BAD_REQUEST, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | "too-many-techniques", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 60 | "Two techniques at most. The server has limits even if you do not.", |
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 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 65 | fn utility(&mut self, utility: Utility, lube: Option<Lube>) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | match utility { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | Utility::Warmup => return self.warm_up(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | Utility::Ice => return self.ice(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 69 | Utility::Supplement => return self.supplement(), |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 70 | Utility::Meditate => return self.meditate(), |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 71 | Utility::Energy => return self.energy(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 72 | Utility::Edge | Utility::Pump => {} |
782069860236 | atagen | 2026-10-10 12:44 UTC | 73 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 74 | self.ready(Technique::Utility(utility), lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 75 | self.check_storage()?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 76 | self.floor_enemy()?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 77 | match utility { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 78 | Utility::Edge => self.edge(), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 79 | _ => self.pump(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 80 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 81 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 82 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 83 | fn single( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 84 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 85 | training: Training, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 86 | intensity: i32, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 87 | lube: Option<Lube>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 88 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 89 | self.ready(Technique::Training(training), lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 90 | self.check_storage()?; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 91 | self.lube_available(lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 92 | self.floor_enemy()?; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 93 | self.take_lube(lube)?; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 94 | self.chafe(lube, intensity); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 95 | self.commit(intensity, lube, 1); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 96 | if let ControlFlow::Break(interrupted) = self.mishaps(training, intensity)? { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 97 | return Ok(interrupted); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 98 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 99 | if let ControlFlow::Break(interrupted) = self.hazards(intensity)? { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 100 | return Ok(interrupted); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 101 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 102 | let outcome = self.roll(training, intensity, lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 103 | Ok(self.gossip(outcome)) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 104 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 105 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 106 | fn combo( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 107 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 108 | a: Training, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 109 | b: Training, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 110 | intensity: i32, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 111 | lube: Option<Lube>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 112 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 113 | if a == b { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 114 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 115 | StatusCode::BAD_REQUEST, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 116 | "combo-invalid", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 117 | "A technique cannot be combined with itself. The server has checked.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 118 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 119 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 120 | self.ready(Technique::Training(a), lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 121 | self.ready(Technique::Training(b), lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 122 | self.check_storage()?; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 123 | self.lube_available(lube)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 124 | self.floor_enemy()?; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 125 | self.take_lube(lube)?; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 126 | self.chafe(lube, intensity); |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 127 | self.chafe(lube, intensity); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 128 | self.commit(intensity, lube, 2); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 129 | for training in [a, b] { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 130 | if let ControlFlow::Break(interrupted) = self.mishaps(training, intensity)? { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 131 | return Ok(interrupted); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 132 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 133 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 134 | if let ControlFlow::Break(interrupted) = self.hazards(intensity)? { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 135 | return Ok(interrupted); |
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 | let mut statuses = Vec::new(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 139 | for training in [a, b] { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 140 | let result = self.roll(training, intensity, lube); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 141 | if self.ended.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 142 | return result; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 143 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 144 | let status = match result { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 145 | Ok(outcome) => self.gossip(outcome).status, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 146 | Err(problem) => problem.status(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 147 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 148 | statuses.push((training, status)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 149 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 150 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 151 | let mut xml = String::from( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 152 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<D:multistatus xmlns:D=\"DAV:\">\n", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 153 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 154 | for (training, status) in statuses { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 155 | let _ = write!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 156 | xml, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 157 | " <D:response>\n <D:href>{}?technique={}</D:href>\n <D:status>HTTP/1.1 {} {}</D:status>\n </D:response>\n", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 158 | self.path(""), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 159 | training.name(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 160 | status.as_u16(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 161 | crate::problem::reason(status), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 162 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 163 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 164 | xml.push_str( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 165 | " <D:responsedescription>Each technique has been reported separately.</D:responsedescription>\n</D:multistatus>\n", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 166 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 167 | Ok(Outcome::raw( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 168 | StatusCode::MULTI_STATUS, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 169 | "application/xml; charset=utf-8", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 170 | xml, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 171 | )) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 172 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 173 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 174 | fn ready(&self, technique: Technique, lube: Option<Lube>) -> Result<(), Problem> { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 175 | self.access(technique)?; |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 176 | match technique { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 177 | Technique::Training(training) => Self::check_lube(training, lube), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 178 | Technique::Utility(_) => Ok(()), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 179 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 180 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 181 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 182 | /// Whether the run could attempt the technique now, ignoring the lubricant. |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 183 | fn access(&self, technique: Technique) -> Result<(), Problem> { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 184 | if technique == Technique::Training(Training::Uli) && !self.uli_taught { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 185 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 186 | StatusCode::FORBIDDEN, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 187 | "technique-locked", |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 188 | "uli is discussed on the forum, in a thread from 2009, by a man who never posted again. You have not found the reply.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 189 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 190 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 191 | if !self.warmed_up { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 192 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 193 | StatusCode::PRECONDITION_FAILED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 194 | "cold-start", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 195 | "Warm-up was skipped. The server has noted this.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 196 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 197 | .with("technique", Utility::Warmup.name())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 198 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 199 | if matches!(technique, Technique::Training(_)) { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 200 | self.grip_closes(self.grip)?; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 201 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 202 | match technique { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 203 | Technique::Utility(Utility::Pump) if !self.items.pump_pro => Err(Problem::new( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 204 | StatusCode::FAILED_DEPENDENCY, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 205 | "no-pump", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 206 | "The pump technique depends on a pump.", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 207 | )), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 208 | Technique::Utility(_) => Ok(()), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 209 | Technique::Training(training) => match training.profile().foreskin { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 210 | Some((min, max)) => self.check_foreskin(min, max), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 211 | None => Ok(()), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 212 | }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 213 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 214 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 215 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 216 | fn check_lube(training: Training, lube: Option<Lube>) -> Result<(), Problem> { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 217 | match (training.profile().lube, lube) { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 218 | (LubeRule::Required, None) => Err(Problem::new( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 219 | StatusCode::UNSUPPORTED_MEDIA_TYPE, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 220 | "lubricant-required", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 221 | format!( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 222 | "The {} technique requires a lubricant. None was declared.", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 223 | training.name() |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 224 | ), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 225 | ) |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 226 | .with("lubricants", json!(LUBRICANTS))), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 227 | (LubeRule::Forbidden, Some(_)) => Err(Problem::new( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 228 | StatusCode::UNSUPPORTED_MEDIA_TYPE, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 229 | "lubricant-declared", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 230 | format!( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 231 | "The {} technique was requested. A lubricant was declared.", |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 232 | training.name() |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 233 | ), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 234 | )), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 235 | _ => Ok(()), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 236 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 237 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 238 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 239 | /// One unit of whatever was declared. Spit is free and the tap is always on. |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 240 | fn lube_available(&self, lube: Option<Lube>) -> Result<(), Problem> { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 241 | let (held, name) = match lube { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 242 | None | Some(Lube::Spit) => return Ok(()), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 243 | Some(Lube::BabyOil) => (&self.items.baby_oil, "baby-oil"), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 244 | Some(Lube::CoconutOil) => (&self.items.coconut_oil, "coconut-oil"), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 245 | Some(Lube::Lotion) => (&self.items.lotion, "lotion"), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 246 | Some(Lube::Vaseline) => (&self.items.vaseline, "vaseline"), |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 247 | }; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 248 | if *held == 0 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 249 | return Err(Problem::new( |
139164489032 | atagen | 2026-10-11 05:46 UTC | 250 | StatusCode::UNSUPPORTED_MEDIA_TYPE, |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 251 | "lubricant-exhausted", |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 252 | format!("{name} was declared, but the bottle is empty."), |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 253 | )); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 254 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 255 | Ok(()) |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 256 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 257 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 258 | fn take_lube(&mut self, lube: Option<Lube>) -> Result<(), Problem> { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 259 | self.lube_available(lube)?; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 260 | let held = match lube { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 261 | None | Some(Lube::Spit) => return Ok(()), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 262 | Some(Lube::BabyOil) => &mut self.items.baby_oil, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 263 | Some(Lube::CoconutOil) => &mut self.items.coconut_oil, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 264 | Some(Lube::Lotion) => &mut self.items.lotion, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 265 | Some(Lube::Vaseline) => &mut self.items.vaseline, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 266 | }; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 267 | *held -= 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 268 | Ok(()) |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 269 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 270 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 271 | /// The techniques a JELQ could use right now without being refused before the roll. |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 272 | pub fn techniques_now(&self) -> Vec<Technique> { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 273 | let blocked = !self.floor.timed() || self.items.cage || self.exhausted; |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 274 | if blocked { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 275 | return Vec::new(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 276 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 277 | Technique::ALL |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 278 | .into_iter() |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 279 | .filter(|&technique| match technique { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 280 | Technique::Utility(Utility::Warmup) => true, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 281 | Technique::Utility(Utility::Ice) => self.items.ice_packs > 0, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 282 | Technique::Utility(Utility::Supplement) => self.items.supplements > 0, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 283 | Technique::Utility(Utility::Meditate) => !self.here.meditated, |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 284 | Technique::Utility(Utility::Energy) => self.items.energy_drinks > 0, |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 285 | _ => self.access(technique).is_ok() && self.check_storage().is_ok(), |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 286 | }) |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 287 | .collect() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 288 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 289 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 290 | fn check_foreskin(&self, min: f64, max: f64) -> Result<(), Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 291 | let Some(f) = self.foreskin else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 292 | if min <= 0.0 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 293 | return Ok(()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 294 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 295 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 296 | StatusCode::GONE, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 297 | "foreskin-gone", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 298 | "This technique requires a foreskin. The foreskin is gone.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 299 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 300 | .header(header::CONTENT_LOCATION, self.path("/foreskin"))); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 301 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 302 | if f < min { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 303 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 304 | StatusCode::LENGTH_REQUIRED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 305 | "foreskin-insufficient", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 306 | format!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 307 | "The selected technique requires {min:.1} units of foreskin. {f:.2} units are available. The server has noted the shortfall." |
782069860236 | atagen | 2026-10-10 12:44 UTC | 308 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 309 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 310 | .with("required", min)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 311 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 312 | if f > max { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 313 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 314 | StatusCode::PAYLOAD_TOO_LARGE, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 315 | "foreskin-excessive", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 316 | format!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 317 | "The selected technique tolerates at most {max:.1} units of foreskin. {f:.2} units are present." |
782069860236 | atagen | 2026-10-10 12:44 UTC | 318 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 319 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 320 | .with("maximum", max)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 321 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 322 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 323 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 324 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 325 | fn check_storage(&self) -> Result<(), Problem> { |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 326 | if self.items.extender && self.girth + self.current_length() / 4.0 > STORAGE_BULK { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 327 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 328 | StatusCode::INSUFFICIENT_STORAGE, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 329 | "jeans-full", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 330 | "The jeans are full. The extender is occupying the remaining storage.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 331 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 332 | .with("extender", self.path("/inventory/extender"))); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 333 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 334 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 335 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 336 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 337 | pub(super) fn chafe(&mut self, lube: Option<Lube>, intensity: i32) { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 338 | let (base, slip) = match lube { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 339 | None => (FRICTION_DRY, 0), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 340 | Some(Lube::Spit) => (FRICTION_SPIT, 0), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 341 | Some(Lube::Lotion) => (0, 0), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 342 | Some(Lube::BabyOil | Lube::CoconutOil) => (0, 1), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 343 | Some(Lube::Vaseline) => (0, 2), |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 344 | }; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 345 | let vigour = match intensity { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 346 | ..=5 => 0, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 347 | 6..=8 => 1, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 348 | _ => 2, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 349 | }; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 350 | let unlubed = matches!(lube, None | Some(Lube::Spit)); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 351 | let thick = i32::from(unlubed && self.girth > GIRTH_THICK); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 352 | let glide = i32::from(unlubed && self.foreskin.is_some_and(|f| f >= FORESKIN_GLIDE)); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 353 | let mut friction = (base + vigour + thick - slip - glide).max(0); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 354 | if friction > 0 && self.jelq_grip.is_some_and(|grip| grip != self.grip) { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 355 | friction -= FRICTION_GRIP; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 356 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 357 | self.jelq_grip = Some(self.grip); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 358 | self.friction = (self.friction + friction).min(FRICTION_MAX); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 359 | if self.friction >= FRICTION_BURN_AT |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 360 | && !self.conditions.friction_burn |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 361 | && self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 362 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 363 | "friction-burn", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 364 | "With the skin this raw, has it finally burned?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 365 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 366 | FRICTION_BURN, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 367 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 368 | { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 369 | self.conditions.friction_burn = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 370 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 371 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 372 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 373 | pub(super) fn commit(&mut self, intensity: i32, lube: Option<Lube>, cost: i32) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 374 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 375 | self.turn += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 376 | self.here.turns += 1; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 377 | self.step_away(); |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 378 | self.realise(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 379 | if self.items.extender { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 380 | self.length += EXTENDER_GAIN; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 381 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 382 | self.stamina -= cost + i32::from(lube == Some(Lube::Lotion)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 383 | if self.stamina <= 0 { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 384 | self.exhaust(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 385 | } |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 386 | let chill = if self.floor == Floor::ChangingRoom { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 387 | CHANGING_ROOM_CHILL |
782069860236 | atagen | 2026-10-10 12:44 UTC | 388 | } else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 389 | 0 |
782069860236 | atagen | 2026-10-10 12:44 UTC | 390 | }; |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 391 | let wobble = self.oracle.span_int( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 392 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 393 | "wobble", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 394 | "How does the count drift on this stroke, up or down?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 395 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 396 | -EQ_WOBBLE, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 397 | EQ_WOBBLE, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 398 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 399 | self.eq = (self.eq + intensity * 2 - 6 - chill + wobble).clamp(0, 100); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 400 | |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 401 | let was_below = self.suspicion < SUSPICION_LIMIT; |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 402 | self.make_noise(intensity / 5 + i32::from(lube == Some(Lube::Vaseline))); |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 403 | if self.floor == Floor::Nans && lube == Some(Lube::CoconutOil) { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 404 | self.add_suspicion(2); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 405 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 406 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 407 | if intensity >= PULLED_MUSCLE_INTENSITY |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 408 | && !self.conditions.pulled_muscle |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 409 | && self.oracle.chance_not( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 410 | self.decision("pulled-muscle", "Do the muscles hold?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 411 | PULLED_MUSCLE, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 412 | ) |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 413 | { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 414 | self.conditions.pulled_muscle = true; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 415 | self.stamina = self.stamina.min(self.max_stamina()); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 416 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 417 | self.settle(was_below); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 418 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 419 | |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 420 | pub(super) fn make_noise(&mut self, noise: i32) { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 421 | let doubled = match self.floor { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 422 | Floor::Nans => true, |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 423 | Floor::ChangingRoom => !self.holds_own_in_the_locker_room(), |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 424 | _ => false, |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 425 | }; |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 426 | self.add_suspicion(if doubled { noise * 2 } else { noise }); |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 427 | } |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 428 | |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 429 | fn add_suspicion(&mut self, amount: i32) { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 430 | self.suspicion = |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 431 | u8::try_from((i32::from(self.suspicion) + amount).clamp(0, i32::from(SUSPICION_LIMIT))) |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 432 | .unwrap_or(SUSPICION_LIMIT); |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 433 | } |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 434 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 435 | /// The part of a turn the house takes part in, whatever the action was. |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 436 | pub(super) fn settle(&mut self, was_below: bool) { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 437 | self.maybe_summon_mum(was_below); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 438 | if let Some(observer) = self.floor.observer() |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 439 | && self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 440 | self.decision("observed", "Has someone quietly noticed what is going on?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 441 | OBSERVED, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 442 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 443 | { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 444 | self.observed = Some(observer); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 445 | self.shame += 1; |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 446 | if observer == Observer::Cat |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 447 | && self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 448 | self.decision("cat-takes-towel", "Has the cat taken the towel?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 449 | CAT_TAKES_TOWEL, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 450 | ) |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 451 | { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 452 | self.here.towel_stolen = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 453 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 454 | } |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 455 | if self.items.ring |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 456 | && self.eq > HOT_EQ |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 457 | && self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 458 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 459 | "ring-priapism", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 460 | "With the ring still on and everything this warm, will it not go down?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 461 | ), |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 462 | if self.girth > GIRTH_THICK { |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 463 | RING_TIGHT_PRIAPISM |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 464 | } else { |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 465 | RING_PRIAPISM |
9374b3933189 | atagen | 2026-10-12 11:15 UTC | 466 | }, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 467 | ) |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 468 | { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 469 | self.conditions.priapism_turns = PRIAPISM_TURNS; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 470 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 471 | if self.conditions.priapism_turns > 0 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 472 | self.conditions.priapism_turns -= 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 473 | self.eq = self.eq.max(PRIAPISM_EQ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 474 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 475 | if self.turn == BRANCH_TURN && self.story == Story::Unopened { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 476 | self.story = Story::Pending; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 477 | self.notices |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 478 | .push("Somewhere, a forum thread from 2009 still has replies."); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 479 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 480 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 481 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 482 | /// HOLD. A pause between strokes, offered when the band has been left or the stamina is gone. |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 483 | pub fn can_hold(&self) -> bool { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 484 | self.eq > DANGER_EQ || self.stamina <= 2 |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 485 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 486 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 487 | pub fn hold(&mut self) -> Result<Outcome, Problem> { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 488 | if self.story == Story::Pending { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 489 | return Ok(self.branch_offer()); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 490 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 491 | if self.items.cage { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 492 | return Err(Problem::new( |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 493 | StatusCode::LOCKED, |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 494 | "caged", |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 495 | "The cage is locked. The key is not in the box.", |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 496 | )); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 497 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 498 | self.touch(); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 499 | self.turn += 1; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 500 | self.here.turns += 1; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 501 | self.realise(); |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 502 | if self.oracle.chance_not( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 503 | self.decision("rupture", "The pause is uneventful"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 504 | RUPTURE_HOLD, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 505 | ) { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 506 | return Err(self.rupture()); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 507 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 508 | let was_below = self.suspicion < SUSPICION_LIMIT; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 509 | if self.exhausted { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 510 | self.recover(); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 511 | self.shed(FRICTION_HOLD); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 512 | self.settle(was_below); |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 513 | let detail = if self.conditions.priapism_turns > 0 { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 514 | "The count went well past ten. Stamina is back. It went down a little. Maybe. You hope." |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 515 | } else { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 516 | "The count went well past ten. Stamina is back. Everything else has gone quiet, and you are cold again." |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 517 | }; |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 518 | return Ok(Outcome::json(StatusCode::OK, json!({ "detail": detail }))); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 519 | } |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 520 | if self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 521 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 522 | "reflection", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 523 | "In the quiet afterwards, have you caught your own eye in the mirror?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 524 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 525 | REFLECTION, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 526 | ) { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 527 | self.eq = 0; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 528 | self.shame += 1; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 529 | self.notices |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 530 | .push("the count reached ten, and then the reflection started"); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 531 | } else { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 532 | self.eq = (self.eq - HOLD_EQ).clamp(0, 100); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 533 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 534 | self.stamina = (self.stamina + 1).min(self.max_stamina()); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 535 | self.shed(FRICTION_HOLD); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 536 | self.settle(was_below); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 537 | Ok(Outcome::empty(StatusCode::NO_CONTENT)) |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 538 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 539 | |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 540 | /// The breathing technique from the forum's replies. It spends no stamina and the turn is |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 541 | /// not the floor's, but each floor allows it once. |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 542 | fn meditate(&mut self) -> Result<Outcome, Problem> { |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 543 | if self.here.meditated { |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 544 | return Err(Problem::new( |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 545 | StatusCode::CONFLICT, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 546 | "already-meditated", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 547 | "This floor has had its meditation.", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 548 | )); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 549 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 550 | self.here.meditated = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 551 | self.step_away(); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 552 | self.reset_eq(self.eq - MEDITATION_EQ); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 553 | self.shed(FRICTION_MEDITATE); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 554 | self.touch(); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 555 | Ok(Outcome::json( |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 556 | StatusCode::OK, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 557 | json!({ |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 558 | "detail": "In through the nose, out through the mouth. EQ falls by ten.", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 559 | }), |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 560 | )) |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 561 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 562 | |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 563 | pub(super) fn maybe_summon_mum(&mut self, was_below: bool) { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 564 | if !self.floor.has_mum() || self.mum.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 565 | return; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 566 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 567 | let summoned = was_below && self.suspicion == SUSPICION_LIMIT; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 568 | let mut visits = u32::from(self.suspicion) + 1; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 569 | if self.here.brother_told { |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 570 | visits *= 2; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 571 | } |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 572 | if summoned |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 573 | || self.oracle.ratio( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 574 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 575 | "mum-summon", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 576 | "With this much noise in the house, is Mum on her way up?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 577 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 578 | visits, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 579 | super::balance::MUM_VISIT, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 580 | ) |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 581 | { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 582 | let errand = self.errand(summoned); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 583 | let nonce = self.fresh_nonce(); |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 584 | self.mum = Some(MumVisit { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 585 | errand, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 586 | nonce, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 587 | strikes: 0, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 588 | knocked: false, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 589 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 590 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 591 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 592 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 593 | fn roll( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 594 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 595 | training: Training, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 596 | intensity: i32, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 597 | lube: Option<Lube>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 598 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 599 | let profile = training.profile(); |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 600 | let natural: i32 = self.oracle.span_int( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 601 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 602 | "natural", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 603 | "What does the twenty-sided die show for this technique?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 604 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 605 | 1, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 606 | 20, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 607 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 608 | let band = if EQ_BAND.contains(&self.eq) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 609 | BAND_BONUS |
782069860236 | atagen | 2026-10-10 12:44 UTC | 610 | } else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 611 | 0 |
782069860236 | atagen | 2026-10-10 12:44 UTC | 612 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 613 | let grip = match (self.grip, training) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 614 | (Grip::Underhand, Training::Stretch) => 2, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 615 | (Grip::Underhand, Training::Wet) => -1, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 616 | _ => 0, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 617 | }; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 618 | let arrival = if self.here.warm_arrival { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 619 | ARRIVAL_BONUS |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 620 | } else { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 621 | 0 |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 622 | }; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 623 | let modifier = lube.map_or(0, Lube::modifier) + band + grip + arrival; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 624 | let dc = profile.dc + intensity / 3; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 625 | let total = natural + modifier; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 626 | let timing = format!("roll;desc=\"d20{modifier:+} vs {dc}\";dur={natural}"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 627 | let timed = |p: Problem| p.header(SERVER_TIMING, &timing); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 628 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 629 | let (length, girth) = self.scaled_gains(&profile, intensity); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 630 | let burn = self.burn(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 631 | let rupture_line = if self.items.ring { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 632 | RING_RUPTURE_LINE |
782069860236 | atagen | 2026-10-10 12:44 UTC | 633 | } else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 634 | RUPTURE_LINE |
782069860236 | atagen | 2026-10-10 12:44 UTC | 635 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 636 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 637 | if natural == 1 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 638 | return Err(timed(self.critical_failure(training, &profile))); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 639 | } |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 640 | self.here.warm_arrival = false; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 641 | if natural == 2 && self.eq > DANGER_EQ - burn { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 642 | return Err(timed(self.rupture())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 643 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 644 | if self.eq > rupture_line - burn && total < dc { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 645 | return Err(timed(self.rupture())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 646 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 647 | if natural == 20 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 648 | self.gain(length * 2.0, girth * 2.0, profile.foreskin_growth); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 649 | return Ok(Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 650 | StatusCode::PERMANENT_REDIRECT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 651 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 652 | "detail": "Your length has moved permanently.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 653 | "length": round3(length * 2.0), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 654 | "girth": round3(girth * 2.0), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 655 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 656 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 657 | .header(header::LOCATION, self.path("/length")) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 658 | .header(SERVER_TIMING, timing)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 659 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 660 | if total < dc - 3 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 661 | return Err(timed(not_extended())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 662 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 663 | if total < dc { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 664 | return Ok(Outcome::empty(StatusCode::NO_CONTENT).header(SERVER_TIMING, timing)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 665 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 666 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 667 | let outcome = if self.eq < *EQ_BAND.start() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 668 | self.gain(length / 2.0, girth / 2.0, profile.foreskin_growth); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 669 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 670 | StatusCode::PARTIAL_CONTENT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 671 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 672 | "detail": "Partial gains were applied. EQ was below the band.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 673 | "length": round3(length / 2.0), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 674 | "girth": round3(girth / 2.0), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 675 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 676 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 677 | } else if total >= dc + 5 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 678 | self.gain(length, girth, profile.foreskin_growth); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 679 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 680 | StatusCode::OK, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 681 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 682 | "detail": "Gains were applied.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 683 | "length": round3(length), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 684 | "girth": round3(girth), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 685 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 686 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 687 | } else { |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 688 | let eta = self.oracle.span_int( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 689 | self.decision("eta", "In how many turns will the queued gains arrive?"), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 690 | 1, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 691 | 4, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 692 | ) as u32; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 693 | self.pending.push(Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 694 | due: self.turn + eta, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 695 | length, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 696 | girth, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 697 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 698 | self.gain(0.0, 0.0, profile.foreskin_growth); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 699 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 700 | StatusCode::ACCEPTED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 701 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 702 | "detail": "Gains have been queued. They may arrive.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 703 | "eta_turns": eta, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 704 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 705 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 706 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 707 | Ok(outcome.header(SERVER_TIMING, timing)) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 708 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 709 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 710 | fn scaled_gains(&self, profile: &Profile, intensity: i32) -> (f64, f64) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 711 | let scale = f64::from(intensity); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 712 | let (mut length, mut girth) = (profile.length * scale, profile.girth * scale); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 713 | let greed = if self.eq > HOT_EQ { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 714 | GREED_HOT |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 715 | } else if self.eq > DANGER_EQ { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 716 | GREED_WARM |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 717 | } else { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 718 | 1.0 |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 719 | }; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 720 | length *= greed; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 721 | girth *= greed; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 722 | if self.here.teapot { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 723 | length *= 0.5; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 724 | girth *= 1.5; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 725 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 726 | if self.items.ring { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 727 | girth *= 2.0; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 728 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 729 | if self.conditions.friction_burn { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 730 | length *= 0.5; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 731 | girth *= 0.5; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 732 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 733 | (length, girth) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 734 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 735 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 736 | fn critical_failure(&mut self, training: Training, profile: &Profile) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 737 | let uses_foreskin = profile.foreskin.is_some_and(|(min, _)| min > 0.0); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 738 | if uses_foreskin && self.foreskin.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 739 | self.foreskin = None; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 740 | self.shame += 25; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 741 | return Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 742 | StatusCode::GONE, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 743 | "foreskin-lost", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 744 | "The technique has removed the foreskin. It will not be returning.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 745 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 746 | .header(header::CONTENT_LOCATION, self.path("/foreskin")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 747 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 748 | if self.eq > DANGER_EQ - self.burn() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 749 | return self.rupture(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 750 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 751 | if training == Training::Stretch && !self.here.teapot { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 752 | self.here.teapot = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 753 | self.items.teapot_spout = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 754 | self.shame += 5; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 755 | return Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 756 | StatusCode::IM_A_TEAPOT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 757 | "teapot", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 758 | "The subject is now short and stout. Length gains are halved for the rest of the floor.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 759 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 760 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 761 | if training == Training::Uli && !self.conditions.peyronie { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 762 | self.conditions.peyronie = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 763 | self.shame += 5; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 764 | return Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 765 | StatusCode::MISDIRECTED_REQUEST, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 766 | "curvature", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 767 | "A curvature has developed. Techniques will land slightly to the left until a professional is consulted.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 768 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 769 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 770 | not_extended() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 771 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 772 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 773 | fn gossip(&mut self, mut outcome: Outcome) -> Outcome { |
c4d70621d377 | atagen | 2026-10-12 11:56 UTC | 774 | let reportable = matches!(outcome.status.as_u16(), 200 | 202 | 206 | 308); |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 775 | if !self.here.brother_told || !reportable { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 776 | return outcome; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 777 | } |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 778 | self.here.brother_told = false; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 779 | outcome.status = StatusCode::ALREADY_REPORTED; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 780 | if let Payload::Json(body) = &mut outcome.payload { |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 781 | body["detail"] = json!("Your brother has already told Mum."); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 782 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 783 | outcome |
782069860236 | atagen | 2026-10-10 12:44 UTC | 784 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 785 | } |