Skip to main content

cuqueclicker_lib/game/
achievement.rs

1use crate::game::state::GameState;
2
3pub type Predicate = fn(&GameState) -> bool;
4
5pub struct AchievementKind {
6    /// Stable identifier used as the save-file key. Survives reorders and
7    /// renames — flipping a predicate's position in the array never turns an
8    /// already-earned achievement back into a locked one.
9    pub id: &'static str,
10    pub unlocked: Predicate,
11}
12
13pub const ACHIEVEMENTS: &[AchievementKind] = &[
14    AchievementKind {
15        id: "first_finger",
16        unlocked: |s| s.total_clicks >= 1,
17    },
18    AchievementKind {
19        id: "warming_up",
20        unlocked: |s| s.lifetime_cuques >= crate::bignum::Mag::from_f64(100.0),
21    },
22    AchievementKind {
23        id: "seasoned_fingerer",
24        unlocked: |s| s.lifetime_cuques >= crate::bignum::Mag::from_f64(10_000.0),
25    },
26    AchievementKind {
27        id: "cuque_mogul",
28        unlocked: |s| s.lifetime_cuques >= crate::bignum::Mag::from_f64(1_000_000.0),
29    },
30    AchievementKind {
31        id: "automation",
32        unlocked: |s| s.fingerers_owned_total() >= 1,
33    },
34    AchievementKind {
35        id: "factory_of_fingers",
36        unlocked: |s| s.fingerer_count("whole_hand") >= 10,
37    },
38    AchievementKind {
39        id: "latex_enjoyer",
40        unlocked: |s| s.fingerer_count("latex_glove") >= 10,
41    },
42    AchievementKind {
43        id: "golden_touch",
44        unlocked: |s| s.golden_caught >= 1,
45    },
46    AchievementKind {
47        id: "golden_hoarder",
48        unlocked: |s| s.golden_caught >= 10,
49    },
50    AchievementKind {
51        id: "rise_of_the_machines",
52        unlocked: |s| s.fingerer_count("robotic_finger") >= 1,
53    },
54];
55
56pub fn count() -> usize {
57    ACHIEVEMENTS.len()
58}