tile_animated.go 601 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. type TileAnimated struct {
  3. name string
  4. idx int
  5. symbols []string
  6. colors []string
  7. }
  8. func (t *TileAnimated) Name() string {
  9. return t.name
  10. }
  11. func (t *TileAnimated) Type() TileType {
  12. return AnimatedTile
  13. }
  14. func (t *TileAnimated) Symbol() string {
  15. return t.symbols[t.idx]
  16. }
  17. func (t *TileAnimated) Color() string {
  18. return t.colors[t.idx]
  19. }
  20. func (t *TileAnimated) Next() {
  21. t.idx++
  22. if t.idx >= len(t.symbols) {
  23. t.idx = 0
  24. }
  25. }
  26. func (t *TileAnimated) ToMap() map[string]any {
  27. return map[string]any{
  28. "name": t.name,
  29. "symbols": t.symbols,
  30. "colors": t.colors,
  31. }
  32. }