tile.go 650 B

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