atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0
7288fc269bb68466e68614d7f97cb55fc4ae1358
1
ssh://brewery@pls.lobotomise.me:33/atagen/jelq.git

Blame: src/game/techniques.rs

dfa38cf4cd4batagen2026-10-10 09:17 UTC1
use axum::http::StatusCode;
dfa38cf4cd4batagen2026-10-10 09:17 UTC2
use serde_json::{Value, json};
dfa38cf4cd4batagen2026-10-10 09:17 UTC3
dfa38cf4cd4batagen2026-10-10 09:17 UTC4
use crate::problem::Problem;
dfa38cf4cd4batagen2026-10-10 09:17 UTC5
dfa38cf4cd4batagen2026-10-10 09:17 UTC6
pub const LUBRICANTS: [&str; 5] = [
dfa38cf4cd4batagen2026-10-10 09:17 UTC7
    "application/baby-oil",
dfa38cf4cd4batagen2026-10-10 09:17 UTC8
    "application/coconut-oil",
dfa38cf4cd4batagen2026-10-10 09:17 UTC9
    "application/lotion",
dfa38cf4cd4batagen2026-10-10 09:17 UTC10
    "application/vaseline",
dfa38cf4cd4batagen2026-10-10 09:17 UTC11
    "text/plain; charset=spit",
dfa38cf4cd4batagen2026-10-10 09:17 UTC12
];
dfa38cf4cd4batagen2026-10-10 09:17 UTC13
dfa38cf4cd4batagen2026-10-10 09:17 UTC14
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
dfa38cf4cd4batagen2026-10-10 09:17 UTC15
pub enum Lube {
dfa38cf4cd4batagen2026-10-10 09:17 UTC16
    BabyOil,
dfa38cf4cd4batagen2026-10-10 09:17 UTC17
    CoconutOil,
dfa38cf4cd4batagen2026-10-10 09:17 UTC18
    Lotion,
dfa38cf4cd4batagen2026-10-10 09:17 UTC19
    Vaseline,
dfa38cf4cd4batagen2026-10-10 09:17 UTC20
    Spit,
dfa38cf4cd4batagen2026-10-10 09:17 UTC21
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC22
dfa38cf4cd4batagen2026-10-10 09:17 UTC23
impl Lube {
dfa38cf4cd4batagen2026-10-10 09:17 UTC24
    pub fn from_content_type(content_type: Option<&str>) -> Result<Option<Self>, Problem> {
dfa38cf4cd4batagen2026-10-10 09:17 UTC25
        let Some(raw) = content_type else {
dfa38cf4cd4batagen2026-10-10 09:17 UTC26
            return Ok(None);
dfa38cf4cd4batagen2026-10-10 09:17 UTC27
        };
dfa38cf4cd4batagen2026-10-10 09:17 UTC28
        let lowered = raw.to_ascii_lowercase();
dfa38cf4cd4batagen2026-10-10 09:17 UTC29
        let mut parts = lowered.split(';').map(str::trim);
dfa38cf4cd4batagen2026-10-10 09:17 UTC30
        let essence = parts.next().unwrap_or_default();
dfa38cf4cd4batagen2026-10-10 09:17 UTC31
        let spit = parts.any(|p| p.replace(' ', "") == "charset=spit");
dfa38cf4cd4batagen2026-10-10 09:17 UTC32
        match essence {
dfa38cf4cd4batagen2026-10-10 09:17 UTC33
            "application/baby-oil" => Ok(Some(Self::BabyOil)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC34
            "application/coconut-oil" => Ok(Some(Self::CoconutOil)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC35
            "application/lotion" => Ok(Some(Self::Lotion)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC36
            "application/vaseline" => Ok(Some(Self::Vaseline)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC37
            "text/plain" if spit => Ok(Some(Self::Spit)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC38
            e if e.starts_with("image/") || e.starts_with("video/") => Err(Problem::new(
dfa38cf4cd4batagen2026-10-10 09:17 UTC39
                StatusCode::UNSUPPORTED_MEDIA_TYPE,
dfa38cf4cd4batagen2026-10-10 09:17 UTC40
                "no",
dfa38cf4cd4batagen2026-10-10 09:17 UTC41
                "No.",
dfa38cf4cd4batagen2026-10-10 09:17 UTC42
            )),
dfa38cf4cd4batagen2026-10-10 09:17 UTC43
            _ => Err(Problem::new(
dfa38cf4cd4batagen2026-10-10 09:17 UTC44
                StatusCode::UNSUPPORTED_MEDIA_TYPE,
dfa38cf4cd4batagen2026-10-10 09:17 UTC45
                "unsupported-lubricant",
dfa38cf4cd4batagen2026-10-10 09:17 UTC46
                format!("{essence} is not a lubricant."),
dfa38cf4cd4batagen2026-10-10 09:17 UTC47
            )
dfa38cf4cd4batagen2026-10-10 09:17 UTC48
            .with("lubricants", json!(LUBRICANTS))),
dfa38cf4cd4batagen2026-10-10 09:17 UTC49
        }
dfa38cf4cd4batagen2026-10-10 09:17 UTC50
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC51
782069860236atagen2026-10-10 12:44 UTC52
    pub fn modifier(self) -> i32 {
dfa38cf4cd4batagen2026-10-10 09:17 UTC53
        match self {
dfa38cf4cd4batagen2026-10-10 09:17 UTC54
            Self::BabyOil => 1,
dfa38cf4cd4batagen2026-10-10 09:17 UTC55
            Self::CoconutOil => 3,
dfa38cf4cd4batagen2026-10-10 09:17 UTC56
            Self::Lotion => 0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC57
            Self::Vaseline => 2,
dfa38cf4cd4batagen2026-10-10 09:17 UTC58
            Self::Spit => -2,
dfa38cf4cd4batagen2026-10-10 09:17 UTC59
        }
dfa38cf4cd4batagen2026-10-10 09:17 UTC60
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC61
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC62
782069860236atagen2026-10-10 12:44 UTC63
/// Techniques that roll for gains.
dfa38cf4cd4batagen2026-10-10 09:17 UTC64
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
782069860236atagen2026-10-10 12:44 UTC65
pub enum Training {
782069860236atagen2026-10-10 12:44 UTC66
    Wet,
782069860236atagen2026-10-10 12:44 UTC67
    Dry,
782069860236atagen2026-10-10 12:44 UTC68
    Stretch,
782069860236atagen2026-10-10 12:44 UTC69
    Uli,
782069860236atagen2026-10-10 12:44 UTC70
}
782069860236atagen2026-10-10 12:44 UTC71
782069860236atagen2026-10-10 12:44 UTC72
/// Techniques that change EQ or spend an item without rolling.
782069860236atagen2026-10-10 12:44 UTC73
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
782069860236atagen2026-10-10 12:44 UTC74
pub enum Utility {
dfa38cf4cd4batagen2026-10-10 09:17 UTC75
    Warmup,
dfa38cf4cd4batagen2026-10-10 09:17 UTC76
    Ice,
dfa38cf4cd4batagen2026-10-10 09:17 UTC77
    Edge,
dfa38cf4cd4batagen2026-10-10 09:17 UTC78
    Pump,
dfa38cf4cd4batagen2026-10-10 09:17 UTC79
    Supplement,
782069860236atagen2026-10-10 12:44 UTC80
}
782069860236atagen2026-10-10 12:44 UTC81
782069860236atagen2026-10-10 12:44 UTC82
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
782069860236atagen2026-10-10 12:44 UTC83
pub enum Technique {
782069860236atagen2026-10-10 12:44 UTC84
    Training(Training),
782069860236atagen2026-10-10 12:44 UTC85
    Utility(Utility),
dfa38cf4cd4batagen2026-10-10 09:17 UTC86
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC87
dfa38cf4cd4batagen2026-10-10 09:17 UTC88
#[derive(Clone, Copy)]
782069860236atagen2026-10-10 12:44 UTC89
pub enum LubeRule {
dfa38cf4cd4batagen2026-10-10 09:17 UTC90
    Required,
dfa38cf4cd4batagen2026-10-10 09:17 UTC91
    Forbidden,
dfa38cf4cd4batagen2026-10-10 09:17 UTC92
    Optional,
dfa38cf4cd4batagen2026-10-10 09:17 UTC93
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC94
58e1fb3943e6atagen2026-10-10 13:30 UTC95
impl LubeRule {
58e1fb3943e6atagen2026-10-10 13:30 UTC96
    fn name(self) -> &'static str {
58e1fb3943e6atagen2026-10-10 13:30 UTC97
        match self {
58e1fb3943e6atagen2026-10-10 13:30 UTC98
            Self::Required => "required",
58e1fb3943e6atagen2026-10-10 13:30 UTC99
            Self::Forbidden => "forbidden",
58e1fb3943e6atagen2026-10-10 13:30 UTC100
            Self::Optional => "optional",
58e1fb3943e6atagen2026-10-10 13:30 UTC101
        }
58e1fb3943e6atagen2026-10-10 13:30 UTC102
    }
58e1fb3943e6atagen2026-10-10 13:30 UTC103
}
58e1fb3943e6atagen2026-10-10 13:30 UTC104
782069860236atagen2026-10-10 12:44 UTC105
pub struct Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC106
    pub dc: i32,
dfa38cf4cd4batagen2026-10-10 09:17 UTC107
    pub length: f64,
dfa38cf4cd4batagen2026-10-10 09:17 UTC108
    pub girth: f64,
782069860236atagen2026-10-10 12:44 UTC109
    /// Minimum and maximum foreskin the technique tolerates. A minimum above zero means it is used.
dfa38cf4cd4batagen2026-10-10 09:17 UTC110
    pub foreskin: Option<(f64, f64)>,
dfa38cf4cd4batagen2026-10-10 09:17 UTC111
    pub foreskin_growth: f64,
dfa38cf4cd4batagen2026-10-10 09:17 UTC112
    pub lube: LubeRule,
dfa38cf4cd4batagen2026-10-10 09:17 UTC113
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC114
782069860236atagen2026-10-10 12:44 UTC115
impl Training {
dfa38cf4cd4batagen2026-10-10 09:17 UTC116
    pub fn name(self) -> &'static str {
dfa38cf4cd4batagen2026-10-10 09:17 UTC117
        match self {
dfa38cf4cd4batagen2026-10-10 09:17 UTC118
            Self::Wet => "wet",
dfa38cf4cd4batagen2026-10-10 09:17 UTC119
            Self::Dry => "dry",
dfa38cf4cd4batagen2026-10-10 09:17 UTC120
            Self::Stretch => "stretch",
dfa38cf4cd4batagen2026-10-10 09:17 UTC121
            Self::Uli => "uli",
dfa38cf4cd4batagen2026-10-10 09:17 UTC122
        }
dfa38cf4cd4batagen2026-10-10 09:17 UTC123
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC124
782069860236atagen2026-10-10 12:44 UTC125
    pub fn profile(self) -> Profile {
782069860236atagen2026-10-10 12:44 UTC126
        match self {
dfa38cf4cd4batagen2026-10-10 09:17 UTC127
            Self::Wet => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC128
                dc: 10,
dfa38cf4cd4batagen2026-10-10 09:17 UTC129
                length: 0.010,
dfa38cf4cd4batagen2026-10-10 09:17 UTC130
                girth: 0.005,
dfa38cf4cd4batagen2026-10-10 09:17 UTC131
                foreskin: None,
dfa38cf4cd4batagen2026-10-10 09:17 UTC132
                foreskin_growth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC133
                lube: LubeRule::Required,
dfa38cf4cd4batagen2026-10-10 09:17 UTC134
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC135
            Self::Dry => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC136
                dc: 12,
dfa38cf4cd4batagen2026-10-10 09:17 UTC137
                length: 0.008,
dfa38cf4cd4batagen2026-10-10 09:17 UTC138
                girth: 0.003,
dfa38cf4cd4batagen2026-10-10 09:17 UTC139
                foreskin: Some((0.8, 2.0)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC140
                foreskin_growth: 0.01,
dfa38cf4cd4batagen2026-10-10 09:17 UTC141
                lube: LubeRule::Forbidden,
dfa38cf4cd4batagen2026-10-10 09:17 UTC142
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC143
            Self::Stretch => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC144
                dc: 11,
dfa38cf4cd4batagen2026-10-10 09:17 UTC145
                length: 0.015,
dfa38cf4cd4batagen2026-10-10 09:17 UTC146
                girth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC147
                foreskin: Some((0.0, 1.8)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC148
                foreskin_growth: 0.03,
dfa38cf4cd4batagen2026-10-10 09:17 UTC149
                lube: LubeRule::Optional,
dfa38cf4cd4batagen2026-10-10 09:17 UTC150
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC151
            Self::Uli => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC152
                dc: 15,
dfa38cf4cd4batagen2026-10-10 09:17 UTC153
                length: 0.002,
dfa38cf4cd4batagen2026-10-10 09:17 UTC154
                girth: 0.020,
dfa38cf4cd4batagen2026-10-10 09:17 UTC155
                foreskin: None,
dfa38cf4cd4batagen2026-10-10 09:17 UTC156
                foreskin_growth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC157
                lube: LubeRule::Optional,
dfa38cf4cd4batagen2026-10-10 09:17 UTC158
            },
782069860236atagen2026-10-10 12:44 UTC159
        }
782069860236atagen2026-10-10 12:44 UTC160
    }
782069860236atagen2026-10-10 12:44 UTC161
}
782069860236atagen2026-10-10 12:44 UTC162
782069860236atagen2026-10-10 12:44 UTC163
impl Utility {
782069860236atagen2026-10-10 12:44 UTC164
    pub fn name(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC165
        match self {
782069860236atagen2026-10-10 12:44 UTC166
            Self::Warmup => "warmup",
782069860236atagen2026-10-10 12:44 UTC167
            Self::Ice => "ice",
782069860236atagen2026-10-10 12:44 UTC168
            Self::Edge => "edge",
782069860236atagen2026-10-10 12:44 UTC169
            Self::Pump => "pump",
782069860236atagen2026-10-10 12:44 UTC170
            Self::Supplement => "supplement",
782069860236atagen2026-10-10 12:44 UTC171
        }
782069860236atagen2026-10-10 12:44 UTC172
    }
782069860236atagen2026-10-10 12:44 UTC173
782069860236atagen2026-10-10 12:44 UTC174
    fn effect(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC175
        match self {
782069860236atagen2026-10-10 12:44 UTC176
            Self::Warmup => "EQ +25. Satisfies the warm-up precondition.",
782069860236atagen2026-10-10 12:44 UTC177
            Self::Ice => "EQ -40. Consumes an ice pack.",
782069860236atagen2026-10-10 12:44 UTC178
            Self::Edge => "EQ +15 and a little girth. Three in a row is a loop.",
782069860236atagen2026-10-10 12:44 UTC179
            Self::Pump => "Large gains, all temporary. Requires a pump.",
782069860236atagen2026-10-10 12:44 UTC180
            Self::Supplement => "Consumes a supplement.",
782069860236atagen2026-10-10 12:44 UTC181
        }
782069860236atagen2026-10-10 12:44 UTC182
    }
782069860236atagen2026-10-10 12:44 UTC183
}
782069860236atagen2026-10-10 12:44 UTC184
782069860236atagen2026-10-10 12:44 UTC185
impl Technique {
782069860236atagen2026-10-10 12:44 UTC186
    pub const ALL: [Self; 9] = [
782069860236atagen2026-10-10 12:44 UTC187
        Self::Utility(Utility::Warmup),
782069860236atagen2026-10-10 12:44 UTC188
        Self::Utility(Utility::Ice),
782069860236atagen2026-10-10 12:44 UTC189
        Self::Utility(Utility::Edge),
782069860236atagen2026-10-10 12:44 UTC190
        Self::Utility(Utility::Pump),
782069860236atagen2026-10-10 12:44 UTC191
        Self::Utility(Utility::Supplement),
782069860236atagen2026-10-10 12:44 UTC192
        Self::Training(Training::Wet),
782069860236atagen2026-10-10 12:44 UTC193
        Self::Training(Training::Dry),
782069860236atagen2026-10-10 12:44 UTC194
        Self::Training(Training::Stretch),
782069860236atagen2026-10-10 12:44 UTC195
        Self::Training(Training::Uli),
782069860236atagen2026-10-10 12:44 UTC196
    ];
782069860236atagen2026-10-10 12:44 UTC197
782069860236atagen2026-10-10 12:44 UTC198
    pub fn name(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC199
        match self {
782069860236atagen2026-10-10 12:44 UTC200
            Self::Training(t) => t.name(),
782069860236atagen2026-10-10 12:44 UTC201
            Self::Utility(u) => u.name(),
782069860236atagen2026-10-10 12:44 UTC202
        }
782069860236atagen2026-10-10 12:44 UTC203
    }
782069860236atagen2026-10-10 12:44 UTC204
782069860236atagen2026-10-10 12:44 UTC205
    pub fn parse(name: &str) -> Option<Self> {
782069860236atagen2026-10-10 12:44 UTC206
        Self::ALL.into_iter().find(|t| t.name() == name)
dfa38cf4cd4batagen2026-10-10 09:17 UTC207
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC208
58e1fb3943e6atagen2026-10-10 13:30 UTC209
    pub fn lubricant(self) -> Option<&'static str> {
58e1fb3943e6atagen2026-10-10 13:30 UTC210
        match self {
58e1fb3943e6atagen2026-10-10 13:30 UTC211
            Self::Training(training) => Some(training.profile().lube.name()),
58e1fb3943e6atagen2026-10-10 13:30 UTC212
            Self::Utility(_) => None,
58e1fb3943e6atagen2026-10-10 13:30 UTC213
        }
58e1fb3943e6atagen2026-10-10 13:30 UTC214
    }
58e1fb3943e6atagen2026-10-10 13:30 UTC215
dfa38cf4cd4batagen2026-10-10 09:17 UTC216
    pub fn describe(self, forum_read: bool) -> Value {
782069860236atagen2026-10-10 12:44 UTC217
        let training = match self {
782069860236atagen2026-10-10 12:44 UTC218
            Self::Utility(utility) => {
782069860236atagen2026-10-10 12:44 UTC219
                return json!({ "name": utility.name(), "effect": utility.effect() });
782069860236atagen2026-10-10 12:44 UTC220
            }
782069860236atagen2026-10-10 12:44 UTC221
            Self::Training(training) => training,
dfa38cf4cd4batagen2026-10-10 09:17 UTC222
        };
782069860236atagen2026-10-10 12:44 UTC223
        let profile = training.profile();
58e1fb3943e6atagen2026-10-10 13:30 UTC224
        let lubricant = profile.lube.name();
dfa38cf4cd4batagen2026-10-10 09:17 UTC225
        json!({
782069860236atagen2026-10-10 12:44 UTC226
            "name": training.name(),
782069860236atagen2026-10-10 12:44 UTC227
            "dc": profile.dc,
dfa38cf4cd4batagen2026-10-10 09:17 UTC228
            "lubricant": lubricant,
782069860236atagen2026-10-10 12:44 UTC229
            "foreskin": profile.foreskin.map(|(min, max)| json!({ "min": min, "max": max })),
782069860236atagen2026-10-10 12:44 UTC230
            "locked": training == Training::Uli && !forum_read,
dfa38cf4cd4batagen2026-10-10 09:17 UTC231
        })
dfa38cf4cd4batagen2026-10-10 09:17 UTC232
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC233
}