diff --git a/bin/evening_detective_server b/bin/evening_detective_server index 8d9bbb5..3a44953 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/internal/app/server.go b/internal/app/server.go index 355127b..b221783 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -623,7 +623,7 @@ func (s *server) GiveTeamApplications(ctx context.Context, req *proto.GiveTeamAp } func (s *server) GetTeamStory(ctx context.Context, req *proto.GetTeamStoryReq) (*proto.GetTeamStoryRsp, error) { - story, err := s.gameService.GetTeamActions( + story, game, err := s.gameService.GetTeamActions( ctx, int(req.Id), req.Password, @@ -634,13 +634,6 @@ func (s *server) GetTeamStory(ctx context.Context, req *proto.GetTeamStoryReq) ( }, nil } - game, err := s.gameService.GetGame(ctx, int(req.Id)) - if err != nil { - return &proto.GetTeamStoryRsp{ - Error: err.Error(), - }, nil - } - return &proto.GetTeamStoryRsp{ Story: mapStory(story), Game: mapGame(game), diff --git a/internal/services/game_service/service.go b/internal/services/game_service/service.go index 1b931fc..2449901 100644 --- a/internal/services/game_service/service.go +++ b/internal/services/game_service/service.go @@ -180,32 +180,32 @@ func (s *GameService) GiveTeamApplications(ctx context.Context, teamId int, name return s.applicationsRepo.UpdateApplicationStatus(ctx, teamId, name, "done") } -func (s *GameService) GetTeamActions(ctx context.Context, teamId int, password string) (*storytelling.Story, error) { +func (s *GameService) GetTeamActions(ctx context.Context, teamId int, password string) (*storytelling.Story, *Game, error) { team, err := s.teamsRepo.GetTeamByID(ctx, teamId) if err != nil { - return nil, err + return nil, nil, err } if team.Password != password { - return nil, teams_repo.ErrTeamNotFound + return nil, nil, teams_repo.ErrTeamNotFound } game, err := s.gamesRepo.GetGameByID(ctx, team.GameId) if err != nil { - return nil, err + return nil, nil, err } actions, err := s.actionsRepo.GetActionsByTeamID(ctx, teamId) if err != nil { - return nil, err + return nil, nil, err } scenario, err := s.scenarioService.GetFullScenarioByID(ctx, game.ScenarioId) if err != nil { - return nil, err + return nil, nil, err } - return s.storyteller.GetStory(scenario.Story, actions), nil + return s.storyteller.GetStory(scenario.Story, actions), mapGame(game, s.domain), nil } func (s *GameService) AddTeamAction(ctx context.Context, teamId int, password string, actionCode string) error {