refactor(achievement): extract achievement logic into AchievementService

Move EnsureExists + GetAllScores + compute loop from handler into
AchievementService.GetAll, and validation + ensure + increment into
AchievementService.Increment. Handlers now delegate to the service
layer for business logic while retaining protocol response building.

GetAchData stays as a pure function in handlers_achievement.go per plan.
This commit is contained in:
Houmgaor
2026-02-23 23:43:39 +01:00
parent bcdc4e0b7e
commit daacb76fb8
6 changed files with 262 additions and 33 deletions

View File

@@ -71,7 +71,8 @@ type Server struct {
miscRepo MiscRepo
scenarioRepo ScenarioRepo
mercenaryRepo MercenaryRepo
guildService *GuildService
guildService *GuildService
achievementService *AchievementService
erupeConfig *cfg.Config
acceptConns chan net.Conn
deleteConns chan net.Conn
@@ -155,6 +156,7 @@ func NewServer(config *Config) *Server {
s.mercenaryRepo = NewMercenaryRepository(config.DB)
s.guildService = NewGuildService(s.guildRepo, s.mailRepo, s.charRepo, s.logger)
s.achievementService = NewAchievementService(s.achievementRepo, s.logger)
// Mezeporta
s.stages.Store("sl1Ns200p0a0u0", NewStage("sl1Ns200p0a0u0"))