atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0
4b690ff501b89a8185e0f0c9ceaa61a89ce1a056
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
782069860236atagen2026-10-10 12:44 UTC95
pub struct Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC96
    pub dc: i32,
dfa38cf4cd4batagen2026-10-10 09:17 UTC97
    pub length: f64,
dfa38cf4cd4batagen2026-10-10 09:17 UTC98
    pub girth: f64,
782069860236atagen2026-10-10 12:44 UTC99
    /// Minimum and maximum foreskin the technique tolerates. A minimum above zero means it is used.
dfa38cf4cd4batagen2026-10-10 09:17 UTC100
    pub foreskin: Option<(f64, f64)>,
dfa38cf4cd4batagen2026-10-10 09:17 UTC101
    pub foreskin_growth: f64,
dfa38cf4cd4batagen2026-10-10 09:17 UTC102
    pub lube: LubeRule,
dfa38cf4cd4batagen2026-10-10 09:17 UTC103
}
dfa38cf4cd4batagen2026-10-10 09:17 UTC104
782069860236atagen2026-10-10 12:44 UTC105
impl Training {
dfa38cf4cd4batagen2026-10-10 09:17 UTC106
    pub fn name(self) -> &'static str {
dfa38cf4cd4batagen2026-10-10 09:17 UTC107
        match self {
dfa38cf4cd4batagen2026-10-10 09:17 UTC108
            Self::Wet => "wet",
dfa38cf4cd4batagen2026-10-10 09:17 UTC109
            Self::Dry => "dry",
dfa38cf4cd4batagen2026-10-10 09:17 UTC110
            Self::Stretch => "stretch",
dfa38cf4cd4batagen2026-10-10 09:17 UTC111
            Self::Uli => "uli",
dfa38cf4cd4batagen2026-10-10 09:17 UTC112
        }
dfa38cf4cd4batagen2026-10-10 09:17 UTC113
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC114
782069860236atagen2026-10-10 12:44 UTC115
    pub fn profile(self) -> Profile {
782069860236atagen2026-10-10 12:44 UTC116
        match self {
dfa38cf4cd4batagen2026-10-10 09:17 UTC117
            Self::Wet => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC118
                dc: 10,
dfa38cf4cd4batagen2026-10-10 09:17 UTC119
                length: 0.010,
dfa38cf4cd4batagen2026-10-10 09:17 UTC120
                girth: 0.005,
dfa38cf4cd4batagen2026-10-10 09:17 UTC121
                foreskin: None,
dfa38cf4cd4batagen2026-10-10 09:17 UTC122
                foreskin_growth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC123
                lube: LubeRule::Required,
dfa38cf4cd4batagen2026-10-10 09:17 UTC124
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC125
            Self::Dry => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC126
                dc: 12,
dfa38cf4cd4batagen2026-10-10 09:17 UTC127
                length: 0.008,
dfa38cf4cd4batagen2026-10-10 09:17 UTC128
                girth: 0.003,
dfa38cf4cd4batagen2026-10-10 09:17 UTC129
                foreskin: Some((0.8, 2.0)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC130
                foreskin_growth: 0.01,
dfa38cf4cd4batagen2026-10-10 09:17 UTC131
                lube: LubeRule::Forbidden,
dfa38cf4cd4batagen2026-10-10 09:17 UTC132
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC133
            Self::Stretch => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC134
                dc: 11,
dfa38cf4cd4batagen2026-10-10 09:17 UTC135
                length: 0.015,
dfa38cf4cd4batagen2026-10-10 09:17 UTC136
                girth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC137
                foreskin: Some((0.0, 1.8)),
dfa38cf4cd4batagen2026-10-10 09:17 UTC138
                foreskin_growth: 0.03,
dfa38cf4cd4batagen2026-10-10 09:17 UTC139
                lube: LubeRule::Optional,
dfa38cf4cd4batagen2026-10-10 09:17 UTC140
            },
dfa38cf4cd4batagen2026-10-10 09:17 UTC141
            Self::Uli => Profile {
dfa38cf4cd4batagen2026-10-10 09:17 UTC142
                dc: 15,
dfa38cf4cd4batagen2026-10-10 09:17 UTC143
                length: 0.002,
dfa38cf4cd4batagen2026-10-10 09:17 UTC144
                girth: 0.020,
dfa38cf4cd4batagen2026-10-10 09:17 UTC145
                foreskin: None,
dfa38cf4cd4batagen2026-10-10 09:17 UTC146
                foreskin_growth: 0.0,
dfa38cf4cd4batagen2026-10-10 09:17 UTC147
                lube: LubeRule::Optional,
dfa38cf4cd4batagen2026-10-10 09:17 UTC148
            },
782069860236atagen2026-10-10 12:44 UTC149
        }
782069860236atagen2026-10-10 12:44 UTC150
    }
782069860236atagen2026-10-10 12:44 UTC151
}
782069860236atagen2026-10-10 12:44 UTC152
782069860236atagen2026-10-10 12:44 UTC153
impl Utility {
782069860236atagen2026-10-10 12:44 UTC154
    pub fn name(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC155
        match self {
782069860236atagen2026-10-10 12:44 UTC156
            Self::Warmup => "warmup",
782069860236atagen2026-10-10 12:44 UTC157
            Self::Ice => "ice",
782069860236atagen2026-10-10 12:44 UTC158
            Self::Edge => "edge",
782069860236atagen2026-10-10 12:44 UTC159
            Self::Pump => "pump",
782069860236atagen2026-10-10 12:44 UTC160
            Self::Supplement => "supplement",
782069860236atagen2026-10-10 12:44 UTC161
        }
782069860236atagen2026-10-10 12:44 UTC162
    }
782069860236atagen2026-10-10 12:44 UTC163
782069860236atagen2026-10-10 12:44 UTC164
    fn effect(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC165
        match self {
782069860236atagen2026-10-10 12:44 UTC166
            Self::Warmup => "EQ +25. Satisfies the warm-up precondition.",
782069860236atagen2026-10-10 12:44 UTC167
            Self::Ice => "EQ -40. Consumes an ice pack.",
782069860236atagen2026-10-10 12:44 UTC168
            Self::Edge => "EQ +15 and a little girth. Three in a row is a loop.",
782069860236atagen2026-10-10 12:44 UTC169
            Self::Pump => "Large gains, all temporary. Requires a pump.",
782069860236atagen2026-10-10 12:44 UTC170
            Self::Supplement => "Consumes a 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
782069860236atagen2026-10-10 12:44 UTC175
impl Technique {
782069860236atagen2026-10-10 12:44 UTC176
    pub const ALL: [Self; 9] = [
782069860236atagen2026-10-10 12:44 UTC177
        Self::Utility(Utility::Warmup),
782069860236atagen2026-10-10 12:44 UTC178
        Self::Utility(Utility::Ice),
782069860236atagen2026-10-10 12:44 UTC179
        Self::Utility(Utility::Edge),
782069860236atagen2026-10-10 12:44 UTC180
        Self::Utility(Utility::Pump),
782069860236atagen2026-10-10 12:44 UTC181
        Self::Utility(Utility::Supplement),
782069860236atagen2026-10-10 12:44 UTC182
        Self::Training(Training::Wet),
782069860236atagen2026-10-10 12:44 UTC183
        Self::Training(Training::Dry),
782069860236atagen2026-10-10 12:44 UTC184
        Self::Training(Training::Stretch),
782069860236atagen2026-10-10 12:44 UTC185
        Self::Training(Training::Uli),
782069860236atagen2026-10-10 12:44 UTC186
    ];
782069860236atagen2026-10-10 12:44 UTC187
782069860236atagen2026-10-10 12:44 UTC188
    pub fn name(self) -> &'static str {
782069860236atagen2026-10-10 12:44 UTC189
        match self {
782069860236atagen2026-10-10 12:44 UTC190
            Self::Training(t) => t.name(),
782069860236atagen2026-10-10 12:44 UTC191
            Self::Utility(u) => u.name(),
782069860236atagen2026-10-10 12:44 UTC192
        }
782069860236atagen2026-10-10 12:44 UTC193
    }
782069860236atagen2026-10-10 12:44 UTC194
782069860236atagen2026-10-10 12:44 UTC195
    pub fn parse(name: &str) -> Option<Self> {
782069860236atagen2026-10-10 12:44 UTC196
        Self::ALL.into_iter().find(|t| t.name() == name)
dfa38cf4cd4batagen2026-10-10 09:17 UTC197
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC198
dfa38cf4cd4batagen2026-10-10 09:17 UTC199
    pub fn describe(self, forum_read: bool) -> Value {
782069860236atagen2026-10-10 12:44 UTC200
        let training = match self {
782069860236atagen2026-10-10 12:44 UTC201
            Self::Utility(utility) => {
782069860236atagen2026-10-10 12:44 UTC202
                return json!({ "name": utility.name(), "effect": utility.effect() });
782069860236atagen2026-10-10 12:44 UTC203
            }
782069860236atagen2026-10-10 12:44 UTC204
            Self::Training(training) => training,
dfa38cf4cd4batagen2026-10-10 09:17 UTC205
        };
782069860236atagen2026-10-10 12:44 UTC206
        let profile = training.profile();
782069860236atagen2026-10-10 12:44 UTC207
        let lubricant = match profile.lube {
dfa38cf4cd4batagen2026-10-10 09:17 UTC208
            LubeRule::Required => "required",
dfa38cf4cd4batagen2026-10-10 09:17 UTC209
            LubeRule::Forbidden => "forbidden",
dfa38cf4cd4batagen2026-10-10 09:17 UTC210
            LubeRule::Optional => "optional",
dfa38cf4cd4batagen2026-10-10 09:17 UTC211
        };
dfa38cf4cd4batagen2026-10-10 09:17 UTC212
        json!({
782069860236atagen2026-10-10 12:44 UTC213
            "name": training.name(),
782069860236atagen2026-10-10 12:44 UTC214
            "dc": profile.dc,
dfa38cf4cd4batagen2026-10-10 09:17 UTC215
            "lubricant": lubricant,
782069860236atagen2026-10-10 12:44 UTC216
            "foreskin": profile.foreskin.map(|(min, max)| json!({ "min": min, "max": max })),
782069860236atagen2026-10-10 12:44 UTC217
            "locked": training == Training::Uli && !forum_read,
dfa38cf4cd4batagen2026-10-10 09:17 UTC218
        })
dfa38cf4cd4batagen2026-10-10 09:17 UTC219
    }
dfa38cf4cd4batagen2026-10-10 09:17 UTC220
}