package models

import (
	"time"

	"github.com/google/uuid"
)

type GameServer struct {
	ID            uuid.UUID  `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
	MatchID       *uuid.UUID `gorm:"type:uuid" json:"match_id,omitempty"`
	ContainerID   string     `gorm:"type:varchar(64);not null" json:"container_id"`
	ContainerName string     `gorm:"type:varchar(128);not null" json:"container_name"`
	Host          string     `gorm:"type:varchar(255);not null" json:"host"`
	Port          int        `gorm:"not null" json:"port"`
	RCONPassword  string     `gorm:"type:varchar(64);not null" json:"-"`
	GSLTToken     string     `gorm:"type:varchar(64);not null" json:"-"`
	Status        string     `gorm:"type:varchar(32);not null" json:"status"`
	CreatedAt     time.Time  `gorm:"not null" json:"created_at"`
	StoppedAt     *time.Time `json:"stopped_at,omitempty"`
}

const (
	ServerStatusStarting = "starting"
	ServerStatusReady    = "ready"
	ServerStatusLive     = "live"
	ServerStatusStopping = "stopping"
	ServerStatusStopped  = "stopped"
)

type PortPool struct {
	Port      int        `gorm:"primaryKey" json:"port"`
	Allocated bool       `gorm:"default:false" json:"allocated"`
	ServerID  *uuid.UUID `gorm:"type:uuid" json:"server_id,omitempty"`
}
