Skip to content

[Feature]: Refactor achievement system for better scalabilityΒ #374

@Sowmya-kc

Description

@Sowmya-kc

πŸ‘‰ Please confirm the following

πŸ€” Is your proposal related to a problem?

Problem

The current achievement system, while functional, has scalability concerns:

  1. registerAchievements() method grows linearly : Adding 20 achievements means 20+ lines in one method
  2. Multiple notify methods : Each event type requires a new notify method in AchievementManager
  3. Tight coupling: Adding a new achievement type requires modifying multiple files

😍 Describe the solution you'd like

Proposed Solutions

Option 1: Configuration-based Registration:

  • Store achievement definitions in JSON/XML
  • Load and instantiate achievements dynamically
  • Example:

{
"achievements": [
{"type": "KillCount", "target": 10, "reward": 50},
{"type": "Score", "target": 5000, "reward": 75}
]
}

Option 2: Event Bus Pattern

  • Replace individual notify methods with a generic event system
  • Achievements subscribe to specific event types
  • Eliminates need for new notify methods per event type

Option 3: Observer Pattern

  • Achievements observe game state changes directly
  • More decoupled from AchievementManager
  • Each achievement defines what it observes

Benefits

  • Adding new achievements becomes configuration, not code
  • Reduced code duplication
  • Easier to maintain and test
  • More scalable for future growth

πŸ‘οΈ Describe alternatives you've considered

No response

✍ Additional context

Metadata

Metadata

Assignees

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions