pub struct ChallengeManager {
pub daily_challenge: Option<Challenge>,
pub weekly_challenge: Option<Challenge>,
pub completed_challenges: HashSet<String>,
/* private fields */
}Expand description
Manages active and completed challenges
Fields§
§daily_challenge: Option<Challenge>Currently active daily challenge
weekly_challenge: Option<Challenge>Currently active weekly challenge
completed_challenges: HashSet<String>Set of completed challenge IDs
Implementations§
Source§impl ChallengeManager
impl ChallengeManager
Sourcepub fn get_daily_challenge(&mut self) -> Challenge
pub fn get_daily_challenge(&mut self) -> Challenge
Get or generate today’s daily challenge
Sourcepub fn get_weekly_challenge(&mut self) -> Challenge
pub fn get_weekly_challenge(&mut self) -> Challenge
Get or generate this week’s weekly challenge
Sourcepub fn complete_challenge(&mut self, challenge_id: String)
pub fn complete_challenge(&mut self, challenge_id: String)
Mark a challenge as completed
Note: this only updates the manager’s own bookkeeping (used by
is_daily_completed / is_weekly_completed UI helpers). For
achievement purposes UserStats is the single source of truth —
prefer check_command, which keeps both in sync.
Sourcepub fn check_command(
&mut self,
command: &str,
stats: &mut UserStats,
) -> Option<Challenge>
pub fn check_command( &mut self, command: &str, stats: &mut UserStats, ) -> Option<Challenge>
Validation entry point the TUI should call after every executed shell command.
Checks the command against the currently active daily and weekly
challenges (as previously generated by get_daily_challenge /
get_weekly_challenge), advancing multi-step weekly-scenario
progress as steps are matched. When a challenge is completed, the
completion is recorded in this manager AND routed into stats
(UserStats::complete_challenge + the "first_challenge" event), so
UserStats remains the single source of truth for achievements.
Returns the challenge the command just completed, if any. Call
stats.check_achievements() afterwards (or use the achievements
already returned by the routed record_event) to surface unlocks.
Sourcepub fn is_challenge_completed(&self, challenge_id: &str) -> bool
pub fn is_challenge_completed(&self, challenge_id: &str) -> bool
Check if a challenge has been completed
Sourcepub fn weekly_completions(&self) -> usize
pub fn weekly_completions(&self) -> usize
Get all challenges completed this week
Sourcepub fn is_daily_completed(&self) -> bool
pub fn is_daily_completed(&self) -> bool
Check if today’s daily challenge is completed
Sourcepub fn is_weekly_completed(&self) -> bool
pub fn is_weekly_completed(&self) -> bool
Check if this week’s weekly challenge is completed