mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 05:43:41 +03:00
Add admin API for content reload
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"lunar-tear/server/internal/gametime"
|
||||
"lunar-tear/server/internal/model"
|
||||
"lunar-tear/server/internal/questflow"
|
||||
"lunar-tear/server/internal/runtime"
|
||||
"lunar-tear/server/internal/store"
|
||||
)
|
||||
|
||||
@@ -15,17 +16,18 @@ type TutorialServiceServer struct {
|
||||
pb.UnimplementedTutorialServiceServer
|
||||
users store.UserRepository
|
||||
sessions store.SessionRepository
|
||||
engine *questflow.QuestHandler
|
||||
holder *runtime.Holder
|
||||
}
|
||||
|
||||
func NewTutorialServiceServer(users store.UserRepository, sessions store.SessionRepository, engine *questflow.QuestHandler) *TutorialServiceServer {
|
||||
return &TutorialServiceServer{users: users, sessions: sessions, engine: engine}
|
||||
func NewTutorialServiceServer(users store.UserRepository, sessions store.SessionRepository, holder *runtime.Holder) *TutorialServiceServer {
|
||||
return &TutorialServiceServer{users: users, sessions: sessions, holder: holder}
|
||||
}
|
||||
|
||||
func (s *TutorialServiceServer) SetTutorialProgress(ctx context.Context, req *pb.SetTutorialProgressRequest) (*pb.SetTutorialProgressResponse, error) {
|
||||
log.Printf("[TutorialService] SetTutorialProgress: type=%d phase=%d choice=%d", req.TutorialType, req.ProgressPhase, req.ChoiceId)
|
||||
userId := CurrentUserId(ctx, s.users, s.sessions)
|
||||
nowMillis := gametime.NowMillis()
|
||||
engine := s.holder.Get().QuestHandler
|
||||
var grants []questflow.RewardGrant
|
||||
s.users.UpdateUser(userId, func(user *store.UserState) {
|
||||
existing, exists := user.Tutorials[req.TutorialType]
|
||||
@@ -36,7 +38,7 @@ func (s *TutorialServiceServer) SetTutorialProgress(ctx context.Context, req *pb
|
||||
ChoiceId: req.ChoiceId,
|
||||
}
|
||||
}
|
||||
grants = s.engine.ApplyTutorialReward(user, model.TutorialType(req.TutorialType), req.ChoiceId, nowMillis)
|
||||
grants = engine.ApplyTutorialReward(user, model.TutorialType(req.TutorialType), req.ChoiceId, nowMillis)
|
||||
if req.TutorialType == int32(model.TutorialTypeMenuFirst) && req.ProgressPhase == 20 {
|
||||
store.EnsureDefaultDeck(user, nowMillis)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user