an http based roguelike rpg about jelqing
Blame: src/game/forum.rs
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 1 | use std::{sync::LazyLock, time::SystemTime}; |
a6caa2f99786 | atagen | 2026-10-12 10:38 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::{Value, json}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 5 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 6 | use super::{ |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 7 | Cause, Floor, Outcome, Run, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 8 | balance::{EXAGGERATION, MEDITATION_ODDS, PATIENCE, THREAD_READS, ULI_ODDS}, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 9 | credentials::{Scheme, parse_credentials}, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 10 | measure::{exaggeration, honest}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 11 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 12 | use crate::{headers::X_FORUM_NOTE, problem::Problem}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 13 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 14 | pub const FORUM_THREAD: &str = "/forum/threads/2009"; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 15 | pub const ELDER_LAST_MODIFIED: &str = "Sun, 14 Jun 2009 03:12:00 GMT"; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 16 | static ELDER_POSTED: LazyLock<SystemTime> = LazyLock::new(|| { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 17 | httpdate::parse_http_date(ELDER_LAST_MODIFIED).expect("the Elder's date is a valid HTTP-date") |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 18 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 20 | const SPREADSHEET: &str = "\ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 21 | date,length,girth,technique,notes,honest? |
782069860236 | atagen | 2026-10-10 12:44 UTC | 22 | 2007-01-03,7.50,5.50,wet,baseline,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 23 | 2007-06-11,7.50,5.50,wet,feeling fuller,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 24 | 2008-01-02,7.50,5.50,dry,new routine,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 25 | 2008-09-19,7.50,5.50,uli,PUT is idempotent. do not use PUT.,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 26 | 2009-06-14,7.50,5.50,wet,progress is slow but real,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 27 | "; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 28 | |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 29 | fn thread(detail: Option<&str>) -> Outcome { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 30 | let mut body = forum_thread(); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 31 | if let Some(detail) = detail { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 32 | body["detail"] = json!(detail); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 33 | } |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 34 | Outcome::json(StatusCode::OK, body).header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED) |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 35 | } |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 36 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 37 | fn nothing_new() -> Outcome { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 38 | thread(None).header( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 39 | header::WARNING, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 40 | r#"199 - "Nothing new has been posted since 2009.""#, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 41 | ) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 42 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 43 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | pub fn forum_thread() -> Value { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 45 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 46 | "title": "The definitive jelqing FAQ (updated 2009)", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 47 | "posts": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | { "author": "TheElder", "body": "Warm up. Always warm up. A cold jelq is a 412 waiting to happen." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | { "author": "TheElder", "body": "Keep EQ between 50 and 70. Above 70 you are gambling. Above 90 you are a cautionary tale." }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 50 | { "author": "newbie_2009", "body": "everyone keeps saying uli. who is uli" }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 51 | { "author": "TheElder", "body": "uli was a member here. He posted the technique in 2001 and never posted again. Some say he ascended. The search function says his account is gone." }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 52 | { "author": "TheElder", "body": "We do not say his name in vain. We say it in girth." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | { "author": "newbie_2009", "body": "I have been sending PUT for three weeks and nothing has changed." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | { "author": "TheElder", "body": "PUT is idempotent. Read the spec." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | { "author": "TheElder", "body": "Members verify with a Ruler. Proxy-Authorization, inches, no rounding up. We can tell." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | { "author": "throwaway_77", "body": "my doctor said i was normal. i didnt believe him. i still dont know what he meant by bearer" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | { "author": "TheElder", "body": "My numbers are in my spreadsheet. They have not changed since 2009. Nothing about me has changed since 2009." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | }) |
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 | fn verification(detail: &str) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 63 | Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 64 | StatusCode::PROXY_AUTHENTICATION_REQUIRED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 65 | "verification-required", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | detail, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | .header(header::PROXY_AUTHENTICATE, "Ruler realm=\"forum\"") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 69 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 70 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 71 | /// The browser tab that opens on turn 10. |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 72 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 73 | pub enum Story { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 74 | Unopened, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 75 | Pending, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 76 | ReadForum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 77 | ClosedTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 78 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 79 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 80 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 81 | pub enum Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 82 | Forum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 83 | CloseTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 84 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 85 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 86 | impl Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 87 | pub fn slug(self) -> &'static str { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 88 | match self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 89 | Self::Forum => "forum", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 90 | Self::CloseTab => "close-tab", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 91 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 92 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 93 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 94 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 95 | impl std::str::FromStr for Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 96 | type Err = (); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 97 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 98 | fn from_str(slug: &str) -> Result<Self, ()> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 99 | [Self::Forum, Self::CloseTab] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 100 | .into_iter() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 101 | .find(|branch| branch.slug() == slug) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 102 | .ok_or(()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 103 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 104 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 105 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 106 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 107 | pub enum Elder { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 108 | Unverified { strikes: u8 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 109 | Verified, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 110 | Beaten, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 111 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 112 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 113 | /// The run's life online, from the tab on turn 10 to the footage the neighbour took. |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 114 | pub struct Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 115 | pub(crate) story: Story, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 116 | pub(crate) meditation_taught: bool, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 117 | pub(crate) uli_taught: bool, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 118 | pub(crate) elder: Elder, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 119 | pub(crate) filmed_at: Option<SystemTime>, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 120 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 121 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 122 | impl Default for Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 123 | fn default() -> Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 124 | Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 125 | story: Story::Unopened, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 126 | meditation_taught: false, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 127 | uli_taught: false, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 128 | elder: Elder::Unverified { strikes: 0 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 129 | filmed_at: None, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 130 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 131 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 132 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 133 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 134 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 135 | pub(super) fn branch_offer(&self) -> Outcome { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 136 | let forum = self.path(&format!("/branches/{}", Branch::Forum.slug())); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 137 | let close = self.path(&format!("/branches/{}", Branch::CloseTab.slug())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 138 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 139 | StatusCode::MULTIPLE_CHOICES, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 140 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 141 | "detail": "A browser tab is open. It has been open for some time.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 142 | "choices": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 143 | { "href": forum, "method": "POST", "title": "Read the forum" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 144 | { "href": close, "method": "POST", "title": "Close the tab" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 145 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 146 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 147 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 148 | .header( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 149 | header::LINK, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 150 | format!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 151 | "<{forum}>; rel=\"alternate\"; title=\"Read the forum\"; allow=\"POST\", <{close}>; rel=\"alternate\"; title=\"Close the tab\"; allow=\"POST\"" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 152 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 153 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 154 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 155 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 156 | pub fn choose(&mut self, choice: Branch) -> Result<Outcome, Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 157 | if self.online.story != Story::Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 158 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 159 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 160 | "no-decision-pending", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 161 | "There is no decision pending.", |
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 | let (story, location, detail) = match choice { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 165 | Branch::Forum => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 166 | self.standing.shame += 3; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 167 | let detail = if self.learn_meditation() { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 168 | "The thread is from 2009. A technique called uli is discussed at length. Further down, someone explains how to breathe, and you write it down." |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 169 | } else { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 170 | "The thread is from 2009. A technique called uli is discussed at length." |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 171 | }; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 172 | (Story::ReadForum, self.path("/techniques"), detail) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 173 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 174 | Branch::CloseTab => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 175 | self.standing.suspicion = 0; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 176 | ( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 177 | Story::ClosedTab, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 178 | self.path(""), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 179 | "The tab is closed. Nobody saw it.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 180 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 181 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 182 | }; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 183 | self.online.story = story; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 184 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 185 | Ok( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 186 | Outcome::json(StatusCode::SEE_OTHER, json!({ "detail": detail })) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 187 | .header(header::LOCATION, location), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 188 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 189 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 190 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 191 | /// Re-reading is free. Each floor gets a couple of live reads that may surface the reply, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 192 | /// after which the forum is down and the browser serves what it kept. |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 193 | pub fn read_thread(&mut self) -> Result<Outcome, Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 194 | if self.online.story == Story::Pending { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 195 | return Ok(self.branch_offer()); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 196 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 197 | if !self.thread_reachable() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 198 | return Err(Problem::new( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 199 | StatusCode::NOT_FOUND, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 200 | "no-thread", |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 201 | "There is no thread. Nobody has mentioned a forum yet.", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 202 | )); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 203 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 204 | self.end_kitchen_visit(); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 205 | if self.online.uli_taught { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 206 | return Ok(thread(None)); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 207 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 208 | if self.here.thread_rolls >= THREAD_READS { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 209 | let age = SystemTime::now() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 210 | .duration_since(*ELDER_POSTED) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 211 | .map_or(0, |age| age.as_secs()); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 212 | return Ok(thread(None) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 213 | .header(header::AGE, age.to_string()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 214 | .header(header::WARNING, r#"112 - "Disconnected operation""#)); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 215 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 216 | self.here.thread_rolls += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 217 | self.touch(); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 218 | let detail = if !self.online.meditation_taught { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 219 | if !self.learn_meditation() { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 220 | return Ok(nothing_new()); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 221 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 222 | "Between two arguments about pumps, a reply explains how to breathe. In through the nose, out through the mouth. You write it down." |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 223 | } else { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 224 | if !self.chance( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 225 | self.decision( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 226 | "teach-uli", |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 227 | "Does this read finally surface the 2009 reply that teaches uli?", |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 228 | ), |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 229 | ULI_ODDS, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 230 | ) { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 231 | return Ok(nothing_new()); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 232 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 233 | self.online.uli_taught = true; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 234 | "Past the necroposting, a reply from TheElder lays out the technique. Uli. The full routine. You write it down before the tab can lose it." |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 235 | }; |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 236 | Ok(thread(Some(detail))) |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 237 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 238 | |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 239 | fn learn_meditation(&mut self) -> bool { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 240 | let taught = self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 241 | self.decision( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 242 | "teach-meditation", |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 243 | "Does the thread surface the reply that teaches the breathing technique?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 244 | ), |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 245 | MEDITATION_ODDS, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 246 | ); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 247 | self.online.meditation_taught |= taught; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 248 | taught |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 249 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 250 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 251 | fn elder_strike(&mut self, problem: Problem) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 252 | self.touch(); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 253 | let Elder::Unverified { strikes } = &mut self.online.elder else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 254 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 255 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 256 | *strikes += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 257 | if *strikes < PATIENCE { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 258 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 259 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 260 | self.end(Cause::Banned) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 261 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 262 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 263 | /// Failed verification counts toward a ban even on GET, the way repeated bad credentials lock an account. |
782069860236 | atagen | 2026-10-10 12:44 UTC | 264 | fn verify_member(&mut self, proxy_authorization: Option<&str>) -> Result<(), Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 265 | if !matches!(self.online.elder, Elder::Unverified { .. }) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 266 | return Ok(()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 267 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 268 | let Some(credentials) = proxy_authorization else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 269 | return Err(verification("The forum requires verification.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 270 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 271 | let Some(claimed) = |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 272 | parse_credentials(credentials, Scheme::Ruler).and_then(|v| v.parse::<f64>().ok()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 273 | else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 274 | return Err(verification("The forum requires verification, in inches.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 275 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 276 | let actual = self.current_length(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 277 | if claimed >= actual + EXAGGERATION { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 278 | self.standing.shame += 2; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 279 | return Err(self.elder_strike(exaggeration())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 280 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 281 | if !honest(claimed, actual) { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 282 | self.standing.shame += 1; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 283 | let failed = verification("Verification failed. The forum can tell."); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 284 | if self.girth_respected() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 285 | return Err(failed.header( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 286 | X_FORUM_NOTE, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 287 | "The mods have let this one go. Girth is also a dimension.", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 288 | )); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 289 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 290 | return Err(self.elder_strike(failed)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 291 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 292 | self.online.elder = Elder::Verified; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 293 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 294 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 295 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 296 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 297 | pub fn elder( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 298 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 299 | proxy_authorization: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 300 | if_modified_since: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 301 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 302 | if self.floor != Floor::Forum { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 303 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 304 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 305 | "elder-absent", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 306 | "The Elder only posts on the forum.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 307 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 308 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 309 | self.verify_member(proxy_authorization)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 310 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 311 | let current = if_modified_since |
782069860236 | atagen | 2026-10-10 12:44 UTC | 312 | .and_then(|d| httpdate::parse_http_date(d).ok()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 313 | .is_some_and(|since| since >= *ELDER_POSTED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 314 | if current { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 315 | if self.online.elder != Elder::Beaten { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 316 | self.online.elder = Elder::Beaten; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 317 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 318 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 319 | return Ok(Outcome::empty(StatusCode::NOT_MODIFIED) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 320 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 321 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 322 | let spreadsheet = Outcome::raw(StatusCode::OK, "text/csv; header=present", SPREADSHEET) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 323 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 324 | if self.online.filmed_at.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 325 | return Ok(spreadsheet.header(X_FORUM_NOTE, "We have seen the footage.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 326 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 327 | Ok(spreadsheet) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 328 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 329 | } |