Data Reset & Clearance
Relevant source files
The following files were used as context for generating this wiki page:
- Quest.html
- index.html
- README.md
- Quest.html:125-156 (Logic for daily cycle and task generation)
- index.html:125-156 (Logic for data persistence and state management)
The Data Reset & Clearance system in the Solo Leveling Penalty System is a core mechanism designed to maintain the integrity of daily progression and enforce accountability. It operates by monitoring the temporal transition between days—specifically synchronized to Saudi Arabia (KSA) time—to determine when current task sets must be cleared and when "Penalty" logic should be applied to the user's total experience points (XP).
This system ensures that the application state, stored in the browser's local storage, remains synchronized with real-world dates. When a date change is detected, the system executes a "Clearance" of previous tasks and a "Reset" of the task pool based on the user's current rank and difficulty level.
Daily Cycle & State Transition
The system relies on a checkDailyCycle function to evaluate the state of systemData against the current date. This process determines whether a reset of daily tasks is required and if the user should be penalized for uncompleted objectives from the previous cycle.
Temporal Synchronization
The system specifically targets the Asia/Riyadh timezone to ensure a consistent reset point for all users. It uses the Intl.DateTimeFormat with the en-CA locale to generate a comparable date string (YYYY-MM-DD).
The diagram shows the logic flow for determining if a daily reset and data clearance is required upon application initialization.
Sources: Quest.html:141-143, index.html:141-143
Penalty Calculation & Data Clearance
When a new day is detected, the system does not simply wipe the data; it first performs a clearance audit. It iterates through the dailyTasks array from the previous session to identify any tasks where the completion flag d is false.
Penalty Logic
For every incomplete task, the system subtracts a penalty value determined by the user's rank configuration at the time of the reset.
| Data Field | Description | Impact during Clearance |
|---|---|---|
systemData.points | Total XP accumulated | Reduced by config.pen per missed task |
systemData.lastPenalty | The sum of points lost in the last reset | Updated to show impact to user |
systemData.dailyTasks | Array of task objects | Entirely replaced with new generation |
systemData.lastUpdate | ISO-style date string | Updated to current date to prevent re-triggering |
Sources: Quest.html:145-156, index.html:145-156
Reset Thresholds
If the clearance of points results in a negative value, the system enforces a floor of 0 to prevent corrupted state values.
systemData.points -= totalPenalty;
if(systemData.points < 0) systemData.points = 0;
systemData.lastPenalty = totalPenalty;
Sources: Quest.html:154-156, index.html:154-156
Task Pool Regeneration
Immediately following the clearance of old data, the system invokes generateTasks() to populate the dailyTasks array for the new cycle. This is not a simple reset but a rank-aware regeneration.
Generation Parameters
The "Clearance" of the old list makes room for five new tasks selected via a randomized shuffle from the taskDatabase. The difficulty of the new tasks is selected based on the user's current XP bracket (Rank F through R).
| Task Category | Selection Count | Source Property |
|---|---|---|
| Physical | 2 Tasks | taskDatabase.physical |
| Discipline | 2 Tasks | taskDatabase.discipline |
| Mental | 1 Task | taskDatabase.mental |
Sources: Quest.html:132-139, index.html:132-139
The sequence diagram illustrates the transition from clearing old daily data to persisting the new daily state.
Sources: Quest.html:141-164, index.html:141-164
Data Persistence Strategy
The system uses localStorage as the primary persistence layer. The save() function is the final step in any reset or clearance operation, ensuring that the state is not lost if the browser is closed immediately after a reset.
- Storage Key:
solo_penalty_v1 - Data Format: JSON stringified object
- Clearance Trigger: Triggered automatically on the first load of a new calendar day (KSA time).
Sources: Quest.html:127-129, index.html:127-129, Quest.html:183