mirror of Walter-Sparrow / lunar-tear
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor tutorial progress update logic to prevent overwriting existing progress unless the new phase is greater.

+13 -7
+13 -7
server/internal/service/tutorial.go
··· 29 29 nowMillis := gametime.NowMillis() 30 30 var grants []questflow.RewardGrant 31 31 user, _ := s.users.UpdateUser(userId, func(user *store.UserState) { 32 - user.Tutorials[req.TutorialType] = store.TutorialProgressState{ 33 - TutorialType: req.TutorialType, 34 - ProgressPhase: req.ProgressPhase, 35 - ChoiceId: req.ChoiceId, 32 + existing, exists := user.Tutorials[req.TutorialType] 33 + if !exists || req.ProgressPhase >= existing.ProgressPhase { 34 + user.Tutorials[req.TutorialType] = store.TutorialProgressState{ 35 + TutorialType: req.TutorialType, 36 + ProgressPhase: req.ProgressPhase, 37 + ChoiceId: req.ChoiceId, 38 + } 36 39 } 37 40 if req.TutorialType == int32(model.TutorialTypeMenuFirst) || 38 41 req.TutorialType == int32(model.TutorialTypeMenuSecond) { ··· 74 77 log.Printf("[TutorialService] SetTutorialProgressAndReplaceDeck: type=%d phase=%d deckType=%d deckNumber=%d", req.TutorialType, req.ProgressPhase, req.DeckType, req.UserDeckNumber) 75 78 userId := currentUserId(ctx, s.users, s.sessions) 76 79 user, _ := s.users.UpdateUser(userId, func(user *store.UserState) { 77 - user.Tutorials[req.TutorialType] = store.TutorialProgressState{ 78 - TutorialType: req.TutorialType, 79 - ProgressPhase: req.ProgressPhase, 80 + existing, exists := user.Tutorials[req.TutorialType] 81 + if !exists || req.ProgressPhase >= existing.ProgressPhase { 82 + user.Tutorials[req.TutorialType] = store.TutorialProgressState{ 83 + TutorialType: req.TutorialType, 84 + ProgressPhase: req.ProgressPhase, 85 + } 80 86 } 81 87 if req.Deck != nil { 82 88 store.ApplyDeckReplacement(user, model.DeckType(req.DeckType), req.UserDeckNumber, deckSlotsFromProto(req.Deck), gametime.NowMillis())