tile_animated.go 662 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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) Len() int {
  27. return len(t.symbols)
  28. }
  29. func (t *TileAnimated) ToMap() map[string]any {
  30. return map[string]any{
  31. "name": t.name,
  32. "symbols": t.symbols,
  33. "colors": t.colors,
  34. }
  35. }