freespin.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package wildapeslot
  2. import (
  3. "encoding/json"
  4. "os"
  5. "bet24.com/log"
  6. )
  7. type DragonChance struct {
  8. Name string // 名称
  9. Id int
  10. FreeCount int // 免费次数
  11. SlotCounts [][][]int
  12. slotCountManager *SlotCountManager
  13. }
  14. type FreeSpinInfo struct {
  15. ApeId int
  16. DragonGame []*DragonChance
  17. MatrixFree [3][9]int
  18. }
  19. func newFreeSpinInfo() *FreeSpinInfo {
  20. ret := new(FreeSpinInfo)
  21. ret.loadConfig()
  22. return ret
  23. }
  24. func (f *FreeSpinInfo) loadConfig() {
  25. data, err := os.ReadFile("slotconf/wildapeslot_free.json")
  26. if err != nil {
  27. log.Error("read wildapeslot_free.json failed")
  28. }
  29. err = json.Unmarshal(data, &f)
  30. if err != nil {
  31. log.Error("Unmarshal wildapeslot_free.json failed err:%v", err)
  32. return
  33. }
  34. for _, v := range f.DragonGame {
  35. v.slotCountManager = newSlotCountManagerByConfig(0, v.SlotCounts)
  36. }
  37. //初始化免费元素矩阵
  38. for i := 0; i < 3; i++ {
  39. index := 0
  40. for col := i; col < 3+i; col++ {
  41. for row := 0; row < 3; row++ {
  42. f.MatrixFree[i][index] = col + row*5
  43. index++
  44. }
  45. }
  46. }
  47. log.Debug("freeMatrix=", f.MatrixFree)
  48. }
  49. func (f *FreeSpinInfo) fillBonusResult(slots []int) int {
  50. count := 0
  51. for i := 0; i < 15; i++ {
  52. if slots[i] == BONUS_ID {
  53. count++
  54. }
  55. }
  56. return count
  57. }
  58. // 看下本轮是否中free,3*3的元素,返回,0表示没有中
  59. func (f *FreeSpinInfo) getFreeApe(slots []int) bool {
  60. for i := 0; i < len(f.MatrixFree); i++ {
  61. allApe := true
  62. for j := 0; j < len(f.MatrixFree[i]); j++ {
  63. index := f.MatrixFree[i][j]
  64. if slots[index] != FREE_ID {
  65. allApe = false
  66. log.Debug("find not free matrix%d,index%d", i, index)
  67. break
  68. }
  69. }
  70. if allApe {
  71. return true
  72. }
  73. }
  74. return false
  75. }
  76. //去掉
  77. func (f *FreeSpinInfo) get15Slots(level int, isFree bool, isBonus bool) []int {
  78. var ret []int
  79. dragon := f.DragonGame[0]
  80. if dragon == nil {
  81. log.Debug("FreeSpinInfo.get15Slots dragonId[%d] not exist")
  82. return ret
  83. }
  84. return dragon.slotCountManager.get15Slots(level, isFree, isBonus)
  85. }
  86. func (f *FreeSpinInfo) getLastDragonId() int {
  87. return f.DragonGame[len(f.DragonGame)-1].Id
  88. }