Overview
The level system provides a framework for creating interactive git challenges. Each level defines a starting state, goal state, and solution validation logic. Location:src/js/level/
Architecture
Level Flow
Level Class
Location:src/js/level/index.js
Structure
Key Properties
| Property | Type | Description |
|---|---|---|
level | Object | Level definition with goals and solutions |
mainVis | Visualization | User’s working visualization |
goalVis | Visualization | Goal state visualization |
goalCanvasHolder | CanvasTerminalHolder | Container for goal visualization |
gitCommandsIssued | Array | Commands executed (for scoring) |
solved | Boolean | Whether level is complete |
wasResetAfterSolved | Boolean | Track resets after solving |
Level Definition
Basic Structure
Tree String Format
Goal trees are stored as URL-encoded JSON:Initialization
initGoalData(options)
Validates level has required fields:initName(options)
Sets up level toolbar:initVisualization(options)
Creates main working visualization:initGoalVisualization()
Creates goal visualization:Goal Visualization Control
showGoal(command, defer)
hideGoal(command, defer)
minimizeGoal(position, size)
Command Tracking
beforeCommandCB(command)
Called before command execution:afterCommandCB(command)
Called after command execution:doesCommandCountTowardsTotal(command)
Determines if command counts for scoring:Solution Validation
afterCommandDefer(defer, command)
Validates solution after each command:levelSolved(defer)
Handles level completion:Tree Comparison
Location:src/js/graph/treeCompare.js
dispatchFromLevel(level, currentTree)
Validates current tree matches goal:onlyMainCompared(level)
Checks if only main branch is validated:compareCommitStructure(tree1, tree2)
Compares commit graph structure:Solution Display
showSolution(command, deferred)
Displays solution animation:Level Commands
Available Commands
getInstantCommands()
Provides level-specific instant commands:Disabled Commands
Levels can disable specific commands:src/js/level/disabledMap.js
Level Sequences
Levels are organized into sequences: Location:src/levels/index.js
Related Components
- GitEngine - Executes commands
- Visualization System - Renders trees
- Command Processing - Processes user input