freespin.go 564 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package TribalSlot
  2. import (
  3. "sort"
  4. )
  5. type FreeSpinTime struct {
  6. Count int // 匹配数量
  7. Time int // 免费次数
  8. }
  9. type FreeSpinInfo struct {
  10. SlotID int
  11. Time []FreeSpinTime
  12. }
  13. func (f *FreeSpinInfo) getFreeTime(slots []Slot) int {
  14. freeSlotCount := 0
  15. for _, v := range slots {
  16. if v.SlotID == f.SlotID {
  17. freeSlotCount++
  18. }
  19. }
  20. for _, v := range f.Time {
  21. if v.Count <= freeSlotCount {
  22. return v.Time
  23. }
  24. }
  25. return 0
  26. }
  27. func (f *FreeSpinInfo) sort() {
  28. sort.Slice(f.Time, func(i, j int) bool {
  29. return f.Time[i].Time > f.Time[j].Time
  30. })
  31. }