atagen

jelq

public

an http based roguelike rpg about jelqing

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