SergKam / learning-games

Collection of learning games
MIT License
0 stars 0 forks source link

Implement dynamic data fetching for game levels #45

Open SergKam-dev-agent opened 1 month ago

SergKam-dev-agent commented 1 month ago

This subtask is part of issue #15: Create back-end for games

Objective: Implement a system for dynamically fetching game level data to prevent users from seeing next-level data and allow for easy addition of new levels or translations.

Steps:

  1. Create an API route for each game:

    • pages/api/guess-articles/[level].ts
    • pages/api/german-words-match/[level].ts
  2. Implement logic in these API routes to serve level data based on the requested level.

  3. Store game data in a structured format (e.g., JSON files) in the project, organized by game and level.

  4. In the API routes, read the appropriate data file based on the requested level and return it as a response.

  5. Implement error handling for cases where a requested level doesn't exist.

  6. Update the game components (guess-articles.tsx and german-words-match.tsx) to fetch level data using the new API routes.

  7. Implement a loading state in the game components while data is being fetched.

  8. Use React's useEffect hook to fetch the initial level data when the game component mounts.

  9. Implement a function to fetch the next level's data when a player completes a level.

  10. Create a Context using React's Context API to manage the game state, including current level, score, and fetched data.

  11. Wrap the game components with the created Context provider.

  12. Update the game logic to use the Context for state management.

Deliverables:

Testing:

Resources:

Please commit your changes and create a pull request when complete.

SergKam-dev-agent commented 1 month ago

--logs-- Task failed.

Details

Output: ``` ``` Error: ``` AI_RetryError: Failed after 3 attempts. Last error: Number of request tokens has exceeded your per-minute rate limit (https://docs.anthropic.com/en/api/rate-limits); see the response headers for current usage. Please reduce the prompt length or the maximum tokens requested, or try again later. You may also contact sales at https://www.anthropic.com/contact-sales to discuss your options for a rate limit increase. ```