types.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package game
  2. import "github.com/gdamore/tcell/v3"
  3. // Directions for movement and actions
  4. const (
  5. up = iota
  6. left
  7. right
  8. down
  9. upleft
  10. upright
  11. downleft
  12. downright
  13. action
  14. rotateleft
  15. rotateright
  16. )
  17. const (
  18. updown = 1
  19. leftright = 2
  20. )
  21. // Styles holds the different styles for the game elements
  22. type Styles struct {
  23. text tcell.Style
  24. sea tcell.Style
  25. ship tcell.Style
  26. miss tcell.Style
  27. hit tcell.Style
  28. incorrect tcell.Style
  29. }
  30. // board stores the different boards, both water and ships.
  31. type board [][]int
  32. // Collection of ships
  33. type ships [][]string
  34. // Collection of ships
  35. type pieces struct {
  36. name string
  37. length int
  38. abreviation string
  39. }
  40. // Game holds the state of the game
  41. type Game struct {
  42. screen tcell.Screen
  43. style Styles
  44. keypresses chan int
  45. score int
  46. leftBoard board
  47. leftShips ships
  48. rightBoard board
  49. rightShips ships
  50. shipsets []pieces
  51. gameover int
  52. stats_score int
  53. stats_miss int
  54. stats_hits int
  55. logs []string
  56. }