// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// Game represents TL type `game#bdf9653b`.
// Indicates an already sent game
//
// See https://core.telegram.org/constructor/game for reference.
type Game struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// ID of the game
	ID int64
	// Access hash of the game
	AccessHash int64
	// Short name for the game
	ShortName string
	// Title of the game
	Title string
	// Game description
	Description string
	// Game preview
	Photo PhotoClass
	// Optional attached document
	//
	// Use SetDocument and GetDocument helpers.
	Document DocumentClass
}

// GameTypeID is TL type id of Game.
const GameTypeID = 0xbdf9653b

// Ensuring interfaces in compile-time for Game.
var (
	_ bin.Encoder     = &Game{}
	_ bin.Decoder     = &Game{}
	_ bin.BareEncoder = &Game{}
	_ bin.BareDecoder = &Game{}
)

func ( *Game) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.ShortName == "") {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.Document == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *Game) () string {
	if  == nil {
		return "Game(nil)"
	}
	type  Game
	return fmt.Sprintf("Game%+v", (*))
}

// FillFrom fills Game from given interface.
func ( *Game) ( interface {
	() ( int64)
	() ( int64)
	() ( string)
	() ( string)
	() ( string)
	() ( PhotoClass)
	() ( DocumentClass,  bool)
}) {
	.ID = .()
	.AccessHash = .()
	.ShortName = .()
	.Title = .()
	.Description = .()
	.Photo = .()
	if ,  := .();  {
		.Document = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*Game) () uint32 {
	return GameTypeID
}

// TypeName returns name of type in TL schema.
func (*Game) () string {
	return "game"
}

// TypeInfo returns info about TL type.
func ( *Game) () tdp.Type {
	 := tdp.Type{
		Name: "game",
		ID:   GameTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "ShortName",
			SchemaName: "short_name",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Description",
			SchemaName: "description",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
		{
			Name:       "Document",
			SchemaName: "document",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Game) () {
	if !(.Document == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *Game) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode game#bdf9653b as nil")
	}
	.PutID(GameTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Game) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode game#bdf9653b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode game#bdf9653b: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutString(.ShortName)
	.PutString(.Title)
	.PutString(.Description)
	if .Photo == nil {
		return fmt.Errorf("unable to encode game#bdf9653b: field photo is nil")
	}
	if  := .Photo.Encode();  != nil {
		return fmt.Errorf("unable to encode game#bdf9653b: field photo: %w", )
	}
	if .Flags.Has(0) {
		if .Document == nil {
			return fmt.Errorf("unable to encode game#bdf9653b: field document is nil")
		}
		if  := .Document.Encode();  != nil {
			return fmt.Errorf("unable to encode game#bdf9653b: field document: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *Game) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode game#bdf9653b to nil")
	}
	if  := .ConsumeID(GameTypeID);  != nil {
		return fmt.Errorf("unable to decode game#bdf9653b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *Game) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode game#bdf9653b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field short_name: %w", )
		}
		.ShortName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field description: %w", )
		}
		.Description = 
	}
	{
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field photo: %w", )
		}
		.Photo = 
	}
	if .Flags.Has(0) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode game#bdf9653b: field document: %w", )
		}
		.Document = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *Game) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *Game) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetShortName returns value of ShortName field.
func ( *Game) () ( string) {
	if  == nil {
		return
	}
	return .ShortName
}

// GetTitle returns value of Title field.
func ( *Game) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetDescription returns value of Description field.
func ( *Game) () ( string) {
	if  == nil {
		return
	}
	return .Description
}

// GetPhoto returns value of Photo field.
func ( *Game) () ( PhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

// SetDocument sets value of Document conditional field.
func ( *Game) ( DocumentClass) {
	.Flags.Set(0)
	.Document = 
}

// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func ( *Game) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Document, true
}

// GetPhotoAsNotEmpty returns mapped value of Photo field.
func ( *Game) () (*Photo, bool) {
	return .Photo.AsNotEmpty()
}

// GetDocumentAsNotEmpty returns mapped value of Document conditional field and
// boolean which is true if field was set.
func ( *Game) () (*Document, bool) {
	if ,  := .GetDocument();  {
		return .AsNotEmpty()
	}
	return nil, false
}