Documentation
¶
Overview ¶
application implements logic of the game
Index ¶
- func NewDescriptionFieldEnemy(desc string) descriptionField
- func NewDescriptionFieldYours(desc string) descriptionField
- func RunApp(ctx context.Context, board boardGUI, client connection.Client)
- func StartApp(ctx context.Context)
- type Accuracy
- type GuiBoard
- func (g *GuiBoard) BoardListener(ctx context.Context, ch chan<- string, t <-chan struct{})
- func (g *GuiBoard) CreateBoard(stateBoard connection.BoardRespons) error
- func (g *GuiBoard) FireToBoard(coord string, resp connection.FireResponse) error
- func (g *GuiBoard) HighlighEmptyTiles(gotRow int, gotColumn int)
- func (g *GuiBoard) LogMessage(message string)
- func (g *GuiBoard) PrintDescription(ctx context.Context) error
- func (g *GuiBoard) SetTurnText(text string)
- func (g *GuiBoard) StartBoard(ctx context.Context, quit chan struct{})
- func (g *GuiBoard) StartTimer(ctx context.Context)
- func (g *GuiBoard) UpdateShipCountField(shipMastCount int)
- func (g *GuiBoard) UpdateTImer(time int)
- func (g *GuiBoard) UpdateYourBoard(coords []string) error
- type LegendField
- type ShipLeftCountField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDescriptionFieldEnemy ¶
func NewDescriptionFieldEnemy(desc string) descriptionField
NewDescriptionFielEnemy take enemy description string and return it devided to up to three lines and create descriptionField in appriopriate coordinates
func NewDescriptionFieldYours ¶
func NewDescriptionFieldYours(desc string) descriptionField
NewDescriptionFielYours take player description string and return it devided to up to three lines and create descriptionField
Types ¶
type Accuracy ¶
type Accuracy struct { ShotNumber uint16 HitNumber uint16 // contains filtered or unexported fields }
Accuracy show and monitor you percentage of hit shot / total number shot
func NewAccuracyField ¶
func NewAccuracyField() Accuracy
NewAccuracyField creates Accuracy in appropriate coordinates
type GuiBoard ¶
type GuiBoard struct { Description connection.Description // contains filtered or unexported fields }
GuiBoard contain variables needed to run the board and implements function needed to manipulate GUI and make it interactive ui - contain user interface yourBoard is user board field userBoardState - contain state of user's board enemyBoard is enemy board field enemyBoardState - contain state of enemy's board config - contain configuration of the board Description contain information about user's and enemy's nick and description turnText is field indication whose turn is now versusText is field which tell against whome user play descText is user description field oppDescText is opponent descritpion field fireLogText is field which logs your shots
func (*GuiBoard) BoardListener ¶
BoardListener listen to user click
func (*GuiBoard) CreateBoard ¶
func (g *GuiBoard) CreateBoard(stateBoard connection.BoardRespons) error
CreateBoard create board of the game
func (*GuiBoard) FireToBoard ¶
func (g *GuiBoard) FireToBoard(coord string, resp connection.FireResponse) error
Upate enemy board with user shots with its result
func (*GuiBoard) HighlighEmptyTiles ¶
HighlighEmptyTiles algorithm which set fields around the ship to miss and takes row and column coordinates of last shot. Script move clocwise.
func (*GuiBoard) PrintDescription ¶
PrintDescription print text fields on the board
func (*GuiBoard) SetTurnText ¶
SetTurnText change text indicating which turn is now
func (*GuiBoard) StartBoard ¶
StartBoard starting printing board
func (*GuiBoard) StartTimer ¶
StartTimer starting timerField which listen how much time left player have to decide on shot
func (*GuiBoard) UpdateShipCountField ¶
UpdateShipCountField update shipLeftCountField on the mast count number of sunken ship
func (*GuiBoard) UpdateTImer ¶
UpdateTimer take time and set counter to this number
func (*GuiBoard) UpdateYourBoard ¶
UpdateYourBoard update user board with enemy shot with indication if enemy missed or hit a ship
type LegendField ¶
type LegendField struct {
// contains filtered or unexported fields
}
LegendField create legend explaining fields on the board hitLegend explain hit field missLegend explain miss field shipLegend explain ship field
func NewLegendField ¶
func NewLegendField() LegendField
NewLegendField creates LegenField in appriopriate coordinates
type ShipLeftCountField ¶
type ShipLeftCountField struct { FourMastField *gui.Text FourMastCount int ThreeMastField *gui.Text ThreeMastCount int TwoMastField *gui.Text TwoMastCount int OneMastField *gui.Text OneMastCount int }
ShipLeftCountField creating fields teling ship left to strike FourMastField text field telling number of four mast ship left FourMastCount number telling how many four mast ship left to strike ThreeMastField text field telling number of three mast ship left ThreeMastCount number telling how many three mast ship left to strike TwoMastField text field telling number of two mast ship left TwoMastCount number telling how many two mast ship left to strike OneMastField text field telling number of one mast ship left OneMastCount number telling how many one mast ship left to strike
func NewShipLeftCountField ¶
func NewShipLeftCountField() ShipLeftCountField
NewShipLeftCountField creates ShipLeftCountField on appropriate coordinates and starting values of ships number
func (*ShipLeftCountField) UpdateFourMastField ¶
func (s *ShipLeftCountField) UpdateFourMastField()
UpdateFourMastField update FourMastField
func (*ShipLeftCountField) UpdateOneMastField ¶
func (s *ShipLeftCountField) UpdateOneMastField()
UpdateOneMastField update OneMastField
func (*ShipLeftCountField) UpdateThreeMastField ¶
func (s *ShipLeftCountField) UpdateThreeMastField()
UpdateThreeMastField update ThreeMastField
func (*ShipLeftCountField) UpdateTwoMastField ¶
func (s *ShipLeftCountField) UpdateTwoMastField()
UpdateTwoMastField update TwoMastField
Directories
¶
Path | Synopsis |
---|---|
menu create main menu of the game
|
menu create main menu of the game |
setShips handle a logic to position ships by the player
|
setShips handle a logic to position ships by the player |
contain algoritm which find all ship nodes
|
contain algoritm which find all ship nodes |
timer create a clock which count turn time
|
timer create a clock which count turn time |