engine

package
v0.0.0-...-e6555c8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller implementation

func (Controller) FetchChallanges

func (c Controller) FetchChallanges(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (Controller) GetRouter

func (c Controller) GetRouter() *httprouter.Router

Creates a new router

func (Controller) InstallChallenge

func (c Controller) InstallChallenge(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (Controller) Ping

func (Controller) PlayerJoin

func (c Controller) PlayerJoin(w http.ResponseWriter, r *http.Request)

func (Controller) Register

Handles /team/register request

type IConroller

type IConroller interface {
	// Status endpoint
	Ping(http.ResponseWriter, *http.Request, httprouter.Params)
	// Endpoint for fetching currently available challenges
	FetchChallanges(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
	// Endpoint for installing defense modules
	InstallChallenge(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
	// Endpoint for registration
	Register(http.ResponseWriter, *http.Request, httprouter.Params)
	// Entry point for the websocket API
	PlayerJoin(w http.ResponseWriter, r *http.Request)
	// Boostrapping of the router
	GetRouter() *httprouter.Router
}

Describes the interface of the engine controller

func NewController

func NewController(
	bus bus.IBus,
	engineService IService,
	playerService player.IService,
	challengeService challenge.IService,
	scoreService scoreboard.IService,
) IConroller

Constructor for the engine controller

type IService

type IService interface {
	// Handles join event for users
	Join(dto.JoinEvent, *websocket.Conn) error
	// Triggers all calculations for the end result of the game
	FinishGame()
}

Describes an engine service interface

func NewService

func NewService(
	bus bus.IBus,
	playerService player.IService,
	challengeService challenge.IService,
	combatService combat.IService,
	scoreService scoreboard.IService,
) IService

Constructor for engine service

type ResponseCreator

type ResponseCreator struct{}

Static pointer struct to provide functions for consistent responses

func (*ResponseCreator) BadRequest

func (rc *ResponseCreator) BadRequest(w http.ResponseWriter, meta map[string]interface{})

Generic bad request

func (*ResponseCreator) Empty200

func (rc *ResponseCreator) Empty200(w http.ResponseWriter)

Describes an empty 200 response

func (*ResponseCreator) InternalServerError

func (rc *ResponseCreator) InternalServerError(w http.ResponseWriter)

Generic 500

func (*ResponseCreator) OK

func (rc *ResponseCreator) OK(w http.ResponseWriter, body interface{})

Describes a 200 with a given body

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implementation

func (*Service) FinishGame

func (s *Service) FinishGame()

func (*Service) Join

func (s *Service) Join(event dto.JoinEvent, conn *websocket.Conn) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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