feat(data,engine): add WinUnder-5min and WinDrawThree weekly goal types

Adds two new weekly goals — "Win 1 game in under 5 minutes" and
"Win 1 Draw-3 game" — broadening variety beyond the existing three.
WeeklyGoalContext gains a draw_mode field so the new WinDrawThree
variant can match on draw mode. Existing tests updated to pre-complete
new goals where the win conditions overlap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-04-27 03:13:33 +00:00
parent cacacb00dc
commit bc021acfd0
2 changed files with 54 additions and 6 deletions
+11 -5
View File
@@ -80,6 +80,7 @@ fn evaluate_weekly_goals(
let ctx = WeeklyGoalContext {
time_seconds: ev.time_seconds,
used_undo: game.0.undo_count > 0,
draw_mode: game.0.draw_mode.clone(),
};
for def in WEEKLY_GOALS {
if !def.matches(&ctx) {
@@ -191,11 +192,16 @@ mod tests {
fn completing_a_goal_fires_event_and_awards_bonus() {
let mut app = headless_app();
// Pre-set the weekly_3_fast goal to 2/3 so the next fast win completes it.
app.world_mut()
.resource_mut::<ProgressResource>()
.0
.weekly_goal_progress
.insert("weekly_3_fast".to_string(), 2);
// Also pre-complete weekly_1_under_five (target=1) and weekly_5_wins /
// weekly_3_no_undo at target so a 60-second win only completes weekly_3_fast,
// keeping the XP delta predictable.
{
let mut p = app.world_mut().resource_mut::<ProgressResource>();
p.0.weekly_goal_progress.insert("weekly_3_fast".to_string(), 2);
p.0.weekly_goal_progress.insert("weekly_1_under_five".to_string(), 1);
p.0.weekly_goal_progress.insert("weekly_5_wins".to_string(), 5);
p.0.weekly_goal_progress.insert("weekly_3_no_undo".to_string(), 3);
}
// Match the current ISO week key so roll_weekly_goals doesn't clear it.
let key = current_iso_week_key(Local::now().date_naive());
app.world_mut()