Skip to content

Feat/implement quest management - #26

Merged
iflames1 merged 2 commits into
devfrom
feat/implement-quest-management
Sep 1, 2026
Merged

Feat/implement quest management#26
iflames1 merged 2 commits into
devfrom
feat/implement-quest-management

Conversation

@iflames1

@iflames1 iflames1 commented Sep 1, 2026

Copy link
Copy Markdown
Member

No description provided.

- Introduced a new function `calculate_wars_point_for` to compute wars points based on rank, participants, and win status.
- Updated the existing `calculate_wars_point` function to utilize the new calculation method.
- Added comprehensive tests for the wars points calculation to ensure accuracy.
- Created a new module for quest management, including quest claims and evaluation logic.
- Implemented caching for quest data and integrated it with the existing user and match systems.
- Enhanced the quest catalog with various quest definitions and metrics for tracking user progress.

This update improves the overall game experience by providing a structured approach to calculating rewards and managing quests.
- Bumped sw-plugin version from 1.0.3 to 1.0.4 in Cargo.toml and Cargo.lock files.
- Updated README.md to reflect the new version of sw-plugin.
- Ensured consistency across dependencies in the project.

This update prepares the project for the latest features and improvements in sw-plugin.
Copilot AI lite review requested due to automatic review settings September 1, 2026 21:58
@iflames1
iflames1 merged commit 053d302 into dev Sep 1, 2026
1 check passed
@iflames1
iflames1 deleted the feat/implement-quest-management branch September 1, 2026 21:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Quest-related user mutations have a missing WS publish and a silent best-effort DB failure path, and the server duplicates the Wars Points formula instead of calling the shared helper.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Implements a server-side quest system (read/evaluate + claim ledger) with referral/intro user flags, Redis caching, and realtime invalidation/broadcast so clients can keep quest UI in sync.

Changes:

  • Adds DB schema for quest/referral user flags and quest_claims ledger (including Getting Started backfill).
  • Introduces crates/sw-server/src/quests/* (catalog, period logic, evaluation, view assembly, caching, post-match ingest) plus new /quests routes and leaderboard modes.
  • Updates Wars Points calculation behavior to avoid awarding a win bonus on draws (new helper in sw-plugin, used by hosts).
File summaries
File Description
migrations/20260901000001_quests.sql Adds quest/referral columns to users, creates quest_claims, and backfills Getting Started completion.
crates/sw-server/src/services/vault_oracle.rs Formatting-only cleanup for settlement helpers/tests.
crates/sw-server/src/services/realtime.rs Adds quest.updated publish helpers for per-user WS topic.
crates/sw-server/src/routes/users.rs Adds referral + quest-intro endpoints; includes quest flags in /users payload and quest invalidation hooks.
crates/sw-server/src/routes/quests.rs New quests read/claim endpoints with transactional claim insertion and cache invalidation.
crates/sw-server/src/routes/mod.rs Mounts the new /quests routes.
crates/sw-server/src/routes/leaderboard.rs Adds board query enum to serve game/quest/all leaderboards.
crates/sw-server/src/quests/view.rs Assembles GET /quests/me response shape, including bonus mission handling.
crates/sw-server/src/quests/streak.rs Implements streak calculation from unique UTC play dates.
crates/sw-server/src/quests/period.rs Defines UTC quest periods/IDs and cache TTL calculation.
crates/sw-server/src/quests/mod.rs Orchestrates load paths (DB/tx), caching, and assembly of quest snapshot.
crates/sw-server/src/quests/ingest.rs Adds post-match async ingest hook (invalidate cache, stamp GS, publish WS).
crates/sw-server/src/quests/evaluate.rs Buckets match history into metrics and maps catalog → quest state/progress.
crates/sw-server/src/quests/catalog.rs Defines in-code quest catalog and paid ladder stages.
crates/sw-server/src/quests/cache.rs Implements Redis caching for GET /quests/me.
crates/sw-server/src/lib.rs Exposes the new quests module.
crates/sw-server/src/host.rs Spawns quest ingest after match persistence; updates Wars Points computation in host.
crates/sw-server/src/data/users.rs Adds quest flag reads + referral/intro mutation queries; updates anonymize to clear referrals.
crates/sw-server/src/data/quest_claims.rs Implements quest claim persistence + match reads + referral counts + quest leaderboards.
crates/sw-server/src/data/mod.rs Exposes the new quest_claims data module.
crates/sw-plugin/src/nop_host.rs Uses winner-aware Wars Points helper for placeholder host.
crates/sw-plugin/src/lib.rs Re-exports calculate_wars_point_for.
crates/sw-plugin/src/kit.rs Introduces calculate_wars_point_for and updates fallback calculation.
crates/sw-plugin/README.md Documents winner-aware Wars Points + bumps dependency snippet.
crates/sw-plugin/Cargo.toml Bumps sw-plugin crate version to 1.0.4.
Cargo.toml Updates workspace dependency to sw-plugin = "1.0.4".
Cargo.lock Locks sw-plugin to 1.0.4.
Review details
  • Files reviewed: 26/27 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +380 to +386
let mut redis = state.redis.clone();
crate::quests::cache::invalidate(&mut redis, UserId::from(user_id)).await;
let _ = crate::data::quest_claims::PgQuestRepo::new(state.db.clone())
.maybe_stamp_getting_started(UserId::from(user_id))
.await;
crate::services::realtime::publish_quest_updated(&state, UserId::from(user_id));
}
Comment on lines +441 to +445
let repo = PgUserRepo::new(state.db.clone());
repo.mark_quest_intro_seen(auth.user_id).await?;
let mut redis = state.redis.clone();
crate::quests::cache::invalidate(&mut redis, auth.user_id).await;
let user = repo
Comment on lines +736 to +749
let wars_point = {
let rank = ctx.rank.max(1) as i64;
let participants = ctx.participants.max(1) as i64;
let mut points = 5;
points += (participants - rank).max(0) * 2;
if is_winner {
points += 8;
}
let paid = !ctx.is_sponsored && ctx.entry_amount.unwrap_or(0.0) > 0.0;
if paid {
points += 3;
}
points.clamp(0, 40)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants