atomas

package
v0.0.0-...-3480783 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const END_OF_GAME = -1000
View Source
const (
	PLUS_SIGN int = 0
)

Variables

This section is empty.

Functions

func CreateCreateGameHandler

func CreateCreateGameHandler(games map[string]GameDTO, nextUUID func() string, randomElement func(int) int) func(http.ResponseWriter, *http.Request)

func CreateElementGenerator

func CreateElementGenerator(rand func() int) func(int) int

func CreateElementGeneratorArray

func CreateElementGeneratorArray(rand func() int) func([]int) int

func CreateGetGameHandler

func CreateGetGameHandler(games map[string]GameDTO) func(http.ResponseWriter, *http.Request)

func CreateHighScoreHandler

func CreateHighScoreHandler(games map[string]GameDTO) func(http.ResponseWriter, *http.Request)

func CreateMoveHandler

func CreateMoveHandler(games map[string]GameDTO, randomElement func([]int) int) func(http.ResponseWriter, *http.Request)

func CreateVersionHandler

func CreateVersionHandler(version string) func(http.ResponseWriter, *http.Request)

func EvaluateBoard

func EvaluateBoard(arrayBoard []int) (int, []int)

func Insert

func Insert(slice []int, element int, index int) []int

func Max

func Max(a int, b int) int

func ToJsonString

func ToJsonString(any interface{}) string

Types

type GameDTO

type GameDTO struct {
	Id               string `json:"id"`
	Ip               string `json:"ip"`
	Name             string `json:"name,omitempty"`
	Board            []int  `json:"board"`
	Next             int    `json:"next"`
	Round            int    `json:"round"`
	Score            int    `json:"score"`
	InitialBoard     []int  `json:"initial_borad"`
	PreviousElements []int  `json:"previous_elements"`
}

func GetHighScores

func GetHighScores(games map[string]GameDTO) [5]GameDTO

func Move

func Move(game GameDTO, moveTo int, next int) GameDTO

func NewGame

func NewGame(uuid string, ipAddress string, name string, randomElement func(int) int) GameDTO

func (GameDTO) NextBoard

func (game GameDTO) NextBoard(newBoard []int, newNext int, scoreForMove int) GameDTO

type ServerResponse

type ServerResponse struct {
	Response string
	Code     int
}

Jump to

Keyboard shortcuts

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