tile.go 723 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package board
  2. import "fmt"
  3. type TileType byte
  4. type jsonTile struct {
  5. X int `json:"x"`
  6. Y int `json:"y"`
  7. Type string `json:"type"`
  8. Player string `json:"player,omitempty"`
  9. }
  10. const (
  11. Water TileType = 0
  12. Rock TileType = 1
  13. Ice TileType = 2
  14. Iglo TileType = 3
  15. )
  16. func (t TileType) String() string {
  17. switch t {
  18. case Water:
  19. return "~"
  20. case Rock:
  21. return "▲"
  22. case Ice:
  23. return "*"
  24. case Iglo:
  25. return "⌂"
  26. }
  27. panic(fmt.Sprintf("Unknown tile type %#v", t))
  28. }
  29. func (t TileType) Name() string {
  30. switch t {
  31. case Water:
  32. return "W" // API says WATER... zucht.
  33. case Rock:
  34. return "R"
  35. case Ice:
  36. return "I"
  37. case Iglo:
  38. return "H"
  39. }
  40. panic(fmt.Sprintf("Unknown tile type %#v", t))
  41. }