Road Section Penalty Keeper
Class-based tracker for rally liaison route deviation penalties. Monitors route recalculation frequency and applies escalating time penalties when the driver deviates from the prescribed road section
Class-based tracker for rally liaison route deviation penalties. Monitors route recalculation frequency and applies escalating time penalties when the driver deviates from the prescribed road section route too often.
Constructor
local RoadSectionPenaltyKeeper = require('gameplay/rally/loop/roadSectionPenaltyKeeper')
local keeper = RoadSectionPenaltyKeeper(manager)Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | (manager) | nil | Stores manager reference, initializes counters |
reset | () | nil | Resets recalc and violation counters to zero |
registerRecalc | () | nil | Increments recalculation counter |
createPenaltyData | () | table | Creates structured penalty data for current violation |
onUpdate | () | boolean | Periodic check: triggers penalty if threshold exceeded |
Internals
Configuration Constants
| Constant | Value | Description |
|---|---|---|
RECALC_TIME_WINDOW | 10 | Seconds between periodic checks |
RECALC_THRESHOLD | 5 | Max recalcs allowed per window before penalty |
MAX_VIOLATIONS | 1 | Maximum violations before penalties stop escalating |
PENALTIES | {30, 60, 120, 180} | Escalating penalty amounts in seconds |
Penalty Escalation
| Violation # | Penalty |
|---|---|
| 1st | 30 seconds |
| 2nd | 60 seconds |
| 3rd | 120 seconds |
| 4th+ | 180 seconds |
Penalty Data Structure
{
type = "liaison_deviation",
amount = number, -- escalating penalty amount
data = {
violationNumber = number,
recalcCount = number
}
}How It Works
- External code calls
registerRecalc()each time the route is recalculated (player went off-route) onUpdate()runs on a 10-second interval (usingmanager.clock)- If recalc count exceeds threshold (5) and violations are under max (1), calls
manager:recordRouteRecalcPenalty()with escalating penalty - After creating a penalty, resets recalc counter to begin a new monitoring window
Usage Example
local RoadSectionPenaltyKeeper = require('gameplay/rally/loop/roadSectionPenaltyKeeper')
local keeper = RoadSectionPenaltyKeeper(loopManager)
-- When route recalculates (player deviated)
keeper:registerRecalc()
-- Called each frame by the loop manager
keeper:onUpdate()
-- Reset when entering a new road section
keeper:reset()See Also
- Rally Loop Penalties - Related reference
- Rally Attempts - Related reference
- Rally Event Log - Related reference
- Gameplay Systems Guide - Guide
Rally Loop Manager
Core manager class for rally loop gameplay. Orchestrates the entire rally event: mission sequencing, schedule calculation, wall clock / epoch time management, time control penalties, timecard recordin
Rally Schedule Utilities
Pure utility functions for rally loop scheduling and time calculations. Provides minute-boundary rounding, slot size conversion, and time comparison helpers.