8000 Lock home version campaign islands when no levels are unlocked by nwinter · Pull Request #7946 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Lock home version campaign islands when no levels are unlocked #7946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

nwinter
Copy link
Contributor
@nwinter nwinter commented Mar 23, 2025

Previously, you could click on them and then be taken to an empty map with nothing to do. Now, you can't click on them, and hovering over them shows a basic message to complete the previous world to unlock.
Screenshot 2025-03-23 at 15 50 24

Summary by CodeRabbit

  • New Features

    • Introduced a localized message indicating that players must complete a previous world to unlock a campaign.
    • Enhanced internationalization attributes for campaign views to support localized tooltips.
  • Style

    • Updated locked campaign visuals by replacing non-interactive pointers with a default cursor, improving user feedback.
  • Bug Fixes

    • Refined unlocking logic to keep specific campaigns accessible.
    • Optimized default language handling and level progress tracking for a smoother user experience.

Previously, you could click on them and then be taken to an empty map
with nothing to do. Now, you can't click on them, and hovering over
them shows a basic message to complete the previous world to unlock.
@nwinter nwinter requested a review from Bryukh March 23, 2025 23:01
Copy link
Contributor
coderabbitai bot commented Mar 23, 2025

Walkthrough

The changes update the internationalization, user interface styling, and campaign display logic in the application. A new localization string for locked campaigns has been added, and the Pug template now makes use of this string via additional data attributes for improved tooltips and i18n support. Moreover, the campaign locking logic has been refined in the campaign view controller to properly account for campaign types and level counts, while the associated CSS has been updated to change the visual feedback on locked elements.

Changes

File(s) Change Summary
app/locale/en.js, app/templates/play/campaign-view.pug Added locked_campaign: 'Complete previous world to unlock' for internationalization; updated Pug template to include data-i18n="[title]play.locked_campaign" (and data-placement="bottom" for beta campaigns) for proper tooltip support.
app/styles/play/campaign-view.sass Replaced pointer-events: none with cursor: default for locked campaign elements, altering how user interactions are indicated.
app/views/play/CampaignView.js Updated default language retrieval with optional chaining and fallback; refined campaign locking logic to account for non-locked campaign types (dungeon and junior), extended tooltip initialization, and modified the countLevels method to include an unlocked count.

Sequence Diagram(s)

sequenceDiagram
    participant CV as CampaignView
    participant CL as Classroom Config
    participant UI as UI Renderer

    CV->>CL: Retrieve aceConfig (using optional chaining)
    CL-->>CV: Return language value or undefined
    CV->>CV: Set default language to 'python' if undefined
    CV->>CV: Execute countLevels() to tally total, completed, and unlocked levels
    CV->>CV: Determine campaign.locked using updated logic (excludes 'dungeon' and 'junior' if levels exist)
    CV->>UI: Initialize tooltips on game controls and locked campaign elements
Loading

Possibly related PRs

Suggested reviewers

  • smallst
  • mrfinch

Poem

I'm a hopping rabbit full of cheer,
Celebrating code changes that are now clear.
Locked campaigns whisper, "Complete the past,"
While tooltips and defaults hold strong and fast.
With every line, my whiskers twitch with delight—
Hoppy coding days and bug-free nights!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02abf15 and da3864f.

📒 Files selected for processing (4)
  • app/locale/en.js (1 hunks)
  • app/styles/play/campaign-view.sass (2 hunks)
  • app/templates/play/campaign-view.pug (2 hunks)
  • app/views/play/CampaignView.js (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Node.js CI (18.10.0)
🔇 Additional comments (11)
app/locale/en.js (1)

553-553: Well-implemented user feedback message.

This new localization string clearly communicates to users why a campaign is locked and what they need to do to unlock it. The message is concise and instructive, aligning perfectly with the PR objective of preventing users from accessing empty campaign maps while providing helpful guidance.

app/styles/play/campaign-view.sass (2)

829-831: Good improvement to campaign islands user experience.

Replacing pointer-events: none with cursor: default allows users to hover over locked campaign islands while still visually indicating they're not clickable. This change enables tooltips to be displayed on hover while preventing the confusing behavior of clicking on empty maps.


907-909: Consistent styling for beta campaigns.

The same cursor behavior update has been correctly applied to beta campaigns, maintaining consistency throughout the interface.

app/templates/play/campaign-view.pug (2)

307-307: Added internationalization for locked campaign tooltip.

Adding the data-i18n="[title]play.locked_campaign" attribute enables localized tooltips for locked beta campaigns. The data-placement="bottom" attribute ensures the tooltip appears below the campaign island, improving visibility.


331-331: Consistent i18n implementation for standard campaigns.

The same internationalization has been properly applied to standard campaign islands. This ensures a consistent user experience across all campaign types.

app/views/play/CampaignView.js (6)

607-607: Improved default language handling with fallback

This change adds a fallback value for language when aceConfig is undefined, which prevents potential runtime errors.


770-771: Enhanced campaign locking logic to include junior campaign and check for unlocked levels

The campaign locking logic now:

  1. Allows both 'dungeon' and 'junior' campaigns to remain unlocked regardless of level count
  2. Locks campaigns that have no unlocked levels (with !count.unlocked condition)

This implements the core functionality of this PR, preventing users from clicking on campaign islands that have no unlocked levels.


1104-1105: Added 'unlocked' property to level count tracking

The count object now tracks unlocked levels, which is necessary for the campaign locking logic to work properly.


1111-1112: Implemented unlocked count incrementing for HOC campaigns

For Hour of Code campaigns, the code now tracks the number of unlocked levels consistently with the main campaign logic.


1120-1121: Implemented unlocked count incrementing for regular campaigns

The unlocked count is properly incremented for standard campaigns, maintaining consistency with the HOC implementation.


818-819:

✅ Verification successful

Added tooltips to locked campaign elements

Tooltip initialization is now extended to locked campaign elements, enhancing user experience by providing feedback when hovering over locked campaigns.

Let's check if there's a corresponding tooltip message for locked campaigns defined in the locale files:


🏁 Script executed:

#!/bin/bash
# Look for locked_campaign string in locale files
rg "locked_campaign" app/locale/

Length of output: 109


Tooltip localization verified

The tooltip message for locked campaigns (locked_campaign) is correctly defined in the locale file (app/locale/en.js), confirming that the tooltip initialization for locked campaign elements is valid as implemented.

  • Verified the presence of the locale string locked_campaign with value "Complete previous world to unlock".
  • The tooltip enhancement for locked campaigns in app/views/play/CampaignView.js (lines 818-819) correctly relies on this locale entry.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator
@Bryukh Bryukh left a comment

Choose a reason for hiding this comment

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

LGTM Merge

@mrfinch mrfinch merged commit 0c2358d into master Mar 26, 2025
3 checks passed
@mrfinch mrfinch deleted the nwinter/island-locking branch March 26, 2025 08:52
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.

3 participants
0