games:
  - type: command-sprint
    title: "Git Command Sprint"
    challenges:
      - prompt: "Initialize a new Git repository in the current directory."
        answer: "git init"
        alternates: ["git init ."]
        timeLimit: 18
      - prompt: "Stage all changed files in the working directory."
        answer: "git add ."
        alternates: ["git add -A", "git add --all"]
        timeLimit: 15
      - prompt: "Create a commit with the message 'Add login form'."
        answer: "git commit -m \"Add login form\""
        alternates: ["git commit -m 'Add login form'"]
        timeLimit: 20
      - prompt: "Create and switch to a new branch named feature/auth."
        answer: "git checkout -b feature/auth"
        alternates: ["git switch -c feature/auth"]
        timeLimit: 20
      - prompt: "Show the commit log as a compact one-line-per-commit."
        answer: "git log --oneline"
        alternates: ["git log --oneline -n 20", "git log --pretty=oneline"]
        timeLimit: 18
      - prompt: "Discard all local changes in src/utils.js (restore to last commit)."
        answer: "git checkout -- src/utils.js"
        alternates: ["git restore src/utils.js"]
        timeLimit: 22
      - prompt: "Undo the last commit but keep your changes staged."
        answer: "git reset --soft HEAD~1"
        alternates: ["git reset --soft HEAD^"]
        timeLimit: 22
      - prompt: "Merge the main branch into your current branch."
        answer: "git merge main"
        alternates: ["git merge origin/main"]
        timeLimit: 18
      - prompt: "Rebase your current branch onto main."
        answer: "git rebase main"
        alternates: ["git rebase origin/main"]
        timeLimit: 20
      - prompt: "Abort an in-progress merge (return to pre-merge state)."
        answer: "git merge --abort"
        alternates: []
        timeLimit: 20

  - type: scenario
    title: "Merge Conflict Crisis"
    startHealth: 5
    steps:
      - id: start
        situation: "You're on branch feature/checkout-ui. You haven't pulled from main in a week. Your teammate merged a big refactor. You run `git pull origin main` and Git reports merge conflicts in 3 files: src/App.jsx, src/components/Header.jsx, and package.json. What do you do first?"
        choices:
          - text: "Open each conflicted file and read the conflict markers."
            consequence: "Smart. You inspect the conflicts before taking action."
            health: 1
            next: inspect
          - text: "Run git merge --abort, then git pull --rebase origin main."
            consequence: "Rebasing first can simplify conflicts, but you haven't seen them yet."
            health: 0
            next: rebase_path
          - text: "Run git checkout --theirs . to accept all incoming changes."
            consequence: "Danger! That discards all your work. You'd lose your feature code."
            health: -2
            next: bad_choice
      - id: inspect
        situation: "You open App.jsx and see conflict markers (<<<<<<< HEAD, =======, >>>>>>> main). The conflict is in the router setup: your version added a new route; main refactored the whole routing. What's your strategy?"
        choices:
          - text: "Manually resolve: keep my new route and adapt it to main's refactor."
            consequence: "Correct. You integrate both sets of changes properly."
            health: 1
            next: resolve_one
          - text: "Use git checkout --ours App.jsx to keep my version for this file."
            consequence: "That keeps your route but may not work with main's refactor—integration issues ahead."
            health: -1
            next: ours_path
          - text: "Delete the conflict markers and fix any syntax errors after."
            consequence: "Risky. You might introduce broken code or lose logic."
            health: -2
            next: quick_fix
      - id: resolve_one
        situation: "You've resolved App.jsx. Header.jsx has a simpler conflict: both branches changed the same prop name. package.json has version conflicts. What next?"
        choices:
          - text: "Resolve Header.jsx and package.json, then git add . and git commit."
            consequence: "Good. You resolve all files, stage them, and complete the merge."
            health: 1
            next: success
          - text: "Run git add App.jsx only, commit, then deal with the others later."
            consequence: "Leaving conflicts unresolved will block the merge. You need to fix all conflicted files."
            health: -1
            next: partial_fail
          - text: "Use a merge tool (e.g. git mergetool) to resolve the rest."
            consequence: "Using a tool is fine. You resolve the remaining conflicts."
            health: 1
            next: success
      - id: rebase_path
        situation: "You aborted and ran git pull --rebase. Now you're mid-rebase with conflicts. Git says 'Resolve conflicts, then run git add <file> and git rebase --continue.' What do you do?"
        choices:
          - text: "Resolve each conflicted file, git add them, then git rebase --continue."
            consequence: "Right. That's the correct rebase flow."
            health: 1
            next: success
          - text: "Run git rebase --skip to skip this commit."
            consequence: "Only skip if you truly want to discard that commit. Usually you resolve."
            health: -1
            next: skip_warning
          - text: "Run git rebase --abort to cancel the rebase entirely."
            consequence: "You're back to square one. Merge might have been simpler."
            health: -1
            next: abort_path
      - id: ours_path
        situation: "You used --ours for App.jsx. Now Header.jsx and package.json still have conflicts. The build fails because your App.jsx doesn't match main's imports. What now?"
        choices:
          - text: "Undo the merge, then resolve all three files properly this time."
            consequence: "Wise. Starting fresh with a careful resolve is better."
            health: 1
            next: start
          - text: "Patch Header.jsx and package.json manually to fix the build."
            consequence: "You salvage it, but it took extra work. Learning moment."
            health: 0
            next: success
          - text: "Push as-is and ask your teammate to fix the build."
            consequence: "Not a good habit. You own your merge resolution."
            health: -2
            next: bad_choice
      - id: quick_fix
        situation: "You removed the markers quickly. A test fails: the new route renders a 404. You realize you dropped a line during the quick fix. What do you do?"
        choices:
          - text: "Re-read the conflict, restore the correct logic, and re-run tests."
            consequence: "Good recovery. Take your time with conflicts."
            health: 1
            next: success
          - text: "Revert the merge commit and redo the merge more carefully."
            consequence: "Also valid. Clean slate, proper resolution."
            health: 0
            next: success
          - text: "Comment out the failing test and move on."
            consequence: "Never a good idea. Tech debt and hidden bugs."
            health: -2
            next: bad_choice
      - id: success
        situation: "Merge complete. Your branch is updated with main, conflicts resolved, and the build passes. Well done!"
        choices:
          - text: "Continue working."
            consequence: "You've navigated the merge conflict successfully."
            health: 0
            next: end
      - id: partial_fail
        situation: "Git won't complete the merge—there are still unmerged paths. You need to resolve and stage every conflicted file before committing."
        choices:
          - text: "Go back and resolve Header.jsx and package.json, then add and commit."
            consequence: "You fix the mistake and complete the merge correctly."
            health: 0
            next: success
          - text: "Give up and run git merge --abort."
            consequence: "You abort and will need to redo the pull and resolution."
            health: -1
            next: abort_path
      - id: skip_warning
        situation: "You skipped a commit. If that commit had important changes, they're now gone. The rebase continues with more conflicts. Do you have more conflict resolution to do?"
        choices:
          - text: "Yes, resolve the next conflicts and git rebase --continue."
            consequence: "You work through the remaining conflicts."
            health: 0
            next: success
          - text: "Run git rebase --abort and try a regular merge instead."
            consequence: "Sometimes merge is simpler than rebase when conflicts are many."
            health: 0
            next: abort_path
      - id: abort_path
        situation: "You've aborted. You're back on your branch before the merge/rebase. Main still has the refactor. What now?"
        choices:
          - text: "Pull with merge, then resolve conflicts carefully in all files."
            consequence: "You try again with a clearer approach."
            health: 0
            next: start
          - text: "Ask your teammate to resolve the conflicts for you."
            consequence: "Learning to resolve conflicts is a core skill. Give it a shot."
            health: -1
            next: bad_choice
      - id: bad_choice
        situation: "That choice cost you. You've either lost work, created tech debt, or passed the buck. Merge conflicts demand care. Try to recover or restart."
        choices:
          - text: "Start over with a fresh mindset."
            consequence: "Every conflict is a chance to practice."
            health: 0
            next: start
          - text: "Accept the consequences and continue."
            consequence: "Sometimes we learn the hard way."
            health: 0
            next: end
