commands

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: AGPL-3.0 Imports: 25 Imported by: 1

Documentation

Overview

This file uses material from the Wikipedia article <a href="https://en.wikipedia.org/wiki/List_of_snakes_by_common_name">"List of snakes by common name"</a>, which is released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share-Alike License 3.0</a>.

Index

Constants

View Source
const (
	TERM_RESET = "\033[0m"

	TERM_BG_GRAY  = "\033[48;2;127;127;127m"
	TERM_BG_WHITE = "\033[107m"

	TERM_FG_GRAY      = "\033[38;2;127;127;127m"
	TERM_FG_LIGHTGRAY = "\033[38;2;200;200;200m"
	TERM_FG_FOOD      = "\033[38;2;255;92;117m"
	TERM_FG_RGB       = "\033[38;2;%d;%d;%dm"
)

ANSI escape codes to be used in the color output of the board view

Variables

This section is empty.

Functions

func Execute

func Execute()

func GenerateSnakeName added in v1.1.18

func GenerateSnakeName() string

Generate a random unique snake name, or return a UUID if there are no more names available.

func NewMapCommand added in v1.1.15

func NewMapCommand() *cobra.Command

func NewMapInfoCommand added in v1.1.15

func NewMapInfoCommand() *cobra.Command

func NewMapListCommand added in v1.1.15

func NewMapListCommand() *cobra.Command

func NewPlayCommand added in v1.1.4

func NewPlayCommand() *cobra.Command

Types

type GameExporter added in v1.0.24

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

func (*GameExporter) AddSnakeRequest added in v1.0.24

func (ge *GameExporter) AddSnakeRequest(snakeRequest client.SnakeRequest)

func (*GameExporter) ConvertToJSON added in v1.0.24

func (ge *GameExporter) ConvertToJSON() ([]string, error)

func (*GameExporter) FlushToFile added in v1.0.24

func (ge *GameExporter) FlushToFile(outputFile io.Writer) (int, error)

type GameState added in v1.1.4

type GameState struct {
	// Options
	Width               int
	Height              int
	Names               []string
	URLs                []string
	Timeout             int
	TurnDuration        int
	Sequential          bool
	GameType            string
	MapName             string
	ViewMap             bool
	UseColor            bool
	Seed                int64
	TurnDelay           int
	OutputPath          string
	ViewInBrowser       bool
	BoardURL            string
	FoodSpawnChance     int
	MinimumFood         int
	HazardDamagePerTurn int
	ShrinkEveryNTurns   int
	// contains filtered or unexported fields
}

func (*GameState) Initialize added in v1.2.0

func (gameState *GameState) Initialize() error

Setup a GameState once all the fields have been parsed from the command-line.

func (*GameState) Run added in v1.1.4

func (gameState *GameState) Run() error

Setup and run a full game.

type SnakeState added in v1.0.23

type SnakeState struct {
	URL        string
	Name       string
	ID         string
	LastMove   string
	Character  rune
	Color      string
	Head       string
	Tail       string
	Author     string
	Version    string
	Error      error
	StatusCode int
	Latency    time.Duration
}

Used to store state for each SnakeState while running a local game

type TimedHttpClient added in v1.1.21

type TimedHttpClient interface {
	Get(url string) (*http.Response, time.Duration, error)
	Post(url string, contentType string, body io.Reader) (*http.Response, time.Duration, error)
}

Jump to

Keyboard shortcuts

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