Fix: GrantExperience에서 프로필 미존재 시 자동 생성 fallback 추가
FindByUserID → GetProfile(auto-create 포함)로 변경하여 프로필 없는 유저의 경험치 지급 실패 방지. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -167,9 +167,9 @@ func (s *Service) SaveGameDataByUsername(username string, data *GameDataRequest)
|
|||||||
|
|
||||||
// GrantExperience adds experience to a player and handles level ups + stat recalculation.
|
// GrantExperience adds experience to a player and handles level ups + stat recalculation.
|
||||||
func (s *Service) GrantExperience(userID uint, exp int) (*LevelUpResult, error) {
|
func (s *Service) GrantExperience(userID uint, exp int) (*LevelUpResult, error) {
|
||||||
profile, err := s.repo.FindByUserID(userID)
|
profile, err := s.GetProfile(userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("프로필이 존재하지 않습니다")
|
return nil, fmt.Errorf("프로필 조회/생성 실패: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := ApplyExperience(profile.Level, profile.Experience, exp)
|
result := ApplyExperience(profile.Level, profile.Experience, exp)
|
||||||
|
|||||||
Reference in New Issue
Block a user