// newGameStartCall gathers data for a new game start call of the worker
newGameStartCall gathers data for a new game start call of the worker
// newGameStartCall gathers data for a new game start call of the worker
func newGameStartCall(roomId string, data string, library games.GameLibrary) (api.GameStartCall, error) {
	request := api.GameStartRequest{}
	if err := request.From(data); err != nil {
		return api.GameStartCall{}, errors.New("invalid request")
	}
	game := request.GameName
	if roomId != "" {
		name := session.GetGameNameFromRoomID(roomId)
		if name == "" {
			return api.GameStartCall{}, errors.New("couldn't decode game name from the room id")
		}
		game = name
	}
	gameInfo := library.FindGameByName(game)
	if gameInfo.Path == "" {
		return api.GameStartCall{}, fmt.Errorf("couldn't find game info for the game %v", game)
	}
	return api.GameStartCall{
		Name: gameInfo.Name,
		Base: gameInfo.Base,
		Path: gameInfo.Path,
		Type: gameInfo.Type,
	}, nil
}
func newGameStartCall ( roomId string , data string , library games . GameLibrary ) ( api . GameStartCall , error ) { request := api . GameStartRequest { } if err := request . From ( data ) ; err != nil { return api . GameStartCall { } , errors . New ( " " ) } game := request . GameName if roomId != " " { name := session . GetGameNameFromRoomID ( roomId ) if name == " " { return api . GameStartCall { } , errors . New ( " " ) } game = name } gameInfo := library . FindGameByName ( game ) if gameInfo . Path == " " { return api . GameStartCall { } , fmt . Errorf ( " " , game ) } return api . GameStartCall { Name : gameInfo . Name , Base : gameInfo . Base , Path : gameInfo . Path , Type : gameInfo . Type , } , nil }
newGameStartCall gathers data for a new game start call of the worker
newGameStartCall gathers data for a new game start call of the worker
// the name of the game either in the `room id` field or // it's in the initial request // ! should be moved into coordinator