EduPets has no backend database and no server-side sessions. Everything that needs to survive a page navigation — the pet’s name, its current hunger/sleep/happiness levels, and the task the child has been assigned — is stored in the browser’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Edupets-Studio/Edu-pets/llms.txt
Use this file to discover all available pages before exploring further.
localStorage API as serialised JSON strings. This keeps the architecture simple and means the game works entirely offline once the page has loaded, but it also means all progress is local to the device and browser the child is using.
Why localStorage?
Since there is no backend database,localStorage is the only place game state can persist across page navigations without re-fetching from the server. JavaScript on any page can call localStorage.getItem(key) and immediately recover the pet’s last known state. Writing is synchronous and instant, so stat values update in real time as the decay timer fires every 300 ms.
The trade-off is that data is device-scoped. A child who logs in from a different browser or clears their browser storage starts fresh. There is no cross-device sync.
State reference
| Key | Type | Default | Written by | Read by | Description |
|---|---|---|---|---|---|
nombreMascota | string | "Pingüi" | mascota.js → guardarNombre() | mascota.js → cargarNombre() | The player-chosen name of the virtual pet |
niveles | JSON object | {comida:100, sueno:100, felicidad:100} | mascota.js → degradarOrbes(), actualizarOrbes(); Suma.js → aumentarOrbeSiCoincide() | mascota.js → nivelesIniciales() | Current pet stat values — each ranges from 0 to 100 |
tareaActual | JSON object | null (randomly generated on first load) | mascota.js → generarTarea() | Suma.js / resta.js / etc. → aumentarOrbeSiCoincide() | The currently assigned task; cleared when the matching exercise is completed |
niveles object shape
0 and 100 inclusive. The decimal precision accumulates because the decay step (-0.03) and boost step (+20) are applied in floating-point arithmetic. The UI rounds to the nearest integer for display (Math.round(valor)).
tareaActual object shape
| Field | Values | Meaning |
|---|---|---|
tipo | "suma", "resta", "multiplicacion", "division" | Which exercise type fulfils this task |
texto | Human-readable Spanish string | Displayed in the task box on the pet dashboard |
orbe | "comida", "sueno", "felicidad" | Which stat is boosted when the task is completed |
mascota.js:
static/js/mascota.js (tareas array)
Stat decay calculation
When the/mascota page loads, a repeating timer is started that slowly drains all three stats to simulate the pet getting hungry, tired, and less happy over time:
static/js/mascota.js (degradarOrbes)
| Interval | Decrement | Per second | Per minute |
|---|---|---|---|
| Every 300 ms | −0.03 | −0.1 | ~−6 points |
0 via Math.max(0, ...) and will never go negative. The timer only runs while the /mascota page is open — navigating away pauses decay because the setInterval is created in the mascota page’s script context and is cleared when the page unloads.
Stat boost on task completion
When a child finishes an exercise, the exercise JS checks whether the completed operation matches the current task. If it does, the linked stat is boosted and the task is cleared:static/js/Suma.js (aumentarOrbeSiCoincide)
Suma.js). Key behaviours:
- If
tareaActualisnull(no task assigned, or task already completed), the function returns immediately without modifying stats. - If the completed exercise type does not match
tarea.tipo, nothing happens — completing the wrong exercise does not reward stats. - The boost is
+20points, capped at100viaMath.min(100, ...). tareaActualis removed fromlocalStorageafter the boost so a new task will be generated on the next visit to/mascota.
