details

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamSwat     = 0
	TeamSuspects = 1
	TeamSwatRed  = 2 // CO-OP Team Red
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Details

type Details struct {
	Info       Info        `param:"-" validate:"required"`
	Players    []Player    `param:"-" validate:"dive"`
	Objectives []Objective `param:"-" validate:"dive"`
}
var Blank Details

func MustNewDetailsFromParams

func MustNewDetailsFromParams(
	info map[string]string,
	players []map[string]string,
	objectives []map[string]string,
) Details

func NewDetailsFromParams

func NewDetailsFromParams(
	pms map[string]string,
	players []map[string]string,
	objectives []map[string]string,
) (Details, error)

func (Details) Validate

func (d Details) Validate(v *validator.Validate) error

type Info

type Info struct {
	Hostname       string `validate:"required"`
	HostPort       int    `validate:"required,gt=0"`
	GameVariant    string `validate:"required"`
	GameVersion    string `validate:"required" param:"gamever"` // nolint: tagalign
	GameType       string `validate:"required"`
	NumPlayers     int    `validate:"gte=0"`
	MaxPlayers     int    `validate:"gte=0"`
	MapName        string `validate:"required"`
	Password       bool
	StatsEnabled   bool
	Round          int `validate:"gte=0"`
	NumRounds      int `validate:"gte=0"`
	TimeLeft       int // can be negative
	TimeSpecial    int `validate:"gte=0"`
	SwatScore      int
	SuspectsScore  int
	SwatWon        int    `validate:"gte=0"`
	SuspectsWon    int    `validate:"gte=0"`
	BombsDefused   int    `validate:"gte=0"`
	BombsTotal     int    `validate:"gte=0"`
	TocReports     string `validate:"ratio"`
	WeaponsSecured string `validate:"ratio"`

	Version string `param:"-" validate:"-"`
}

func MustNewInfoFromParams

func MustNewInfoFromParams(pms map[string]string) Info

func NewInfoFromParams

func NewInfoFromParams(pms map[string]string) (Info, error)

func (Info) Validate

func (i Info) Validate(v *validator.Validate) error

type Objective

type Objective struct {
	Name   string          `validate:"required"`
	Status ObjectiveStatus `validate:"oneof=0 1 2"`
}

type ObjectiveStatus

type ObjectiveStatus int
const (
	ObjInProgress ObjectiveStatus = iota
	ObjCompleted
	ObjFailed
)

func (ObjectiveStatus) String

func (os ObjectiveStatus) String() string

type Player

type Player struct {
	Name            string           `param:"player"             validate:"required"`
	Score           int              `param:"score"`
	Ping            int              `param:"ping"`
	Team            PlayerTeam       `validate:"oneof=0 1 2"`
	VIP             bool             `param:"vip"`
	CoopStatus      PlayerCoopStatus `validate:"oneof=0 1 2 3 4"`
	Kills           int              `validate:"gte=0"`
	TeamKills       int              `param:"tkills"             validate:"gte=0"`
	Deaths          int              `validate:"gte=0"`
	Arrests         int              `validate:"gte=0"`
	Arrested        int              `validate:"gte=0"`
	VIPEscapes      int              `param:"vescaped"           validate:"gte=0"`
	VIPArrests      int              `param:"arrestedvip"        validate:"gte=0"`
	VIPRescues      int              `param:"unarrestedvip"      validate:"gte=0"`
	VIPKillsValid   int              `param:"validvipkills"      validate:"gte=0"`
	VIPKillsInvalid int              `param:"invalidvipkills"    validate:"gte=0"`
	BombsDefused    int              `param:"bombsdiffused"      validate:"gte=0"`
	BombsDetonated  bool             `param:"rdcrybaby"`
	CaseEscapes     int              `param:"escapedcase"        validate:"gte=0"`
	CaseKills       int              `param:"killedcase"         validate:"gte=0"`
	CaseSecured     bool             `param:"sgcrybaby"`
}

type PlayerCoopStatus

type PlayerCoopStatus int
const (
	CoopStatusUnknown PlayerCoopStatus = iota
	CoopStatusReady
	CoopStatusHealthy
	CoopStatusInjured
	CoopStatusIncapacitated
)

func (PlayerCoopStatus) String

func (cs PlayerCoopStatus) String() string

type PlayerTeam

type PlayerTeam int

func (PlayerTeam) String

func (pt PlayerTeam) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL