Documentation ¶
Index ¶
- Variables
- func CreateDemoType(repository *DemoRepository) *graphql.Object
- type Bomb
- type BombPlanted
- type Demo
- type DemoRepository
- type Equipment
- type FireExpiredEvent
- type FireStartedEvent
- type FlashExplosionEvent
- type GameEvent
- func FireExpired(tick int, e events.FireGrenadeExpired) GameEvent
- func FireStarted(tick int, e events.FireGrenadeStart) GameEvent
- func NewFlashExplosion(tick int, e events.FlashExplode) GameEvent
- func NewHeExplosion(tick int, e events.HeExplode) GameEvent
- func NewMatchStartedEvent(t int, e events.MatchStart) GameEvent
- func RoundEnded(tick int, e events.RoundEnd) GameEvent
- func RoundStarted(tick int, e events.RoundStart) GameEvent
- func SmokeExpired(tick int, e events.SmokeExpired) GameEvent
- func SmokeStarted(tick int, e events.SmokeStart) GameEvent
- type Grenade
- type HEExplosionEvent
- type Header
- type Inferno
- type MatchStartedEvent
- type Player
- type Position
- type RoundEndEvent
- type RoundStartedEvent
- type Smoke
- type SmokeExpiredEvent
- type SmokeStartedEvent
- type Tick
- type WeaponFired
Constants ¶
This section is empty.
Variables ¶
var BombPlantedType = graphql.NewObject(graphql.ObjectConfig{ Name: "BombPlanted", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "BOMB_PLANTED", nil }, }, "player": &graphql.Field{ Name: "player", Type: PlayerType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(BombPlanted).Player, nil }, }, "bombsite": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(BombPlanted).Bombsite, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "BOMB_PLANTED" }, })
BombPlantedType represents the BombPlantedEvent as GraphQL Type.
var BombType = graphql.NewObject(graphql.ObjectConfig{ Name: "bomb", Fields: graphql.Fields{ "lastOnGroundPosition": &graphql.Field{ Type: PositionType, }, "carrier": &graphql.Field{ Type: PlayerType, }, }, })
BombType is the graphql implementation for the bomb.
var EquipmentType = graphql.NewObject(graphql.ObjectConfig{ Name: "equipment", Fields: graphql.Fields{ "type": &graphql.Field{ Type: graphql.Int, }, "ammoInMagazine": &graphql.Field{ Type: graphql.Int, }, "ammoReserve": &graphql.Field{ Type: graphql.Int, }, }, })
EquipmentType represents the Equipment GraphQL Type.
var FireExpiredType = graphql.NewObject(graphql.ObjectConfig{ Name: "FireExpired", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "FIRE_EXPIRED", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FireExpiredEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FireExpiredEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "FIRE_EXPIRED" }, })
FireExpiredType is the GraphQL type of the FireStartedEvent
var FireStartedType = graphql.NewObject(graphql.ObjectConfig{ Name: "FireStarted", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "FIRE_STARTED", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FireStartedEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FireStartedEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "FIRE_STARTED" }, })
FireStartedType is the GraphQL type of the FireStartedEvent
var FlashExplosionType = graphql.NewObject(graphql.ObjectConfig{ Name: "FlashExploded", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "FLASH_EXPLOSION", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FlashExplosionEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(FlashExplosionEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "FLASH_EXPLOSION" }, })
var GameEventType = graphql.NewUnion(graphql.UnionConfig{ Name: "AnyGameEvent", Types: []*graphql.Object{ BombPlantedType, WeaponFiredType, SmokeStartedType, SmokeExpiredType, FireStartedType, FireExpiredType, RoundStartedType, RoundEndedType, MatchStartedEventTpe, FlashExplosionType, HEExplosionType, }, })
var GrenadeProjectileType = graphql.NewObject(graphql.ObjectConfig{ Name: "Grenade", Fields: graphql.Fields{ "tick": &graphql.Field{ Type: graphql.Int, }, "thrower": &graphql.Field{ Type: PlayerType, }, "owner": &graphql.Field{ Type: PlayerType, }, "position": &graphql.Field{ Type: PositionType, }, "trajectory": &graphql.Field{ Type: graphql.NewList(PositionType), }, "weapon": &graphql.Field{ Type: EquipmentType, }, }, })
var HEExplosionType = graphql.NewObject(graphql.ObjectConfig{ Name: "HEExploded", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "HE_EXPLOSION", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(HEExplosionEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(HEExplosionEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "HE_EXPLOSION" }, })
HEExplosionType represents the GraphQL Type of a HEGrenade.
var HeaderType = graphql.NewObject(graphql.ObjectConfig{ Name: "Header", Fields: graphql.Fields{ "mapName": &graphql.Field{ Type: graphql.String, }, "tickRate": &graphql.Field{ Type: graphql.Int, }, "fps": &graphql.Field{ Type: graphql.Int, }, }, })
var InfernoType = graphql.NewObject(graphql.ObjectConfig{ Name: "Inferno", Fields: graphql.Fields{ "hull": &graphql.Field{ Type: graphql.NewList(PositionType), }, }, })
InfernoType represents the GraphQL Type of an inferno.
var MatchStartedEventTpe = graphql.NewObject(graphql.ObjectConfig{ Name: "MatchStarted", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "MATCH_STARTED", nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(MatchStartedEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "MATCH_STARTED" }, })
var PlayerType = graphql.NewObject(graphql.ObjectConfig{ Name: "Player", Fields: graphql.Fields{ "name": &graphql.Field{ Type: graphql.String, }, "entityId": &graphql.Field{ Type: graphql.Int, }, "team": &graphql.Field{ Type: graphql.Int, }, "position": &graphql.Field{ Type: PositionType, }, "angleX": &graphql.Field{ Type: graphql.Float, }, "angleY": &graphql.Field{ Type: graphql.Float, }, "hp": &graphql.Field{ Type: graphql.Int, }, "armor": &graphql.Field{ Type: graphql.Int, }, "flashDuration": &graphql.Field{ Type: graphql.Float, }, "npc": &graphql.Field{ Type: graphql.Boolean, }, "hasHelmet": &graphql.Field{ Type: graphql.Boolean, }, "hasDefuseKit": &graphql.Field{ Type: graphql.Boolean, }, "equipment": &graphql.Field{ Type: graphql.NewList(EquipmentType), }, "planting": &graphql.Field{ Type: graphql.Boolean, }, "defusing": &graphql.Field{ Type: graphql.Boolean, }, "inBuyzone": &graphql.Field{ Type: graphql.Boolean, }, "firing": &graphql.Field{ Type: graphql.Boolean, }, "money": &graphql.Field{ Type: graphql.Int, }, "kills": &graphql.Field{ Type: graphql.Int, }, "deaths": &graphql.Field{ Type: graphql.Int, }, }, })
var PositionType = graphql.NewObject(graphql.ObjectConfig{ Name: "Position", Fields: graphql.Fields{ "x": &graphql.Field{ Type: graphql.Float, }, "y": &graphql.Field{ Type: graphql.Float, }, "z": &graphql.Field{ Type: graphql.Float, }, }, })
var RoundEndedType = graphql.NewObject(graphql.ObjectConfig{ Name: "RoundEnded", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "ROUND_ENDED", nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(RoundEndEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "ROUND_ENDED" }, })
var RoundStartedType = graphql.NewObject(graphql.ObjectConfig{ Name: "RoundStarted", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "ROUND_STARTED", nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(RoundStartedEvent).Tick, nil }, }, "timeLimit": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(RoundStartedEvent).TimeLimit, nil }, }, "objective": &graphql.Field{ Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(RoundStartedEvent).Objective, nil }, }, "fragLimit": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(RoundStartedEvent).FragLimit, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "ROUND_STARTED" }, })
var SmokeExpiredType = graphql.NewObject(graphql.ObjectConfig{ Name: "SmokeExpired", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "SMOKE_EXPIRED", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(SmokeExpiredEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(SmokeExpiredEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "SMOKE_EXPIRED" }, })
var SmokeStartedType = graphql.NewObject(graphql.ObjectConfig{ Name: "SmokeStarted", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "SMOKE_STARTED", nil }, }, "position": &graphql.Field{ Type: PositionType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(SmokeStartedEvent).Position, nil }, }, "tick": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) return x.RealEvent.(SmokeStartedEvent).Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "SMOKE_STARTED" }, })
var SmokeType = graphql.NewObject(graphql.ObjectConfig{ Name: "smoke", Fields: graphql.Fields{ "position": &graphql.Field{ Type: PositionType, }, "id": &graphql.Field{ Type: graphql.Int, }, }, })
SmokeType represents the GraphQL Type of a Smoke
var TickType = graphql.NewObject(graphql.ObjectConfig{ Name: "Tick", Fields: graphql.Fields{ "tick": &graphql.Field{ Type: graphql.Int, }, "players": &graphql.Field{ Type: graphql.NewList(PlayerType), }, "bomb": &graphql.Field{ Type: BombType, }, "grenades": &graphql.Field{ Type: graphql.NewList(GrenadeProjectileType), }, "infernos": &graphql.Field{ Type: graphql.NewList(InfernoType), }, "smokes": &graphql.Field{ Type: graphql.NewList(SmokeType), }, "totalRoundsPlayed": &graphql.Field{ Type: graphql.Int, }, }, })
var WeaponFiredType = graphql.NewObject(graphql.ObjectConfig{ Name: "WeaponFired", Fields: graphql.Fields{ "name": &graphql.Field{ Name: "name", Type: graphql.String, Resolve: func(p graphql.ResolveParams) (interface{}, error) { return "WEAPON_FIRED", nil }, }, "shooter": &graphql.Field{ Name: "shooter", Type: PlayerType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) event := x.RealEvent.(WeaponFired) return event.Shooter, nil }, }, "weapon": &graphql.Field{ Name: "weapon", Type: EquipmentType, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) event := x.RealEvent.(WeaponFired) return event.Weapon, nil }, }, "tick": &graphql.Field{ Name: "tick", Type: graphql.Int, Resolve: func(p graphql.ResolveParams) (interface{}, error) { x := p.Source.(GameEvent) event := x.RealEvent.(WeaponFired) return event.Tick, nil }, }, }, IsTypeOf: func(p graphql.IsTypeOfParams) bool { eventName := p.Value.(GameEvent).Name return eventName == "WEAPON_FIRED" }, })
Functions ¶
func CreateDemoType ¶
func CreateDemoType(repository *DemoRepository) *graphql.Object
CreateDemoType creats a GraphQL Schema representing the whole query.
Types ¶
type Bomb ¶
type Bomb struct { LastOnGroundPosition Position `json:"lastOnGroundPosition"` Carrier Player `json:"carrier"` }
Bomb is the structure representing the json of the bombstate in a tick.
type BombPlanted ¶
type BombPlanted struct { Name string `json:"name"` Player Player `json:"player"` Bombsite int32 `json:"bombsite"` }
BombPlanted represents the event, when the bomb was planted.
type Demo ¶
type Demo struct { Header Header `json:"header"` Ticks []Tick `json:"ticks"` Events []GameEvent `json:"events"` }
Demo represents the json of a whole demo.
type DemoRepository ¶
type DemoRepository struct {
CurrentDemo Demo
}
DemoRepository holds the state of the whole Operation. In this case a simple in memory database
type Equipment ¶
type Equipment struct { Type int `json:"type"` AmmoInMagazine int `json:"ammoInMagazine"` AmmoReserve int `json:"ammoReserve"` AmmoType int `json:"ammoType"` }
Equipment represents the Equipment of a player in the json format.
func FromEquipment ¶
FromEquipment maps a single "core" Equipment to the JSON Model.
func ToEntityEquipment ¶
ToEntityEquipment maps an array of "core" Equipment to the JSON Model.
type FireExpiredEvent ¶
type FireExpiredEvent struct { Position Position `json:"position"` Name string `json:"name"` Tick int `json:"tick"` }
FireExpiredEvent represents the JSON of the fire expired event.
type FireStartedEvent ¶
type FireStartedEvent struct { Position Position `json:"position"` Name string `json:"name"` Tick int `json:"tick"` }
FireStartedEvent represents the JSON of the fire started event.
type FlashExplosionEvent ¶
type GameEvent ¶
type GameEvent struct { Name string `json:"name"` RealEvent interface{} }
func FireExpired ¶
func FireExpired(tick int, e events.FireGrenadeExpired) GameEvent
FireExpired creates a GameEvent for FIRE_EXPIRED of the real Event.
func FireStarted ¶
func FireStarted(tick int, e events.FireGrenadeStart) GameEvent
FireStarted creates a GameEvent for FIRE_STARTED of the real Event.
func NewFlashExplosion ¶
func NewFlashExplosion(tick int, e events.FlashExplode) GameEvent
func NewHeExplosion ¶
NewHeExplision creates a new HEExplosion Event from the core event.
func NewMatchStartedEvent ¶
func NewMatchStartedEvent(t int, e events.MatchStart) GameEvent
func RoundStarted ¶
func RoundStarted(tick int, e events.RoundStart) GameEvent
func SmokeExpired ¶
func SmokeExpired(tick int, e events.SmokeExpired) GameEvent
func SmokeStarted ¶
func SmokeStarted(tick int, e events.SmokeStart) GameEvent
type Grenade ¶
type Grenade struct { Thrower Player `json:"thrower"` Owner Player `json:"owner"` Trajectory []Position `json:"trajectory"` WeaponInstance Equipment `json:"weapon"` Position Position `json:"position"` UniqueId int64 `json:"uniqueId"` }
func NewProjectile ¶
func NewProjectile(e common.GrenadeProjectile, firing map[int]bool) Grenade
type HEExplosionEvent ¶
type HEExplosionEvent struct { Position Position `json:"position"` Name string `json:"name"` Tick int `json:"tick"` }
HEExplosionEvent represents an event of a explodion HE-Grenade.
type Inferno ¶
type Inferno struct {
Hull []Position `json:"hull"`
}
Inferno represents a burning fire.
type MatchStartedEvent ¶
type Player ¶
type Player struct { Name string `json:"name"` EntityID int `json:"entityId"` Team int `json:"team,omitempty"` Position Position `json:"position,omitempty"` // This allows us smoother replay with less overhead compared to higher snapshot rate AngleX int `json:"angleX,omitempty"` AngleY int `json:"angleY,omitempty"` Hp int `json:"hp,omitempty"` Armor int `json:"armor,omitempty"` FlashDuration float32 `json:"flashDuration,omitempty"` Npc bool `json:"npc,omitempty"` HasHelmet bool `json:"hasHelmet,omitempty"` HasDefuseKit bool `json:"hasDefuseKit,omitempty"` Equipment []Equipment `json:"equipment,omitempty"` Planting bool `json:"planting,omitempty"` Defusing bool `json:"defusing,omitempty"` InBuyzone bool `json:"inBuyzone,omitempty"` Money int `json:"money,omitempty"` Kills int `json:"kills,omitempty"` Deaths int `json:"deaths,omitempty"` Firing bool `json:"isFiring, omitempty"` }
type Position ¶
func FromPoints ¶
FromPoints creats a position array from a point array.