package app

import (
	"evening_detective_server/internal/services/game_service"
	"evening_detective_server/proto"

	"google.golang.org/protobuf/types/known/timestamppb"
)

func mapGame(
	o *game_service.Game,
) *proto.Game {
	return &proto.Game{
		Id:          int32(o.ID),
		Name:        o.Name,
		Description: o.Description,
		StartAt:     timestamppb.New(o.StartAt),
		Status:      o.Status,
		Scenario:    mapScenario(o.Scenario),
		Teams:       mapTeams(o.Teams),
	}
}

func mapGames(
	o []*game_service.Game,
) []*proto.Game {
	res := make([]*proto.Game, 0, len(o))
	for _, item := range o {
		res = append(res, mapGame(item))
	}
	return res
}
