game

package
v0.0.0-...-d4adc71 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GRID_ROW_SIZE = 10
	GRID_COL_SIZE = 10

	GRID_OCEAN = 0
	GRID_SHIP  = 1

	// ship cell value number base for store ship HIT status, TYPE, NUMBER
	SHIP_HIT_BASE    = 10
	SHIP_TYPE_BASE   = 100
	SHIP_NUMBER_BASE = 1000
)
View Source
const (
	CMD_TYPE_PLACE_SHIP = iota
	CMD_TYPE_FIRE
)

Type of commands

View Source
const (
	CMD_NAME_PLACE_SHIP = "PLACE_SHIP"
	CMD_NAME_FIRE       = "FIRE"
)

Type of command name

View Source
const (
	SHIP_TYPE_CARRIER = iota
	SHIP_TYPE_BATTLESHIP
	SHIP_TYPE_CRUISER
	SHIP_TYPE_SUBMARINE
	SHIP_TYPE_DESTROYER
)

Ship types

View Source
const (
	SHIP_TYPE_SIZE_CARRIER    = 5
	SHIP_TYPE_SIZE_BATTLESHIP = 4
	SHIP_TYPE_SIZE_CRUISER    = 3
	SHIP_TYPE_SIZE_SUBMARINE  = 3
	SHIP_TYPE_SIZE_DESTROYER  = 2
)

Ship size

View Source
const (
	SHIP_NAME_CARRIER    = "Carrier"
	SHIP_NAME_BATTLESHIP = "Battleship"
	SHIP_NAME_CRUISER    = "Cruiser"
	SHIP_NAME_SUBMARINE  = "Submarine"
	SHIP_NAME_DESTROYER  = "Destroyer"
)

Ship type names

View Source
const (
	SHIP_DIRECT_TYPE_RIGHT = iota
	SHIP_DIRECT_TYPE_DOWN
)

Type of ships direction

View Source
const (
	SHIP_DIRECT_NAME_RIGHT = "right"
	SHIP_DIRECT_NAME_DOWN  = "down"
)

Ship type names

View Source
const (
	FIRE_STATUS_HIT = iota
	FIRE_STATUS_MISS
	FIRE_STATUS_SUNK
	FIRE_STATUS_OVER
)
View Source
const (
	FIRE_STATUS_NAME_HIT  = "Hit"
	FIRE_STATUS_NAME_MISS = "Miss"
	FIRE_STATUS_NAME_SUNK = "You sunk my %s!"
	FIRE_STATUS_NAME_OVER = "Game Over"
)
View Source
const (
	SHIP_CELL_UP = iota
	SHIP_CELL_DOWN
	SHIP_CELL_LEFT
	SHIP_CELL_RIGHT
)
View Source
const (
	PLACED_STATUS_TEMPLATE = "Placed %s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Input file path
	InPath string
}

type Game

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

func New

func New(config Config) *Game

func (*Game) Play

func (g *Game) Play(inSrc io.Reader) error

func (*Game) Run

func (g *Game) Run() error

Jump to

Keyboard shortcuts

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