chesslib

package module
v0.0.0-...-77c5e5b Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FigureTypeKing   = "KING"
	FigureTypeBishop = "BISHOP"
	FigureTypeRook   = "ROOK"
)

Types of figures

Variables

View Source
var (
	ErrCoordinatesNotValid          = errors.New("figure coordinates not valid")    // "figure coordinates not valid"
	ErrHorizontalCoordinateNotValid = errors.New("horizontal coordinate not valid") // "horizontal coordinate not valid"
	ErrVerticalCoordinateNotValid   = errors.New("vertical coordinate not valid")   // "vertical coordinate not valid"

	ErrKingCoordinatesNotValid   = errors.New("king coordinates not valid")   // "king coordinates not valid"
	ErrRookCoordinatesNotValid   = errors.New("rook coordinates not valid")   // "rook coordinates not valid"
	ErrBishopCoordinatesNotValid = errors.New("bishop coordinates not valid") // "bishop coordinates not valid"
)

Errors coordinates by diffrents figures. Errors returned by king danger calculator

Functions

This section is empty.

Types

type ChessKingUnderDangerCalculator

type ChessKingUnderDangerCalculator interface {
	IsKingUnderAttackRook(figureCoordinates, kingCoordinates string) (bool, error)
	IsKingUnderAttackBishop(figureCoordinates, kingCoordinates string) (bool, error)
}

Calculator for danger to king from figures

type ChessLib

type ChessLib struct {
	Debug  bool
	Logger Logger
}

Chess library implementation

func NewChessKingUnderDangerCalculator

func NewChessKingUnderDangerCalculator() *ChessLib

Create ChessKingUnderDangerCalculator instance

func (*ChessLib) IsKingUnderAttackBishop

func (ChessLib *ChessLib) IsKingUnderAttackBishop(figureCoordinates, kingCoordinates string) (bool, error)

Calculate danger to King from Bishop

func (*ChessLib) IsKingUnderAttackRook

func (ChessLib *ChessLib) IsKingUnderAttackRook(figureCoordinates, kingCoordinates string) (bool, error)

Calculate danger to King from Rook

type Logger

type Logger interface {
	DebugLog(figureType, figureCoordinates, kingCoordinates string,
		isUnderAttack bool, err error)
}

type LoggerImpl

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

func NewLogger

func NewLogger(isDebug bool) *LoggerImpl

func (*LoggerImpl) DebugLog

func (LoggerImpl *LoggerImpl) DebugLog(figureType, figureCoordinates, kingCoordinates string,
	isUnderAttack bool, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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