just a thing to find the string representation of a ripple playstyle in go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
836B

  1. // Package playstyle provides an enum for Ripple's playstyles.
  2. package playstyle
  3. import "strings"
  4. // PlayStyle is a bitwise enum containing the instruments a Ripple user likes
  5. // to play with.
  6. type PlayStyle int
  7. // various playstyles on ripple.
  8. const (
  9. Mouse int = 1 << iota
  10. Tablet
  11. Keyboard
  12. Touchscreen
  13. Spoon
  14. LeapMotion
  15. OculusRift
  16. Dick
  17. Eggplant
  18. )
  19. // Styles are string representations of the various playstyles someone can have.
  20. var Styles = [...]string{
  21. "Mouse",
  22. "Tablet",
  23. "Keyboard",
  24. "Touchscreen",
  25. "Spoon",
  26. "Leap motion",
  27. "Oculus rift",
  28. "Dick",
  29. "Eggplant",
  30. }
  31. // String is the string representation of a playstyle.
  32. func (p PlayStyle) String() string {
  33. var parts []string
  34. i := int(p)
  35. for k, v := range Styles {
  36. if i&(1<<uint(k)) > 0 {
  37. parts = append(parts, v)
  38. }
  39. }
  40. return strings.Join(parts, ", ")
  41. }