GameDefs_bonus.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package slotpanda
  2. // respin触发时单个Bonus信息
  3. type BonusInfo struct {
  4. Pos int // 位置:0-60 ,分4个区域
  5. Multiple int // 倍率
  6. }
  7. // respin每次触发产生的一帧中包含bonus的信息,如果没有则表示本轮不产生bonus
  8. type Bonus_Frame struct {
  9. Bonuses []BonusInfo
  10. }
  11. func (bf *Bonus_Frame) addBonus(pos, mul int) {
  12. bf.Bonuses = append(bf.Bonuses, BonusInfo{Pos: pos, Multiple: mul})
  13. }
  14. func (bf *Bonus_Frame) isEmpty() bool {
  15. return len(bf.Bonuses) == 0
  16. }
  17. type Bonus struct {
  18. BetAmount int // 下注额
  19. RespinCount int // 最大respin次数
  20. Frames []Bonus_Frame // 中间动画帧
  21. ResultBonuses []BonusInfo // 最终结果
  22. BonusResult int // bonus产生的赔付
  23. JackpotResult int // Jackpot赔付
  24. JackpotLevel int // Jackpot等级
  25. leftRespinCount int
  26. bonusIndex []bool
  27. }
  28. func newBonus() *Bonus {
  29. ret := new(Bonus)
  30. ret.bonusIndex = make([]bool, 60)
  31. return ret
  32. }
  33. func (b *Bonus) addFrame(frame Bonus_Frame) {
  34. b.Frames = append(b.Frames, frame)
  35. b.ResultBonuses = append(b.ResultBonuses, frame.Bonuses...)
  36. for _, v := range frame.Bonuses {
  37. b.bonusIndex[v.Pos] = true
  38. b.BonusResult += v.Multiple * b.BetAmount
  39. }
  40. }
  41. func (b *Bonus) isPass(pos int) bool {
  42. return b.bonusIndex[pos]
  43. }
  44. func (b *Bonus) getJackpotLevel() int {
  45. fullCount := 0
  46. for i := 0; i < 4; i++ {
  47. full := true
  48. for j := 0; j < 15; j++ {
  49. if !b.bonusIndex[i*15+j] {
  50. full = false
  51. break
  52. }
  53. }
  54. if full {
  55. fullCount++
  56. }
  57. }
  58. if fullCount == 4 {
  59. return JackpotLevelGrand
  60. }
  61. if fullCount == 3 {
  62. return JackpotLevelMajor
  63. }
  64. if fullCount == 2 {
  65. return JackpotLevelMinor
  66. }
  67. if fullCount == 1 {
  68. return JackpotLevelMini
  69. }
  70. return JackpotLevelNone
  71. }