Reward Distribution
Relevant source files
The following files were used as context for generating this wiki page:
Reward Distribution in the Solo-System is a dynamic logic engine that calculates and applies experience points (XP), ranks, and levels based on user task completion. The system operates on a feedback loop where successful task fulfillment grants "rewards" (positive points), while failure to complete daily tasks results in "penalties" (negative points).
The system uses a tiered configuration to determine the magnitude of rewards and penalties, ensuring that as a user progresses to higher ranks, the stakes and requirements for advancement increase proportionally. This creates a gamified progression environment where the user's status is reflected through a real-time UI.
Sources: Quest.html:105-115, index.html:105-115
Core Logic and State Management
The reward system relies on a central state object named systemData stored in the browser's localStorage. This object tracks the user's current points, the last update timestamp, the list of daily tasks, and the most recent penalty applied.
Data Structure
The state is managed using the following JSON structure:
let systemData = {
points: 0,
lastUpdate: '',
dailyTasks: [],
lastPenalty: 0
};
Sources: Quest.html:101-103, index.html:101-103
Progression Calculation
The function calculateLevel(pts) handles the conversion of total points into a specific level. Unlike linear progression, the system uses a variable requirement (displayReq) that adjusts based on the user's current rank once they surpass Level 5.
Sources: Quest.html:117-126, index.html:117-126
Rank Configuration Table
The distribution of rewards and the severity of penalties are governed by the getRankConfig(pts) function. This function returns a configuration object defining the current rank, the reward per task, the penalty per failed task, and the points required for the next level.
| Rank | Point Threshold | Reward (XP) | Penalty (XP) | Level Req (XP) | Difficulty Key |
|---|---|---|---|---|---|
| R | 3000+ | 6 | 8 | 50 | r |
| SS | 2000 - 2999 | 6 | 8 | 40 | r |
| S | 1200 - 1999 | 4 | 6 | 30 | a |
| A | 800 - 1199 | 4 | 6 | 25 | a |
| B | 500 - 799 | 4 | 6 | 20 | d |
| C | 300 - 499 | 3 | 5 | 15 | d |
| D | 150 - 299 | 3 | 5 | 12 | d |
| E | 70 - 149 | 2 | 3 | 10 | f |
| F | 0 - 69 | 2 | 3 | 10 | f |
Sources: Quest.html:105-115, index.html:105-115
Reward and Penalty Flow
The distribution logic is triggered by two main events: user interaction with tasks and the passage of the daily cycle.
Task Completion (Reward)
When a user toggles a task in the UI, the toggleTask(i) function calculates the point adjustment. If a task is marked as completed, the reward value from the current rank config is added to systemData.points. If unchecked, the points are deducted.
Sources: Quest.html:166-173, index.html:166-173
Daily Cycle (Penalty)
The system performs a "check" using the checkDailyCycle() function. If the current date (Asia/Riyadh timezone) differs from systemData.lastUpdate, the system iterates through all tasks from the previous day. For every task where task.d (done) is false, it applies the rank's pen (penalty) value to the total points.
The diagram above illustrates how the system automatically processes penalties and resets for a new day.
Sources: Quest.html:145-164, index.html:145-164
Visual Feedback and UI Updates
The updateUI() function acts as the renderer for the distribution system, ensuring the user sees the immediate impact of their rewards or penalties.
- Level & Progress: Displays the calculated level and a progress bar representing the percentage towards the next level requirement.
- Rank Display: Updates the Rank letter and applies specific colors and shadows (e.g.,
#ff4d4dfor Rank R). - Status Message: Informs the user of the current potential reward/penalty or details a penalty applied during the date rollover.
Sources: Quest.html:128-143, index.html:128-143
Sequence of Reward Application
This sequence shows the interaction between the User Interface and the logic functions when a task is completed.
Summary of Distribution Rules
- Minimum Points: The total points can never drop below 0.
- Difficulty Scaling: Tasks generated (
generateTasks) use thediffkey from the rank configuration to select harder task descriptions (f, d, a, r) from thetaskDatabase. - Timezone Consistency: All time-based rewards and penalties are synchronized to the
Asia/Riyadhtimezone to ensure consistent daily resets.
Sources: Quest.html:139-141, index.html:145-147, Quest.html:187-189