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::{ |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 7 | Cause, Floor, Item, Outcome, Run, |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 8 | balance::{ |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 9 | EXAGGERATION, MEDITATION_ODDS, PATIENCE, PRINTABLE_RULER, RULER_SHAME, THREAD_READS, |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 10 | ULI_ODDS, |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 11 | }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 12 | credentials::{Scheme, parse_credentials}, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 13 | measure::{exaggeration, honest}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 14 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 15 | use crate::{headers::X_FORUM_NOTE, problem::Problem}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 16 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 17 | pub const FORUM_THREAD: &str = "/forum/threads/2009"; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 18 | pub const ELDER_LAST_MODIFIED: &str = "Sun, 14 Jun 2009 03:12:00 GMT"; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 19 | static ELDER_POSTED: LazyLock<SystemTime> = LazyLock::new(|| { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 20 | 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 | 21 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 22 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 23 | const SPREADSHEET: &str = "\ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 24 | date,length,girth,technique,notes,honest? |
782069860236 | atagen | 2026-10-10 12:44 UTC | 25 | 2007-01-03,7.50,5.50,wet,baseline,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 26 | 2007-06-11,7.50,5.50,wet,feeling fuller,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 27 | 2008-01-02,7.50,5.50,dry,new routine,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 28 | 2008-09-19,7.50,5.50,uli,PUT is idempotent. do not use PUT.,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 29 | 2009-06-14,7.50,5.50,wet,progress is slow but real,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 30 | "; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 31 | |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 32 | fn thread(detail: Option<&str>) -> Outcome { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 33 | let mut body = forum_thread(); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 34 | if let Some(detail) = detail { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 35 | body["detail"] = json!(detail); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 36 | } |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 37 | Outcome::json(StatusCode::OK, body).header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED) |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 38 | } |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 39 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 40 | pub fn forum_thread() -> Value { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 41 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 42 | "title": "The definitive jelqing FAQ (updated 2009)", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 43 | "posts": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | { "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 | 45 | { "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 | 46 | { "author": "newbie_2009", "body": "everyone keeps saying uli. who is uli" }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 47 | { "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 | 48 | { "author": "TheElder", "body": "We do not say his name in vain. We say it in girth." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | { "author": "newbie_2009", "body": "I have been sending PUT for three weeks and nothing has changed." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 50 | { "author": "TheElder", "body": "PUT is idempotent. Read the spec." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 51 | { "author": "TheElder", "body": "Members verify with a Ruler. Proxy-Authorization, inches, no rounding up. We can tell." }, |
9adb509e6685 | atagen | 2026-10-14 08:54 UTC | 52 | { "author": "newbie_2009", "body": "cant i just take off what i tell people. everyone adds an inch and a half" }, |
9adb509e6685 | atagen | 2026-10-14 08:54 UTC | 53 | { "author": "TheElder", "body": "Everyone adds a different amount. That is why there is a Ruler." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | { "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 | 55 | { "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 | 56 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | }) |
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 | fn verification(detail: &str) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 61 | Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 62 | StatusCode::PROXY_AUTHENTICATION_REQUIRED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 63 | "verification-required", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 64 | detail, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 65 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | .header(header::PROXY_AUTHENTICATE, "Ruler realm=\"forum\"") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 69 | /// The browser tab that opens on turn 10. |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 70 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 71 | pub enum Story { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 72 | Unopened, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 73 | Pending, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 74 | ReadForum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 75 | ClosedTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 76 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 77 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 78 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 79 | pub enum Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 80 | Forum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 81 | CloseTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 82 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 83 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 84 | impl Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 85 | pub fn slug(self) -> &'static str { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 86 | match self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 87 | Self::Forum => "forum", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 88 | Self::CloseTab => "close-tab", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 89 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 90 | } |
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 | impl std::str::FromStr for Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 94 | type Err = (); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 95 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 96 | fn from_str(slug: &str) -> Result<Self, ()> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 97 | [Self::Forum, Self::CloseTab] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 98 | .into_iter() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 99 | .find(|branch| branch.slug() == slug) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 100 | .ok_or(()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 101 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 102 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 103 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 104 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 105 | pub enum Elder { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 106 | Unverified { strikes: u8 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 107 | Verified, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 108 | Beaten, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 109 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 110 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 111 | /// 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 | 112 | pub struct Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 113 | pub(crate) story: Story, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 114 | pub(crate) meditation_taught: bool, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 115 | pub(crate) uli_taught: bool, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 116 | pub(crate) elder: Elder, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 117 | pub(crate) filmed_at: Option<SystemTime>, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 118 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 119 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 120 | impl Default for Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 121 | fn default() -> Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 122 | Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 123 | story: Story::Unopened, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 124 | meditation_taught: false, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 125 | uli_taught: false, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 126 | elder: Elder::Unverified { strikes: 0 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 127 | filmed_at: None, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 128 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 129 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 130 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 131 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 132 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 133 | pub(super) fn branch_offer(&self) -> Outcome { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 134 | let forum = self.path(&format!("/branches/{}", Branch::Forum.slug())); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 135 | let close = self.path(&format!("/branches/{}", Branch::CloseTab.slug())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 136 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 137 | StatusCode::MULTIPLE_CHOICES, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 138 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 139 | "detail": "A browser tab is open. It has been open for some time.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 140 | "choices": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 141 | { "href": forum, "method": "POST", "title": "Read the forum" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 142 | { "href": close, "method": "POST", "title": "Close the tab" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 143 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 144 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 145 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 146 | .header( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 147 | header::LINK, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 148 | format!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 149 | "<{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 | 150 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 151 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 152 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 153 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 154 | pub fn choose(&mut self, choice: Branch) -> Result<Outcome, Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 155 | if self.online.story != Story::Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 156 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 157 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 158 | "no-decision-pending", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 159 | "There is no decision pending.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 160 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 161 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 162 | let (story, location, detail) = match choice { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 163 | Branch::Forum => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 164 | self.standing.shame += 3; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 165 | let detail = if self.learn_meditation() { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 166 | "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 | 167 | } else { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 168 | "The thread is from 2009. A technique called uli is discussed at length." |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 169 | }; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 170 | (Story::ReadForum, self.path("/techniques"), detail) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 171 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 172 | Branch::CloseTab => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 173 | self.standing.suspicion = 0; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 174 | ( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 175 | Story::ClosedTab, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 176 | self.path(""), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 177 | "The tab is closed. Nobody saw it.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 178 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 179 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 180 | }; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 181 | self.online.story = story; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 182 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 183 | Ok( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 184 | Outcome::json(StatusCode::SEE_OTHER, json!({ "detail": detail })) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 185 | .header(header::LOCATION, location), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 186 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 187 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 188 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 189 | /// 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 | 190 | /// after which the forum is down and the browser serves what it kept. |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 191 | pub fn read_thread(&mut self) -> Result<Outcome, Problem> { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 192 | if !self.thread_reachable() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 193 | return Err(Problem::new( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 194 | StatusCode::NOT_FOUND, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 195 | "no-thread", |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 196 | "There is no thread. Nobody has mentioned a forum yet.", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 197 | )); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 198 | } |
3ac624339c98 | atagen | 2026-10-13 12:21 UTC | 199 | if self.online.story == Story::Pending { |
3ac624339c98 | atagen | 2026-10-13 12:21 UTC | 200 | return Ok(thread(None)); |
3ac624339c98 | atagen | 2026-10-13 12:21 UTC | 201 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 202 | self.end_kitchen_visit(); |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 203 | let rulerless = self.floor == Floor::Forum && !self.items.kit.ruler; |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 204 | if self.online.uli_taught && !rulerless { |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 205 | return Ok(thread(None)); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 206 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 207 | if self.here.thread_rolls >= THREAD_READS { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 208 | let age = SystemTime::now() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 209 | .duration_since(*ELDER_POSTED) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 210 | .map_or(0, |age| age.as_secs()); |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 211 | return Ok(thread(None) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 212 | .header(header::AGE, age.to_string()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 213 | .header(header::WARNING, r#"112 - "Disconnected operation""#)); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 214 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 215 | self.here.thread_rolls += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 216 | self.touch(); |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 217 | if rulerless |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 218 | && self.chance( |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 219 | self.decision( |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 220 | "printable-ruler", |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 221 | "Does this read surface a member's printable ruler?", |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 222 | ), |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 223 | PRINTABLE_RULER, |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 224 | ) |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 225 | { |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 226 | self.items.grant(Item::Ruler); |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 227 | self.standing.shame += RULER_SHAME; |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 228 | return Ok(thread(Some( |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 229 | "A member has attached a printable ruler. Print at 100%. Do not scale to fit. You now know.", |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 230 | )) |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 231 | .header(header::LOCATION, self.path("/inventory/ruler"))); |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 232 | } |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 233 | if self.online.uli_taught { |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 234 | return Ok(thread(None)); |
56d34031c321 | atagen | 2026-10-14 09:23 UTC | 235 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 236 | let detail = if !self.online.meditation_taught { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 237 | if !self.learn_meditation() { |
3ac624339c98 | atagen | 2026-10-13 12:21 UTC | 238 | return Ok(thread(None)); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 239 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 240 | "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 | 241 | } else { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 242 | if !self.chance( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 243 | self.decision( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 244 | "teach-uli", |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 245 | "Does this read finally surface the 2009 reply that teaches uli?", |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 246 | ), |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 247 | ULI_ODDS, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 248 | ) { |
3ac624339c98 | atagen | 2026-10-13 12:21 UTC | 249 | return Ok(thread(None)); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 250 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 251 | self.online.uli_taught = true; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 252 | "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 | 253 | }; |
a11497af08aa | atagen | 2026-10-13 12:04 UTC | 254 | Ok(thread(Some(detail))) |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 255 | } |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 256 | |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 257 | fn learn_meditation(&mut self) -> bool { |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 258 | let taught = self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 259 | self.decision( |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 260 | "teach-meditation", |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 261 | "Does the thread surface the reply that teaches the breathing technique?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 262 | ), |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 263 | MEDITATION_ODDS, |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 264 | ); |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 265 | self.online.meditation_taught |= taught; |
880b29a0c11e | atagen | 2026-10-13 09:27 UTC | 266 | taught |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 267 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 268 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 269 | fn elder_strike(&mut self, problem: Problem) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 270 | self.touch(); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 271 | let Elder::Unverified { strikes } = &mut self.online.elder else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 272 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 273 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 274 | *strikes += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 275 | if *strikes < PATIENCE { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 276 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 277 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 278 | self.end(Cause::Banned) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 279 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 280 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 281 | /// 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 | 282 | fn verify_member(&mut self, proxy_authorization: Option<&str>) -> Result<(), Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 283 | if !matches!(self.online.elder, Elder::Unverified { .. }) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 284 | return Ok(()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 285 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 286 | let Some(credentials) = proxy_authorization else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 287 | return Err(verification("The forum requires verification.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 288 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 289 | let Some(claimed) = |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 290 | parse_credentials(credentials, Scheme::Ruler).and_then(|v| v.parse::<f64>().ok()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 291 | else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 292 | return Err(verification("The forum requires verification, in inches.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 293 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 294 | let actual = self.current_length(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 295 | if claimed >= actual + EXAGGERATION { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 296 | self.standing.shame += 2; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 297 | return Err(self.elder_strike(exaggeration())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 298 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 299 | if !honest(claimed, actual) { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 300 | self.standing.shame += 1; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 301 | let failed = verification("Verification failed. The forum can tell."); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 302 | if self.girth_respected() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 303 | return Err(failed.header( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 304 | X_FORUM_NOTE, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 305 | "The mods have let this one go. Girth is also a dimension.", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 306 | )); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 307 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 308 | return Err(self.elder_strike(failed)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 309 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 310 | self.online.elder = Elder::Verified; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 311 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 312 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 313 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 314 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 315 | pub fn elder( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 316 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 317 | proxy_authorization: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 318 | if_modified_since: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 319 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 320 | if self.floor != Floor::Forum { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 321 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 322 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 323 | "elder-absent", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 324 | "The Elder only posts on the forum.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 325 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 326 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 327 | self.verify_member(proxy_authorization)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 328 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 329 | let current = if_modified_since |
782069860236 | atagen | 2026-10-10 12:44 UTC | 330 | .and_then(|d| httpdate::parse_http_date(d).ok()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 331 | .is_some_and(|since| since >= *ELDER_POSTED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 332 | if current { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 333 | if self.online.elder != Elder::Beaten { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 334 | self.online.elder = Elder::Beaten; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 335 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 336 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 337 | return Ok(Outcome::empty(StatusCode::NOT_MODIFIED) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 338 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 339 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 340 | let spreadsheet = Outcome::raw(StatusCode::OK, "text/csv; header=present", SPREADSHEET) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 341 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 342 | if self.online.filmed_at.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 343 | return Ok(spreadsheet.header(X_FORUM_NOTE, "We have seen the footage.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 344 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 345 | Ok(spreadsheet) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 346 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 347 | } |