Loggest thy stuff
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.

37 lines
653 B

  1. package models
  2. type StatEntry struct {
  3. ID int `json:"id"`
  4. Name string `json:"name"`
  5. Weight float64 `json:"weight"`
  6. }
  7. type StatProgressEntry struct {
  8. StatEntry
  9. Acquired int `json:"acquired"`
  10. Required int `json:"required"`
  11. }
  12. type Stat struct {
  13. StatEntry
  14. Description string `json:"description"`
  15. AllowedAmounts map[string]int `json:"allowedAmounts"`
  16. }
  17. func (stat *Stat) AllowsAmount(amount int) bool {
  18. if stat == nil {
  19. return false
  20. }
  21. if stat.AllowedAmounts == nil || len(stat.AllowedAmounts) == 0 {
  22. return true
  23. }
  24. for _, v := range stat.AllowedAmounts {
  25. if v == amount {
  26. return true
  27. }
  28. }
  29. return false
  30. }