Documentation
¶
Index ¶
- func SetupRouter() (r *gin.Engine)
- func Throttle(i int) gin.HandlerFunc
- func TokenAuthMiddleWare() gin.HandlerFunc
- type ActionAttackRequest
- type ActionGamePlayerRequest
- type ActionMoveRequest
- type ActionPickupRequest
- type ActionUseRequest
- type AllGamesGame
- type AllGamesResponse
- type BoardStatuses
- type ErrorResponse
- type GameDetailResponse
- type GameEntities
- type GameEntitiesResponse
- type GameEventsResponse
- type GameInfoResponse
- type GameOptionsResponse
- type GameScoresResponse
- type GetGameDetailRequest
- type JoinPlayerRequest
- type MetaTotalScoresResponse
- type MetaTypesResponse
- type NewGameRequest
- type NewGameResponse
- type NewPlayerResponse
- type PlayerActions
- type PlayerGameRequest
- type PlayerLeaderBoardResponse
- type PlayerLeaderboardScore
- type PlayerRequest
- type PlayerScore
- type PlayerStatusResponse
- type PlayerSurroundingResponse
- type PlayerTotalScore
- type PowerupTypes
- type RegisterPlayerRequest
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupRouter ¶
SetupRouter configures the HTTP routes we have
func Throttle ¶
func Throttle(i int) gin.HandlerFunc
Throttle rate limits an endpoint for i per second
func TokenAuthMiddleWare ¶
func TokenAuthMiddleWare() gin.HandlerFunc
TokenAuthMiddleWare is a middleware that expects an API token ref: https://sosedoff.com/2014/12/21/gin-middleware.html
Types ¶
type ActionAttackRequest ¶
type ActionAttackRequest struct { GamePlayerIDs ActionGamePlayerRequest `json:"game_player_id" binding:"required"` X int `json:"x" binding:"required" example:"10"` Y int `json:"y" binding:"required" example:"9"` }
ActionAttackRequest is a request to move a player
func (*ActionAttackRequest) Validation ¶
func (r *ActionAttackRequest) Validation() error
Validation validates request values
type ActionGamePlayerRequest ¶
type ActionGamePlayerRequest struct { GameID string `json:"game_id" binding:"required,uuid" example:"1df69d53-3468-43df-a43b-a9c674240cab"` PlayerID string `json:"player_id" binding:"required,uuid" example:"6d950e36-b82b-4253-93d7-faa63d3a0e63"` }
ActionGamePlayerRequest is a request with the game and player is
func (*ActionGamePlayerRequest) Validation ¶
func (r *ActionGamePlayerRequest) Validation() error
Validation validates request values
type ActionMoveRequest ¶
type ActionMoveRequest struct { GamePlayerIDs ActionGamePlayerRequest `json:"game_player_id" binding:"required"` X int `json:"x" binding:"required" example:"10"` Y int `json:"y" binding:"required" example:"9"` }
ActionMoveRequest is a request to move a player
func (*ActionMoveRequest) Validation ¶
func (r *ActionMoveRequest) Validation() error
Validation validates request values
type ActionPickupRequest ¶
type ActionPickupRequest struct { GamePlayerIDs ActionGamePlayerRequest `json:"game_player_id" binding:"required"` X int `json:"x" binding:"required" example:"10"` Y int `json:"y" binding:"required" example:"9"` }
ActionPickupRequest is a request to move a player
func (*ActionPickupRequest) Validation ¶
func (r *ActionPickupRequest) Validation() error
Validation validates request values
type ActionUseRequest ¶
type ActionUseRequest struct { GamePlayerIDs ActionGamePlayerRequest `json:"game_player_id" binding:"required"` PowerUpID string `json:"powerup_id" binding:"required,uuid" example:"6d950e36-b82b-4253-93d7-faa63d3a0e63"` }
ActionUseRequest is a request to move a player
func (*ActionUseRequest) Validation ¶
func (r *ActionUseRequest) Validation() error
Validation validates request values
type AllGamesGame ¶
type AllGamesGame struct { ID string `json:"id"` Name string `json:"name"` Status int `json:"status"` }
AllGamesGame has details for a game in the all games response
type AllGamesResponse ¶
type AllGamesResponse struct {
Games []*AllGamesGame `json:"games"`
}
AllGamesResponse is a response with all games
type BoardStatuses ¶
type BoardStatuses struct { New game.BoardStatus `json:"new"` Running game.BoardStatus `json:"running"` Finished game.BoardStatus `json:"finished"` }
BoardStatuses are the game board statuses
type ErrorResponse ¶
ErrorResponse is an error response
type GameDetailResponse ¶
GameDetailResponse is a response with a single game
type GameEntities ¶
type GameEntities struct { PlayerEntity game.Entity `json:"player"` CreepEntity game.Entity `json:"creep"` PowerupEntity game.Entity `json:"powerup"` }
GameEntities are the game entities
type GameEntitiesResponse ¶
type GameEntitiesResponse struct { AliveCreep int `json:"alive_creep"` AlivePlayers int `json:"alive_players"` PowerUps int `json:"powerups"` }
GameEntitiesResponse contains the number of enties in a game
type GameEventsResponse ¶
GameEventsResponse is a response with a games' events
type GameInfoResponse ¶
type GameInfoResponse struct { Name string `json:"name"` Status game.BoardStatus `json:"status"` SizeX int `json:"size_x"` SizeY int `json:"size_y"` Fow float64 `json:"fow"` CurrentPlayer string `json:"current_player"` Created time.Time `json:"created"` Started time.Time `json:"started"` GameOptions GameOptionsResponse `json:"game_options"` GameEntities GameEntitiesResponse `json:"game_entities"` }
GameInfoResponse is a response summary for a game
type GameOptionsResponse ¶
type GameOptionsResponse struct { FogOfWarPercent int `json:"fow_percent"` AttackRange int `json:"player_attack_range"` PlayerRoundMoves int `json:"player_round_moves"` MaxRoundSeconds int `json:"player_round_seconds"` MaxPlayerMoveDistance int `json:"player_max_move_range"` PowerUpMax int `json:"powerup_max"` }
GameOptionsResponse are the options in the GameInfoResponse
type GameScoresResponse ¶
type GameScoresResponse struct {
Scores []*PlayerScore `json:"scores"`
}
GameScoresResponse is a response with a games' events
type GetGameDetailRequest ¶
type GetGameDetailRequest struct {
GameID string `uri:"game_id" binding:"required,uuid" example:"1df69d53-3468-43df-a43b-a9c674240cab"`
}
GetGameDetailRequest is a request with a game uuid
func (*GetGameDetailRequest) Validation ¶
func (r *GetGameDetailRequest) Validation() error
Validation validates request values
type JoinPlayerRequest ¶
type JoinPlayerRequest struct { GameID string `json:"game_id" binding:"required,uuid" example:"1df69d53-3468-43df-a43b-a9c674240cab"` PlayerID string `json:"player_id" binding:"required,uuid" example:"6d950e36-b82b-4253-93d7-faa63d3a0e63"` }
JoinPlayerRequest is a request to join a player to a game
func (*JoinPlayerRequest) Validation ¶
func (r *JoinPlayerRequest) Validation() error
Validation validates request values
type MetaTotalScoresResponse ¶
type MetaTotalScoresResponse struct {
Players []*PlayerTotalScore `json:"players"`
}
MetaTotalScoresResponse is a response containing game types
type MetaTypesResponse ¶
type MetaTypesResponse struct { PlayerActions *PlayerActions `json:"player_actions"` BoardStatuses *BoardStatuses `json:"board_statuses"` GameEntities *GameEntities `json:"game_entities"` PowerupTypes *PowerupTypes `json:"powerup_types"` }
MetaTypesResponse is a response containing game types
type NewGameRequest ¶
type NewGameRequest struct {
Name string `uri:"name" binding:"required" example:"pew pew"`
}
NewGameRequest is a request with a game uuid
func (*NewGameRequest) Validation ¶
func (r *NewGameRequest) Validation() error
Validation validates request values
type NewGameResponse ¶
NewGameResponse is a new game response
type NewPlayerResponse ¶
NewPlayerResponse is a response for a newly registered player
type PlayerActions ¶
type PlayerActions struct { Move game.ActionType `json:"move"` Attack game.ActionType `json:"attack"` Pickup game.ActionType `json:"pickup"` Nothing game.ActionType `json:"nothing"` }
PlayerActions are the player actions
type PlayerGameRequest ¶
type PlayerGameRequest struct { GameID string `json:"game_id" binding:"required,uuid" example:"1df69d53-3468-43df-a43b-a9c674240cab"` PlayerID string `json:"player_id" binding:"required,uuid" example:"6d950e36-b82b-4253-93d7-faa63d3a0e63"` }
PlayerGameRequest is a request that needs a player and game id
func (*PlayerGameRequest) Validation ¶
func (r *PlayerGameRequest) Validation() error
Validation validates request values
type PlayerLeaderBoardResponse ¶
type PlayerLeaderBoardResponse struct {
Scores []*PlayerLeaderboardScore `json:"scores"`
}
PlayerLeaderBoardResponse contains the leader board
type PlayerLeaderboardScore ¶
type PlayerLeaderboardScore struct { Name string `json:"name"` GameID string `json:"game_id"` GameName string `json:"game_name"` Score int `json:"score"` Position int `json:"position"` DamageTaken int `json:"damage_taken"` DamageDealt int `json:"damage_dealt"` CreepKills int `json:"creep_kills"` PlayerKills int `json:"player_kills"` }
PlayerLeaderboardScore is a player score representation
type PlayerRequest ¶
type PlayerRequest struct {
PlayerID string `json:"player_id" binding:"required,uuid" example:"6d950e36-b82b-4253-93d7-faa63d3a0e63"`
}
PlayerRequest is a request for a player
func (*PlayerRequest) Validation ¶
func (r *PlayerRequest) Validation() error
Validation validates request values
type PlayerScore ¶
type PlayerScore struct { Name string `json:"name"` Score int `json:"score"` DamageDealt int `json:"damage_dealt"` DamageTaken int `json:"damage_taken"` CreepKilled int `json:"killed_creep"` PlayersKilled int `json:"killed_players"` }
PlayerScore contains a players score
type PlayerStatusResponse ¶
PlayerStatusResponse is a player status response
type PlayerSurroundingResponse ¶
type PlayerSurroundingResponse struct { FOWEnabled bool `json:"fow_enabled"` Creep []*game.Creep `json:"creep"` Players []*game.Player `json:"players"` PowerUps []*game.PowerUp `json:"powerups"` }
PlayerSurroundingResponse is a surroundings response
type PlayerTotalScore ¶
type PlayerTotalScore struct { Name string `json:"name"` AveragePosition int `json:"average_position"` TotalScore int `json:"total_score"` TotalDamageTaken int `json:"total_damage_taken"` TotalDamageDealt int `json:"total_damage_dealt"` TotalCreepKills int `json:"total_creep_kills"` TotalPlayerKills int `json:"total_player_kills"` }
PlayerTotalScore contains player score totals
type PowerupTypes ¶
type PowerupTypes struct { Health game.PowerUpType `json:"health"` Teleport game.PowerUpType `json:"teleport"` DoubleDamage game.PowerUpType `json:"double_damage"` }
PowerupTypes are the powerups
type RegisterPlayerRequest ¶
type RegisterPlayerRequest struct {
Name string `json:"name" binding:"required" example:"my name"`
}
RegisterPlayerRequest is a request to register a player
func (*RegisterPlayerRequest) Validation ¶
func (r *RegisterPlayerRequest) Validation() error
Validation validates request values
type StatusResponse ¶
type StatusResponse struct {
Success bool `json:"success"`
}
StatusResponse is a status response