stats-module

Track and persist player statistics with caps and batched saves in Unity.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/punkfuncgames/tetris-clone --skill stats-module
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stats-module
Source: https://github.com/punkfuncgames/tetris-clone/tree/main/.claude/skills/stats-module
Command: npx skills add https://github.com/punkfuncgames/tetris-clone --skill stats-module

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing player and game metrics across sessions can be error-prone and inconsistent when you need caps, source tracking, event notifications, and persistent storage. This Skill describes a unified StatsModule that centralizes registration, clamping, consumption checks, batched persistence, and change broadcasting so gameplay systems can read and modify stats safely and predictably.

Core Features & Use Cases

  • Centralized registration and lookup of stat definitions with initial values and definition-level caps.
  • Deterministic operations: set, add, consume (with failure event), and convenience queries such as HasEnough and IsAtCap.
  • Cap management with automatic clamping, reset semantics (to initial values or zero), and bulk reset operations.
  • Event publishing for StatChanged, StatReset, StatConsumeFailed, and StatCapChanged to drive UI and achievement systems.
  • Batched tick-based persistence for performance with immediate saves on cap and reset changes, plus test helpers and a mock factory for unit tests.
  • Typical usage: bootstrap registration of StatsDefinition assets, runtime updates from gameplay systems, and subscription from UI/analytics for reactive updates.

Quick Start

Register your StatsDefinition assets during bootstrap and use the IStatsService RegisterStat, Add, Set, Consume, and SetCap methods to track, cap, and persist player metrics.

Frequently Asked Questions about stats-module

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I track player stats in Unity with caps and event publishing?

You can track player stats in Unity with caps and event publishing by registering stat definitions during bootstrap and using a centralized service to apply automatic clamping, broadcast change events, and drive reactive UI or achievement systems.

How does batched persistence work for saving Unity game metrics?

Batched persistence for saving Unity game metrics operates on a tick-based system that batches stat updates for performance, while triggering immediate saves automatically whenever cap changes or reset operations occur to ensure data integrity.

Can I use BigDouble numeric support for large resource tracking in Unity?

Yes, BigDouble numeric support is included for large resource tracking in Unity, allowing you to manage incremental idle-game metrics or massive resource values that exceed standard floating-point limits without losing precision.

What is source attribution in a player stats system?

Source attribution in a player stats system tracks the origin of stat modifications, allowing gameplay systems to identify which specific action or system triggered an add, consume, or set operation for accurate analytics and debugging.

How do I handle stat consumption failures in Unity gameplay systems?

To handle stat consumption failures in Unity gameplay systems, the stats module checks if sufficient resources exist before deducting and automatically publishes a dedicated failure event if the consumption attempt is invalid or insufficient.

Does this Unity stats module support dependency injection for service registration?

Yes, this Unity stats module supports dependency-injected service registration, allowing you to bootstrap the stat tracking interface cleanly within your existing architecture and mock the service for unit testing.